aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS5
-rw-r--r--Documentation/cpusets.txt3
-rw-r--r--Documentation/dvb/README.flexcop205
-rw-r--r--Documentation/dvb/bt8xx.txt69
-rw-r--r--Documentation/dvb/ci.txt219
-rw-r--r--Documentation/dvb/get_dvb_firmware4
-rw-r--r--Documentation/feature-removal-schedule.txt20
-rw-r--r--Documentation/filesystems/sysfs-pci.txt6
-rw-r--r--Documentation/power/devices.txt21
-rw-r--r--Documentation/powerpc/hvcs.txt4
-rw-r--r--Documentation/x86_64/boot-options.txt3
-rw-r--r--Makefile4
-rw-r--r--arch/alpha/kernel/osf_sys.c7
-rw-r--r--arch/arm/mach-s3c2410/clock.c2
-rw-r--r--arch/arm/mach-s3c2410/s3c2440.c6
-rw-r--r--arch/arm/mm/Kconfig21
-rw-r--r--arch/arm/mm/copypage-v4mc.S80
-rw-r--r--arch/arm/mm/copypage-v4mc.c111
-rw-r--r--arch/arm/mm/copypage-v6.c28
-rw-r--r--arch/arm/mm/flush.c37
-rw-r--r--arch/arm/mm/mm-armv.c27
-rw-r--r--arch/i386/Kconfig2
-rw-r--r--arch/i386/kernel/cpu/amd.c12
-rw-r--r--arch/i386/kernel/cpu/common.c4
-rw-r--r--arch/i386/kernel/smpboot.c1
-rw-r--r--arch/i386/mach-voyager/voyager_smp.c17
-rw-r--r--arch/i386/mm/ioremap.c10
-rw-r--r--arch/i386/pci/fixup.c2
-rw-r--r--arch/i386/pci/irq.c5
-rw-r--r--arch/ia64/ia32/ia32_ioctl.c1
-rw-r--r--arch/mips/vr41xx/common/pmu.c55
-rw-r--r--arch/ppc/kernel/head_44x.S15
-rw-r--r--arch/ppc/kernel/setup.c4
-rw-r--r--arch/ppc/lib/string.S7
-rw-r--r--arch/ppc/mm/init.c1
-rw-r--r--arch/ppc/syslib/ipic.c2
-rw-r--r--arch/ppc/syslib/mpc83xx_devices.c1
-rw-r--r--arch/ppc/syslib/mpc85xx_devices.c1
-rw-r--r--arch/ppc/syslib/open_pic.c2
-rw-r--r--arch/ppc64/kernel/mf.c85
-rw-r--r--arch/ppc64/kernel/pmac_smp.c28
-rw-r--r--arch/ppc64/kernel/prom_init.c44
-rw-r--r--arch/ppc64/kernel/rtc.c39
-rw-r--r--arch/ppc64/kernel/time.c1
-rw-r--r--arch/sparc64/kernel/pci_iommu.c167
-rw-r--r--arch/sparc64/kernel/sbus.c31
-rw-r--r--arch/sparc64/kernel/setup.c11
-rw-r--r--arch/sparc64/kernel/smp.c3
-rw-r--r--arch/sparc64/kernel/traps.c19
-rw-r--r--arch/um/Kconfig_x86_644
-rw-r--r--arch/um/drivers/chan_kern.c22
-rw-r--r--arch/um/drivers/mcast_kern.c4
-rw-r--r--arch/um/drivers/mcast_user.c47
-rw-r--r--arch/um/drivers/ubd_kern.c296
-rw-r--r--arch/um/include/sysdep-i386/ptrace.h2
-rw-r--r--arch/um/include/sysdep-x86_64/checksum.h26
-rw-r--r--arch/um/include/sysdep-x86_64/ptrace.h62
-rw-r--r--arch/um/kernel/Makefile2
-rw-r--r--arch/um/kernel/checksum.c0
-rw-r--r--arch/um/kernel/initrd.c78
-rw-r--r--arch/um/kernel/irq_user.c10
-rw-r--r--arch/um/kernel/ksyms.c1
-rw-r--r--arch/um/kernel/mem.c40
-rw-r--r--arch/um/kernel/ptrace.c6
-rw-r--r--arch/um/kernel/trap_kern.c36
-rw-r--r--arch/um/kernel/tt/ksyms.c1
-rw-r--r--arch/um/kernel/uml.lds.S2
-rw-r--r--arch/um/sys-i386/Makefile4
-rw-r--r--arch/um/sys-i386/delay.c16
-rw-r--r--arch/um/sys-x86_64/Makefile6
-rw-r--r--arch/um/sys-x86_64/delay.c33
-rw-r--r--arch/um/sys-x86_64/ksyms.c3
-rw-r--r--arch/um/sys-x86_64/ptrace.c9
-rw-r--r--arch/um/sys-x86_64/syscalls.c1
-rw-r--r--arch/um/sys-x86_64/user-offsets.c8
-rw-r--r--arch/x86_64/Kconfig16
-rw-r--r--arch/x86_64/defconfig58
-rw-r--r--arch/x86_64/kernel/Makefile1
-rw-r--r--arch/x86_64/kernel/apic.c5
-rw-r--r--arch/x86_64/kernel/entry.S11
-rw-r--r--arch/x86_64/kernel/io_apic.c81
-rw-r--r--arch/x86_64/kernel/mpparse.c22
-rw-r--r--arch/x86_64/kernel/nmi.c248
-rw-r--r--arch/x86_64/kernel/pmtimer.c101
-rw-r--r--arch/x86_64/kernel/ptrace.c17
-rw-r--r--arch/x86_64/kernel/setup.c30
-rw-r--r--arch/x86_64/kernel/signal.c4
-rw-r--r--arch/x86_64/kernel/smpboot.c263
-rw-r--r--arch/x86_64/kernel/time.c62
-rw-r--r--arch/x86_64/kernel/traps.c2
-rw-r--r--arch/x86_64/kernel/vsyscall.c5
-rw-r--r--arch/x86_64/kernel/x8664_ksyms.c3
-rw-r--r--arch/x86_64/mm/fault.c11
-rw-r--r--arch/x86_64/mm/ioremap.c29
-rw-r--r--crypto/crypto_null.c28
-rw-r--r--crypto/internal.h2
-rw-r--r--drivers/acpi/Kconfig5
-rw-r--r--drivers/acpi/pci_irq.c4
-rw-r--r--drivers/base/Makefile2
-rw-r--r--drivers/base/bus.c1
-rw-r--r--drivers/base/core.c7
-rw-r--r--drivers/base/interface.c51
-rw-r--r--drivers/base/power/power.h11
-rw-r--r--drivers/base/power/resume.c11
-rw-r--r--drivers/base/power/shutdown.c23
-rw-r--r--drivers/base/power/suspend.c17
-rw-r--r--drivers/block/ioctl.c2
-rw-r--r--drivers/block/pktcdvd.c16
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c20
-rw-r--r--drivers/char/raw.c2
-rw-r--r--drivers/char/watchdog/i8xx_tco.c1
-rw-r--r--drivers/i2c/busses/i2c-keywest.c5
-rw-r--r--drivers/ide/ide-cd.c50
-rw-r--r--drivers/ide/ide-disk.c41
-rw-r--r--drivers/ide/ide-floppy.c42
-rw-r--r--drivers/ide/ide-probe.c51
-rw-r--r--drivers/ide/ide-proc.c54
-rw-r--r--drivers/ide/ide-tape.c51
-rw-r--r--drivers/ide/ide.c307
-rw-r--r--drivers/ieee1394/Kconfig5
-rw-r--r--drivers/ieee1394/ieee1394_core.c3
-rw-r--r--drivers/ieee1394/ieee1394_transactions.c3
-rw-r--r--drivers/ieee1394/ieee1394_transactions.h7
-rw-r--r--drivers/ieee1394/nodemgr.c3
-rw-r--r--drivers/ieee1394/ohci1394.c2
-rw-r--r--drivers/ieee1394/ohci1394.h3
-rw-r--r--drivers/ieee1394/pcilynx.c394
-rw-r--r--drivers/ieee1394/pcilynx.h49
-rw-r--r--drivers/ieee1394/video1394.c139
-rw-r--r--drivers/infiniband/core/sa_query.c35
-rw-r--r--drivers/infiniband/core/user_mad.c4
-rw-r--r--drivers/infiniband/include/ib_sa.h4
-rw-r--r--drivers/input/keyboard/atkbd.c6
-rw-r--r--drivers/input/mouse/alps.c4
-rw-r--r--drivers/input/serio/serio.c25
-rw-r--r--drivers/input/serio/serport.c98
-rw-r--r--drivers/macintosh/therm_adt746x.c125
-rw-r--r--drivers/md/linear.c5
-rw-r--r--drivers/md/multipath.c8
-rw-r--r--drivers/md/raid1.c7
-rw-r--r--drivers/md/raid10.c6
-rw-r--r--drivers/md/raid5.c7
-rw-r--r--drivers/md/raid6main.c6
-rw-r--r--drivers/media/common/saa7146_core.c4
-rw-r--r--drivers/media/dvb/Kconfig2
-rw-r--r--drivers/media/dvb/b2c2/Kconfig50
-rw-r--r--drivers/media/dvb/b2c2/Makefile12
-rw-r--r--drivers/media/dvb/b2c2/b2c2-common.c214
-rw-r--r--drivers/media/dvb/b2c2/b2c2-usb-core.c549
-rw-r--r--drivers/media/dvb/b2c2/flexcop-common.h164
-rw-r--r--drivers/media/dvb/b2c2/flexcop-dma.c149
-rw-r--r--drivers/media/dvb/b2c2/flexcop-eeprom.c153
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c403
-rw-r--r--drivers/media/dvb/b2c2/flexcop-hw-filter.c204
-rw-r--r--drivers/media/dvb/b2c2/flexcop-i2c.c210
-rw-r--r--drivers/media/dvb/b2c2/flexcop-misc.c66
-rw-r--r--drivers/media/dvb/b2c2/flexcop-pci.c381
-rw-r--r--drivers/media/dvb/b2c2/flexcop-reg.h701
-rw-r--r--drivers/media/dvb/b2c2/flexcop-sram.c403
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.c577
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.h119
-rw-r--r--drivers/media/dvb/b2c2/flexcop.c286
-rw-r--r--drivers/media/dvb/b2c2/flexcop.h30
-rw-r--r--drivers/media/dvb/b2c2/skystar2.c20
-rw-r--r--drivers/media/dvb/bt8xx/Kconfig3
-rw-r--r--drivers/media/dvb/bt8xx/Makefile4
-rw-r--r--drivers/media/dvb/bt8xx/bt878.c54
-rw-r--r--drivers/media/dvb/bt8xx/bt878.h6
-rw-r--r--drivers/media/dvb/bt8xx/dst.c865
-rw-r--r--drivers/media/dvb/bt8xx/dst.h40
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c861
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.h58
-rw-r--r--drivers/media/dvb/bt8xx/dst_common.h153
-rw-r--r--drivers/media/dvb/bt8xx/dst_priv.h1
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c121
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.h4
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c12
-rw-r--r--drivers/media/dvb/dibusb/dvb-dibusb-dvb.c10
-rw-r--r--drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c4
-rw-r--r--drivers/media/dvb/dibusb/dvb-dibusb.h2
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c32
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c38
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c36
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c75
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c9
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.h2
-rw-r--r--drivers/media/dvb/frontends/Kconfig22
-rw-r--r--drivers/media/dvb/frontends/at76c651.c18
-rw-r--r--drivers/media/dvb/frontends/cx22700.c20
-rw-r--r--drivers/media/dvb/frontends/cx22702.c20
-rw-r--r--drivers/media/dvb/frontends/cx24110.c31
-rw-r--r--drivers/media/dvb/frontends/dib3000mb.c28
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.c26
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.h10
-rw-r--r--drivers/media/dvb/frontends/dvb_dummy_fe.c8
-rw-r--r--drivers/media/dvb/frontends/l64781.c22
-rw-r--r--drivers/media/dvb/frontends/mt312.c32
-rw-r--r--drivers/media/dvb/frontends/mt352.c40
-rw-r--r--drivers/media/dvb/frontends/mt352.h7
-rw-r--r--drivers/media/dvb/frontends/nxt2002.c22
-rw-r--r--drivers/media/dvb/frontends/nxt6000.c56
-rw-r--r--drivers/media/dvb/frontends/nxt6000_priv.h21
-rw-r--r--drivers/media/dvb/frontends/or51132.c14
-rw-r--r--drivers/media/dvb/frontends/sp8870.c20
-rw-r--r--drivers/media/dvb/frontends/sp887x.c22
-rw-r--r--drivers/media/dvb/frontends/stv0297.c24
-rw-r--r--drivers/media/dvb/frontends/stv0299.c114
-rw-r--r--drivers/media/dvb/frontends/tda10021.c22
-rw-r--r--drivers/media/dvb/frontends/tda1004x.c284
-rw-r--r--drivers/media/dvb/frontends/tda1004x.h7
-rw-r--r--drivers/media/dvb/frontends/tda8083.c26
-rw-r--r--drivers/media/dvb/frontends/tda80xx.c36
-rw-r--r--drivers/media/dvb/frontends/ves1820.c23
-rw-r--r--drivers/media/dvb/frontends/ves1x93.c24
-rw-r--r--drivers/media/dvb/ttpci/av7110.c144
-rw-r--r--drivers/media/dvb/ttpci/av7110.h3
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.c12
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.c4
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.c20
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.h5
-rw-r--r--drivers/media/dvb/ttpci/av7110_ir.c2
-rw-r--r--drivers/media/dvb/ttpci/av7110_v4l.c16
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c226
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c6
-rw-r--r--drivers/media/dvb/ttpci/budget-core.c12
-rw-r--r--drivers/media/dvb/ttpci/budget-patch.c4
-rw-r--r--drivers/media/dvb/ttpci/budget.c4
-rw-r--r--drivers/media/dvb/ttpci/budget.h5
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c22
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c28
-rw-r--r--drivers/media/video/Kconfig1
-rw-r--r--drivers/media/video/bttv-cards.c1
-rw-r--r--drivers/media/video/bttv-i2c.c3
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c10
-rw-r--r--drivers/media/video/video-buf-dvb.c12
-rw-r--r--drivers/mmc/Kconfig2
-rw-r--r--drivers/mmc/mmc_block.c5
-rw-r--r--drivers/mmc/wbsd.c716
-rw-r--r--drivers/mmc/wbsd.h12
-rw-r--r--drivers/net/Kconfig10
-rw-r--r--drivers/net/Makefile3
-rwxr-xr-xdrivers/net/amd8111e.c24
-rw-r--r--drivers/net/bnx2.c5530
-rw-r--r--drivers/net/bnx2.h4352
-rw-r--r--drivers/net/bnx2_fw.h2468
-rw-r--r--drivers/net/bonding/bond_main.c2
-rw-r--r--drivers/net/e100.c165
-rw-r--r--drivers/net/e1000/e1000.h37
-rw-r--r--drivers/net/e1000/e1000_ethtool.c105
-rw-r--r--drivers/net/e1000/e1000_hw.c1987
-rw-r--r--drivers/net/e1000/e1000_hw.h570
-rw-r--r--drivers/net/e1000/e1000_main.c1147
-rw-r--r--drivers/net/e1000/e1000_osdep.h32
-rw-r--r--drivers/net/e1000/e1000_param.c3
-rw-r--r--drivers/net/forcedeth.c103
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.c2
-rw-r--r--drivers/net/iseries_veth.c32
-rw-r--r--drivers/net/ixgb/ixgb.h2
-rw-r--r--drivers/net/ixgb/ixgb_ee.c24
-rw-r--r--drivers/net/ixgb/ixgb_ethtool.c4
-rw-r--r--drivers/net/ixgb/ixgb_main.c153
-rw-r--r--drivers/net/ixgb/ixgb_osdep.h3
-rw-r--r--drivers/net/natsemi.c6
-rw-r--r--drivers/net/ns83820.c69
-rw-r--r--drivers/net/pcnet32.c7
-rw-r--r--drivers/net/sis900.c52
-rw-r--r--drivers/net/tg3.c488
-rw-r--r--drivers/net/tg3.h8
-rw-r--r--drivers/net/tlan.c12
-rw-r--r--drivers/net/tulip/media.c1
-rw-r--r--drivers/net/tulip/tulip_core.c2
-rw-r--r--drivers/net/wireless/Kconfig2
-rw-r--r--drivers/net/wireless/airo.c150
-rw-r--r--drivers/net/wireless/atmel_cs.c1
-rw-r--r--drivers/pci/hotplug.c119
-rw-r--r--drivers/pci/hotplug/cpci_hotplug.h2
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c169
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_pci.c352
-rw-r--r--drivers/pci/hotplug/pciehp.h1
-rw-r--r--drivers/pci/hotplug/pciehp_core.c2
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c156
-rw-r--r--drivers/pci/hotplug/shpchp_core.c2
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c30
-rw-r--r--drivers/pci/pci-sysfs.c12
-rw-r--r--drivers/pci/pci.h27
-rw-r--r--drivers/pci/pcie/portdrv_bus.c3
-rw-r--r--drivers/pci/quirks.c40
-rw-r--r--drivers/pcmcia/ds.c4
-rw-r--r--drivers/s390/block/dasd.c16
-rw-r--r--drivers/s390/net/Makefile3
-rw-r--r--drivers/s390/net/ctcdbug.h12
-rw-r--r--drivers/s390/net/ctcmain.c616
-rw-r--r--drivers/s390/net/ctcmain.h276
-rw-r--r--drivers/s390/net/ctctty.c5
-rw-r--r--drivers/s390/net/cu3088.c4
-rw-r--r--drivers/s390/net/cu3088.h3
-rw-r--r--drivers/s390/net/iucv.c10
-rw-r--r--drivers/s390/net/lcs.c33
-rw-r--r--drivers/s390/net/qeth.h35
-rw-r--r--drivers/s390/net/qeth_eddp.c51
-rw-r--r--drivers/s390/net/qeth_main.c316
-rw-r--r--drivers/s390/net/qeth_tso.c285
-rw-r--r--drivers/s390/net/qeth_tso.h166
-rw-r--r--drivers/sbus/char/aurora.c8
-rw-r--r--drivers/scsi/aic7xxx/aic7770_osm.c52
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c1403
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.h169
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm_pci.c11
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_proc.c13
-rw-r--r--drivers/scsi/aic7xxx/aiclib.c1
-rw-r--r--drivers/scsi/ide-scsi.c86
-rw-r--r--drivers/scsi/libata-core.c25
-rw-r--r--drivers/scsi/libata-scsi.c5
-rw-r--r--drivers/scsi/sata_promise.c2
-rw-r--r--drivers/scsi/sata_sil.c1
-rw-r--r--drivers/scsi/sata_svw.c2
-rw-r--r--drivers/scsi/scsi_transport_spi.c188
-rw-r--r--drivers/serial/21285.c14
-rw-r--r--drivers/serial/8250.c32
-rw-r--r--drivers/serial/amba-pl010.c14
-rw-r--r--drivers/serial/amba-pl011.c14
-rw-r--r--drivers/serial/clps711x.c5
-rw-r--r--drivers/serial/pxa.c16
-rw-r--r--drivers/serial/s3c2410.c15
-rw-r--r--drivers/serial/sa1100.c5
-rw-r--r--drivers/serial/serial_cs.c4
-rw-r--r--drivers/serial/serial_lh7a40x.c13
-rw-r--r--drivers/serial/serial_txx9.c15
-rw-r--r--drivers/serial/sunsab.c109
-rw-r--r--drivers/serial/sunsab.h1
-rw-r--r--drivers/serial/vr41xx_siu.c6
-rw-r--r--drivers/usb/atm/speedtch.c2
-rw-r--r--drivers/usb/core/sysfs.c34
-rw-r--r--drivers/usb/host/ehci-hub.c1
-rw-r--r--drivers/usb/media/pwc/Makefile2
-rw-r--r--drivers/usb/media/pwc/pwc-ctrl.c12
-rw-r--r--drivers/usb/media/pwc/pwc-dec1.c42
-rw-r--r--drivers/usb/media/pwc/pwc-dec1.h36
-rw-r--r--drivers/usb/media/pwc/pwc-dec23.c623
-rw-r--r--drivers/usb/media/pwc/pwc-dec23.h58
-rw-r--r--drivers/usb/media/pwc/pwc-if.c9
-rw-r--r--drivers/usb/media/pwc/pwc-kiara.c573
-rw-r--r--drivers/usb/media/pwc/pwc-timon.c1130
-rw-r--r--drivers/usb/media/pwc/pwc-uncompress.c2
-rw-r--r--drivers/usb/net/Kconfig14
-rw-r--r--drivers/usb/net/usbnet.c53
-rw-r--r--drivers/usb/serial/cypress_m8.c2
-rw-r--r--drivers/usb/serial/cypress_m8.h1
-rw-r--r--fs/binfmt_elf.c4
-rw-r--r--fs/buffer.c8
-rw-r--r--fs/ext3/super.c10
-rw-r--r--fs/namei.c1
-rw-r--r--fs/proc/mmu.c14
-rw-r--r--fs/reiserfs/stree.c1
-rw-r--r--fs/reiserfs/super.c4
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c1
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c7
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.c29
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.h6
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c3
-rw-r--r--fs/xfs/xfs_iomap.c4
-rw-r--r--include/asm-arm/arch-imx/imx-regs.h24
-rw-r--r--include/asm-arm/arch-s3c2410/regs-nand.h44
-rw-r--r--include/asm-arm/page.h18
-rw-r--r--include/asm-i386/linkage.h4
-rw-r--r--include/asm-ia64/ioctl32.h1
-rw-r--r--include/asm-ppc64/iSeries/mf.h1
-rw-r--r--include/asm-sparc64/spitfire.h3
-rw-r--r--include/asm-um/arch-signal-i386.h0
-rw-r--r--include/asm-um/elf-i386.h2
-rw-r--r--include/asm-um/elf-x86_64.h24
-rw-r--r--include/asm-um/elf.h0
-rw-r--r--include/asm-x86_64/apicdef.h2
-rw-r--r--include/asm-x86_64/bug.h2
-rw-r--r--include/asm-x86_64/io_apic.h1
-rw-r--r--include/asm-x86_64/ioctl32.h1
-rw-r--r--include/asm-x86_64/nmi.h2
-rw-r--r--include/asm-x86_64/processor.h5
-rw-r--r--include/asm-x86_64/proto.h5
-rw-r--r--include/asm-x86_64/vsyscall.h3
-rw-r--r--include/linux/acpi.h5
-rw-r--r--include/linux/device.h3
-rw-r--r--include/linux/err.h4
-rw-r--r--include/linux/ide.h20
-rw-r--r--include/linux/if_tr.h45
-rw-r--r--include/linux/libata.h7
-rw-r--r--include/linux/mii.h8
-rw-r--r--include/linux/mmc/protocol.h27
-rw-r--r--include/linux/net.h1
-rw-r--r--include/linux/netdevice.h2
-rw-r--r--include/linux/pci_ids.h3
-rw-r--r--include/linux/pkt_sched.h9
-rw-r--r--include/linux/serial_core.h19
-rw-r--r--include/linux/spinlock.h8
-rw-r--r--include/linux/vmalloc.h1
-rw-r--r--include/linux/wait.h4
-rw-r--r--include/media/video-buf-dvb.h2
-rw-r--r--include/net/act_generic.h4
-rw-r--r--include/net/xfrm.h2
-rw-r--r--include/scsi/scsi_transport_spi.h6
-rw-r--r--kernel/cpuset.c24
-rw-r--r--kernel/irq/handle.c1
-rw-r--r--kernel/power/main.c6
-rw-r--r--kernel/printk.c72
-rw-r--r--kernel/profile.c16
-rw-r--r--kernel/sched.c2
-rw-r--r--kernel/signal.c11
-rw-r--r--kernel/spinlock.c8
-rw-r--r--mm/filemap.c2
-rw-r--r--mm/memory.c17
-rw-r--r--mm/mmap.c63
-rw-r--r--mm/mremap.c7
-rw-r--r--mm/nommu.c3
-rw-r--r--mm/rmap.c8
-rw-r--r--mm/swapfile.c2
-rw-r--r--mm/vmalloc.c33
-rw-r--r--net/802/tr.c26
-rw-r--r--net/ipv4/ip_output.c8
-rw-r--r--net/ipv4/ipvs/ip_vs_xmit.c1
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c28
-rw-r--r--net/ipv4/tcp_input.c11
-rw-r--r--net/ipv6/ip6_output.c14
-rw-r--r--net/ipv6/xfrm6_output.c1
-rw-r--r--net/ipv6/xfrm6_policy.c4
-rw-r--r--net/netlink/af_netlink.c13
-rw-r--r--net/sched/sch_netem.c209
-rw-r--r--net/unix/af_unix.c28
-rw-r--r--net/xfrm/xfrm_algo.c2
-rw-r--r--net/xfrm/xfrm_policy.c4
-rw-r--r--net/xfrm/xfrm_user.c15
-rw-r--r--security/selinux/ss/services.c8
431 files changed, 28821 insertions, 11622 deletions
diff --git a/CREDITS b/CREDITS
index 3b9e160d6f7e..9bd099d960f3 100644
--- a/CREDITS
+++ b/CREDITS
@@ -882,13 +882,12 @@ S: Blacksburg, Virginia 24061
882S: USA 882S: USA
883 883
884N: Randy Dunlap 884N: Randy Dunlap
885E: rddunlap@osdl.org 885E: rdunlap@xenotime.net
886W: http://www.xenotime.net/linux/linux.html 886W: http://www.xenotime.net/linux/linux.html
887W: http://www.linux-usb.org 887W: http://www.linux-usb.org
888D: Linux-USB subsystem, USB core/UHCI/printer/storage drivers 888D: Linux-USB subsystem, USB core/UHCI/printer/storage drivers
889D: x86 SMP, ACPI, bootflag hacking 889D: x86 SMP, ACPI, bootflag hacking
890S: 12725 SW Millikan Way, Suite 400 890S: (ask for current address)
891S: Beaverton, Oregon 97005
892S: USA 891S: USA
893 892
894N: Bob Dunlop 893N: Bob Dunlop
diff --git a/Documentation/cpusets.txt b/Documentation/cpusets.txt
index 1ad26d2c20ae..2f8f24eaefd9 100644
--- a/Documentation/cpusets.txt
+++ b/Documentation/cpusets.txt
@@ -252,8 +252,7 @@ in a tasks processor placement.
252There is an exception to the above. If hotplug funtionality is used 252There is an exception to the above. If hotplug funtionality is used
253to remove all the CPUs that are currently assigned to a cpuset, 253to remove all the CPUs that are currently assigned to a cpuset,
254then the kernel will automatically update the cpus_allowed of all 254then the kernel will automatically update the cpus_allowed of all
255tasks attached to CPUs in that cpuset with the online CPUs of the 255tasks attached to CPUs in that cpuset to allow all CPUs. When memory
256nearest parent cpuset that still has some CPUs online. When memory
257hotplug functionality for removing Memory Nodes is available, a 256hotplug functionality for removing Memory Nodes is available, a
258similar exception is expected to apply there as well. In general, 257similar exception is expected to apply there as well. In general,
259the kernel prefers to violate cpuset placement, over starving a task 258the kernel prefers to violate cpuset placement, over starving a task
diff --git a/Documentation/dvb/README.flexcop b/Documentation/dvb/README.flexcop
new file mode 100644
index 000000000000..a50c70f9ca72
--- /dev/null
+++ b/Documentation/dvb/README.flexcop
@@ -0,0 +1,205 @@
1This README escorted the skystar2-driver rewriting procedure. It describes the
2state of the new flexcop-driver set and some internals are written down here
3too.
4
5This document hopefully describes things about the flexcop and its
6device-offsprings. Goal was to write an easy-to-write and easy-to-read set of
7drivers based on the skystar2.c and other information.
8
9Remark: flexcop-pci.c was a copy of skystar2.c, but every line has been
10touched and rewritten.
11
12History & News
13==============
14 2005-04-01 - correct USB ISOC transfers (thanks to Vadim Catana)
15
16
17
18
19General coding processing
20=========================
21
22We should proceed as follows (as long as no one complains):
23
240) Think before start writing code!
25
261) rewriting the skystar2.c with the help of the flexcop register descriptions
27and splitting up the files to a pci-bus-part and a flexcop-part.
28The new driver will be called b2c2-flexcop-pci.ko/b2c2-flexcop-usb.ko for the
29device-specific part and b2c2-flexcop.ko for the common flexcop-functions.
30
312) Search for errors in the leftover of flexcop-pci.c (compare with pluto2.c
32and other pci drivers)
33
343) make some beautification (see 'Improvements when rewriting (refactoring) is
35done')
36
374) Testing the new driver and maybe substitute the skystar2.c with it, to reach
38a wider tester audience.
39
405) creating an usb-bus-part using the already written flexcop code for the pci
41card.
42
43Idea: create a kernel-object for the flexcop and export all important
44functions. This option saves kernel-memory, but maybe a lot of functions have
45to be exported to kernel namespace.
46
47
48Current situation
49=================
50
510) Done :)
521) Done (some minor issues left)
532) Done
543) Not ready yet, more information is necessary
554) next to be done (see the table below)
565) USB driver is working (yes, there are some minor issues)
57
58What seems to be ready?
59-----------------------
60
611) Rewriting
621a) i2c is cut off from the flexcop-pci.c and seems to work
631b) moved tuner and demod stuff from flexcop-pci.c to flexcop-tuner-fe.c
641c) moved lnb and diseqc stuff from flexcop-pci.c to flexcop-tuner-fe.c
651e) eeprom (reading MAC address)
661d) sram (no dynamic sll size detection (commented out) (using default as JJ told me))
671f) misc. register accesses for reading parameters (e.g. resetting, revision)
681g) pid/mac filter (flexcop-hw-filter.c)
691i) dvb-stuff initialization in flexcop.c (done)
701h) dma stuff (now just using the size-irq, instead of all-together, to be done)
711j) remove flexcop initialization from flexcop-pci.c completely (done)
721l) use a well working dma IRQ method (done, see 'Known bugs and problems and TODO')
731k) cleanup flexcop-files (remove unused EXPORT_SYMBOLs, make static from
74non-static where possible, moved code to proper places)
75
762) Search for errors in the leftover of flexcop-pci.c (partially done)
775a) add MAC address reading
785c) feeding of ISOC data to the software demux (format of the isochronous data
79and speed optimization, no real error) (thanks to Vadim Catana)
80
81What to do in the near future?
82--------------------------------------
83(no special order here)
84
855) USB driver
865b) optimize isoc-transfer (submitting/killing isoc URBs when transfer is starting)
87
88Testing changes
89---------------
90
91O = item is working
92P = item is partially working
93X = item is not working
94N = item does not apply here
95<empty field> = item need to be examined
96
97 | PCI | USB
98item | mt352 | nxt2002 | stv0299 | mt312 | mt352 | nxt2002 | stv0299 | mt312
99-------+-------+---------+---------+-------+-------+---------+---------+-------
1001a) | O | | | | N | N | N | N
1011b) | O | | | | | | O |
1021c) | N | N | | | N | N | O |
1031d) | O | O
1041e) | O | O
1051f) | P
1061g) | O
1071h) | P |
1081i) | O | N
1091j) | O | N
1101l) | O | N
1112) | O | N
1125a) | N | O
1135b)* | N |
1145c) | N | O
115
116* - not done yet
117
118Known bugs and problems and TODO
119--------------------------------
120
1211g/h/l) when pid filtering is enabled on the pci card
122
123DMA usage currently:
124 The DMA is splitted in 2 equal-sized subbuffers. The Flexcop writes to first
125 address and triggers an IRQ when it's full and starts writing to the second
126 address. When the second address is full, the IRQ is triggered again, and
127 the flexcop writes to first address again, and so on.
128 The buffersize of each address is currently 640*188 bytes.
129
130 Problem is, when using hw-pid-filtering and doing some low-bandwidth
131 operation (like scanning) the buffers won't be filled enough to trigger
132 the IRQ. That's why:
133
134 When PID filtering is activated, the timer IRQ is used. Every 1.97 ms the IRQ
135 is triggered. Is the current write address of DMA1 different to the one
136 during the last IRQ, then the data is passed to the demuxer.
137
138 There is an additional DMA-IRQ-method: packet count IRQ. This isn't
139 implemented correctly yet.
140
141 The solution is to disable HW PID filtering, but I don't know how the DVB
142 API software demux behaves on slow systems with 45MBit/s TS.
143
144Solved bugs :)
145--------------
1461g) pid-filtering (somehow pid index 4 and 5 (EMM_PID and ECM_PID) aren't
147working)
148SOLUTION: also index 0 was affected, because net_translation is done for
149these indexes by default
150
1515b) isochronous transfer does only work in the first attempt (for the Sky2PC
152USB, Air2PC is working) SOLUTION: the flexcop was going asleep and never really
153woke up again (don't know if this need fixes, see
154flexcop-fe-tuner.c:flexcop_sleep)
155
156NEWS: when the driver is loaded and unloaded and loaded again (w/o doing
157anything in the while the driver is loaded the first time), no transfers take
158place anymore.
159
160Improvements when rewriting (refactoring) is done
161=================================================
162
163- split sleeping of the flexcop (misc_204.ACPI3_sig = 1;) from lnb_control
164 (enable sleeping for other demods than dvb-s)
165- add support for CableStar (stv0297 Microtune 203x/ALPS) (almost done, incompatibilities with the Nexus-CA)
166
167Debugging
168---------
169- add verbose debugging to skystar2.c (dump the reg_dw_data) and compare it
170 with this flexcop, this is important, because i2c is now using the
171 flexcop_ibi_value union from flexcop-reg.h (do you have a better idea for
172 that, please tell us so).
173
174Everything which is identical in the following table, can be put into a common
175flexcop-module.
176
177 PCI USB
178-------------------------------------------------------------------------------
179Different:
180Register access: accessing IO memory USB control message
181I2C bus: I2C bus of the FC USB control message
182Data transfer: DMA isochronous transfer
183EEPROM transfer: through i2c bus not clear yet
184
185Identical:
186Streaming: accessing registers
187PID Filtering: accessing registers
188Sram destinations: accessing registers
189Tuner/Demod: I2C bus
190DVB-stuff: can be written for common use
191
192Acknowledgements (just for the rewriting part)
193================
194
195Bjarne Steinsbo thought a lot in the first place of the pci part for this code
196sharing idea.
197
198Andreas Oberritter for providing a recent PCI initialization template
199(pluto2.c).
200
201Boleslaw Ciesielski for pointing out a problem with firmware loader.
202
203Vadim Catana for correcting the USB transfer.
204
205comments, critics and ideas to linux-dvb@linuxtv.org.
diff --git a/Documentation/dvb/bt8xx.txt b/Documentation/dvb/bt8xx.txt
index e3cacf4f2345..d64430bf4bb6 100644
--- a/Documentation/dvb/bt8xx.txt
+++ b/Documentation/dvb/bt8xx.txt
@@ -17,74 +17,53 @@ Because of this, you need to enable
17"Device drivers" => "Multimedia devices" 17"Device drivers" => "Multimedia devices"
18 => "Video For Linux" => "BT848 Video For Linux" 18 => "Video For Linux" => "BT848 Video For Linux"
19 19
20Furthermore you need to enable
21"Device drivers" => "Multimedia devices" => "Digital Video Broadcasting Devices"
22 => "DVB for Linux" "DVB Core Support" "Nebula/Pinnacle PCTV/TwinHan PCI Cards"
23
202) Loading Modules 242) Loading Modules
21================== 25==================
22 26
23In general you need to load the bttv driver, which will handle the gpio and 27In general you need to load the bttv driver, which will handle the gpio and
24i2c communication for us. Next you need the common dvb-bt8xx device driver 28i2c communication for us, plus the common dvb-bt8xx device driver.
25and one frontend driver. 29The frontends for Nebula (nxt6000), Pinnacle PCTV (cx24110) and
26 30TwinHan (dst) are loaded automatically by the dvb-bt8xx device driver.
27The bttv driver will HANG YOUR SYSTEM IF YOU DO NOT SPECIFY THE CORRECT
28CARD ID!
29
30(If you don't get your card running and you suspect that the card id you're
31using is wrong, have a look at "bttv-cards.c" for a list of possible card
32ids.)
33
34Pay attention to failures when you load the frontend drivers
35(e.g. dmesg, /var/log/messages).
36 31
373a) Nebula / Pinnacle PCTV 323a) Nebula / Pinnacle PCTV
38-------------------------- 33--------------------------
39 34
40 $ modprobe bttv i2c_hw=1 card=0x68 35 $ modprobe bttv (normally bttv is being loaded automatically by kmod)
41 $ modprobe dvb-bt8xx 36 $ modprobe dvb-bt8xx (or just place dvb-bt8xx in /etc/modules for automatic loading)
42
43For Nebula cards use the "nxt6000" frontend driver:
44 $ modprobe nxt6000
45 37
46For Pinnacle PCTV cards use the "cx24110" frontend driver:
47 $ modprobe cx24110
48 38
493b) TwinHan 393b) TwinHan and Clones
50----------- 40--------------------------
51 41
52 $ modprobe bttv i2c_hw=1 card=0x71 42 $ modprobe bttv i2c_hw=1 card=0x71
53 $ modprobe dvb-bt8xx 43 $ modprobe dvb-bt8xx
54 $ modprobe dst 44 $ modprobe dst
55 45
56The value 0x71 will override the PCI type detection for dvb-bt8xx, which 46The value 0x71 will override the PCI type detection for dvb-bt8xx,
57is necessary for TwinHan cards.# 47which is necessary for TwinHan cards.
58 48
59If you're having an older card (blue color circuit) and card=0x71 locks your 49If you're having an older card (blue color circuit) and card=0x71 locks
60machine, try using 0x68, too. If that does not work, ask on the DVB mailing list. 50your machine, try using 0x68, too. If that does not work, ask on the
51mailing list.
61 52
62The DST module takes a couple of useful parameters, in case the 53The DST module takes a couple of useful parameters.
63dst drivers fails to detect your type of card correctly.
64 54
65dst_type takes values 0 (satellite), 1 (terrestial TV), 2 (cable). 55verbose takes values 0 to 5. These values control the verbosity level.
66 56
67dst_type_flags takes bit combined values: 57debug takes values 0 and 1. You can either disable or enable debugging.
681 = new tuner type packets. You can use this if your card is detected
69 and you have debug and you continually see the tuner packets not
70 working (make sure not a basic problem like dish alignment etc.)
71 58
722 = TS 204. If your card tunes OK, but the picture is terrible, seemingly 59dst_addons takes values 0 and 0x20. A value of 0 means it is a FTA card.
73 breaking up in one half continually, and crc fails a lot, then 600x20 means it has a Conditional Access slot.
74 this is worth a try (or trying to turn off)
75 61
764 = has symdiv. Some cards, mostly without new tuner packets, require 62The autodected values are determined bythe cards 'response
77 a symbol division algorithm. Doesn't apply to terrestial TV.
78
79You can also specify a value to have the autodetected values turned off
80(e.g. 0). The autodected values are determined bythe cards 'response
81string' which you can see in your logs e.g. 63string' which you can see in your logs e.g.
82 64
83dst_check_ci: recognize DST-MOT 65dst_get_device_id: Recognise [DSTMCI]
84
85or
86 66
87dst_check_ci: unable to recognize DSTXCI or STXCI
88 67
89-- 68--
90Authors: Richard Walker, Jamie Honan, Michael Hunold 69Authors: Richard Walker, Jamie Honan, Michael Hunold, Manu Abraham
diff --git a/Documentation/dvb/ci.txt b/Documentation/dvb/ci.txt
new file mode 100644
index 000000000000..62e0701b542a
--- /dev/null
+++ b/Documentation/dvb/ci.txt
@@ -0,0 +1,219 @@
1* For the user
2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3NOTE: This document describes the usage of the high level CI API as
4in accordance to the Linux DVB API. This is a not a documentation for the,
5existing low level CI API.
6~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7
8To utilize the High Level CI capabilities,
9
10(1*) This point is valid only for the Twinhan/clones
11 For the Twinhan/Twinhan clones, the dst_ca module handles the CI
12 hardware handling.This module is loaded automatically if a CI
13 (Common Interface, that holds the CAM (Conditional Access Module)
14 is detected.
15
16(2) one requires a userspace application, ca_zap. This small userland
17 application is in charge of sending the descrambling related information
18 to the CAM.
19
20This application requires the following to function properly as of now.
21
22 (a) Tune to a valid channel, with szap.
23 eg: $ szap -c channels.conf -r "TMC" -x
24
25 (b) a channels.conf containing a valid PMT PID
26
27 eg: TMC:11996:h:0:27500:278:512:650:321
28
29 here 278 is a valid PMT PID. the rest of the values are the
30 same ones that szap uses.
31
32 (c) after running a szap, you have to run ca_zap, for the
33 descrambler to function,
34
35 eg: $ ca_zap patched_channels.conf "TMC"
36
37 The patched means a patch to apply to scan, such that scan can
38 generate a channels.conf_with pmt, which has this PMT PID info
39 (NOTE: szap cannot use this channels.conf with the PMT_PID)
40
41
42 (d) Hopeflly Enjoy your favourite subscribed channel as you do with
43 a FTA card.
44
45(3) Currently ca_zap, and dst_test, both are meant for demonstration
46 purposes only, they can become full fledged applications if necessary.
47
48
49* Cards that fall in this category
50~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51At present the cards that fall in this category are the Twinhan and it's
52clones, these cards are available as VVMER, Tomato, Hercules, Orange and
53so on.
54
55* CI modules that are supported
56~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57The CI module support is largely dependant upon the firmware on the cards
58Some cards do support almost all of the available CI modules. There is
59nothing much that can be done in order to make additional CI modules
60working with these cards.
61
62Modules that have been tested by this driver at present are
63
64(1) Irdeto 1 and 2 from SCM
65(2) Viaccess from SCM
66(3) Dragoncam
67
68* The High level CI API
69~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70
71* For the programmer
72~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73With the High Level CI approach any new card with almost any random
74architecture can be implemented with this style, the definitions
75insidethe switch statement can be easily adapted for any card, thereby
76eliminating the need for any additional ioctls.
77
78The disadvantage is that the driver/hardware has to manage the rest. For
79the application programmer it would be as simple as sending/receiving an
80array to/from the CI ioctls as defined in the Linux DVB API. No changes
81have been made in the API to accomodate this feature.
82
83
84* Why the need for another CI interface ?
85~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86This is one of the most commonly asked question. Well a nice question.
87Strictly speaking this is not a new interface.
88
89The CI interface is defined in the DVB API in ca.h as
90
91typedef struct ca_slot_info {
92 int num; /* slot number */
93
94 int type; /* CA interface this slot supports */
95#define CA_CI 1 /* CI high level interface */
96#define CA_CI_LINK 2 /* CI link layer level interface */
97#define CA_CI_PHYS 4 /* CI physical layer level interface */
98#define CA_DESCR 8 /* built-in descrambler */
99#define CA_SC 128 /* simple smart card interface */
100
101 unsigned int flags;
102#define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */
103#define CA_CI_MODULE_READY 2
104} ca_slot_info_t;
105
106
107
108This CI interface follows the CI high level interface, which is not
109implemented by most applications. Hence this area is revisited.
110
111This CI interface is quite different in the case that it tries to
112accomodate all other CI based devices, that fall into the other categories
113
114This means that this CI interface handles the EN50221 style tags in the
115Application layer only and no session management is taken care of by the
116application. The driver/hardware will take care of all that.
117
118This interface is purely an EN50221 interface exchanging APDU's. This
119means that no session management, link layer or a transport layer do
120exist in this case in the application to driver communication. It is
121as simple as that. The driver/hardware has to take care of that.
122
123
124With this High Level CI interface, the interface can be defined with the
125regular ioctls.
126
127All these ioctls are also valid for the High level CI interface
128
129#define CA_RESET _IO('o', 128)
130#define CA_GET_CAP _IOR('o', 129, ca_caps_t)
131#define CA_GET_SLOT_INFO _IOR('o', 130, ca_slot_info_t)
132#define CA_GET_DESCR_INFO _IOR('o', 131, ca_descr_info_t)
133#define CA_GET_MSG _IOR('o', 132, ca_msg_t)
134#define CA_SEND_MSG _IOW('o', 133, ca_msg_t)
135#define CA_SET_DESCR _IOW('o', 134, ca_descr_t)
136#define CA_SET_PID _IOW('o', 135, ca_pid_t)
137
138
139On querying the device, the device yields information thus
140
141CA_GET_SLOT_INFO
142----------------------------
143Command = [info]
144APP: Number=[1]
145APP: Type=[1]
146APP: flags=[1]
147APP: CI High level interface
148APP: CA/CI Module Present
149
150CA_GET_CAP
151----------------------------
152Command = [caps]
153APP: Slots=[1]
154APP: Type=[1]
155APP: Descrambler keys=[16]
156APP: Type=[1]
157
158CA_SEND_MSG
159----------------------------
160Descriptors(Program Level)=[ 09 06 06 04 05 50 ff f1]
161Found CA descriptor @ program level
162
163(20) ES type=[2] ES pid=[201] ES length =[0 (0x0)]
164(25) ES type=[4] ES pid=[301] ES length =[0 (0x0)]
165ca_message length is 25 (0x19) bytes
166EN50221 CA MSG=[ 9f 80 32 19 03 01 2d d1 f0 08 01 09 06 06 04 05 50 ff f1 02 e0 c9 00 00 04 e1 2d 00 00]
167
168
169Not all ioctl's are implemented in the driver from the API, the other
170features of the hardware that cannot be implemented by the API are achieved
171using the CA_GET_MSG and CA_SEND_MSG ioctls. An EN50221 style wrapper is
172used to exchange the data to maintain compatibility with other hardware.
173
174
175/* a message to/from a CI-CAM */
176typedef struct ca_msg {
177 unsigned int index;
178 unsigned int type;
179 unsigned int length;
180 unsigned char msg[256];
181} ca_msg_t;
182
183
184The flow of data can be described thus,
185
186
187
188
189
190 App (User)
191 -----
192 parse
193 |
194 |
195 v
196 en50221 APDU (package)
197 --------------------------------------
198 | | | High Level CI driver
199 | | |
200 | v |
201 | en50221 APDU (unpackage) |
202 | | |
203 | | |
204 | v |
205 | sanity checks |
206 | | |
207 | | |
208 | v |
209 | do (H/W dep) |
210 --------------------------------------
211 | Hardware
212 |
213 v
214
215
216
217
218The High Level CI interface uses the EN50221 DVB standard, following a
219standard ensures futureproofness.
diff --git a/Documentation/dvb/get_dvb_firmware b/Documentation/dvb/get_dvb_firmware
index 3ffdcb394299..a750f0101d9d 100644
--- a/Documentation/dvb/get_dvb_firmware
+++ b/Documentation/dvb/get_dvb_firmware
@@ -107,7 +107,7 @@ sub tda10045 {
107sub tda10046 { 107sub tda10046 {
108 my $sourcefile = "tt_budget_217g.zip"; 108 my $sourcefile = "tt_budget_217g.zip";
109 my $url = "http://www.technotrend.de/new/217g/$sourcefile"; 109 my $url = "http://www.technotrend.de/new/217g/$sourcefile";
110 my $hash = "a25b579e37109af60f4a36c37893957c"; 110 my $hash = "6a7e1e2f2644b162ff0502367553c72d";
111 my $outfile = "dvb-fe-tda10046.fw"; 111 my $outfile = "dvb-fe-tda10046.fw";
112 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 112 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
113 113
@@ -115,7 +115,7 @@ sub tda10046 {
115 115
116 wgetfile($sourcefile, $url); 116 wgetfile($sourcefile, $url);
117 unzip($sourcefile, $tmpdir); 117 unzip($sourcefile, $tmpdir);
118 extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x3f731, 24479, "$tmpdir/fwtmp"); 118 extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x3f731, 24478, "$tmpdir/fwtmp");
119 verify("$tmpdir/fwtmp", $hash); 119 verify("$tmpdir/fwtmp", $hash);
120 copy("$tmpdir/fwtmp", $outfile); 120 copy("$tmpdir/fwtmp", $outfile);
121 121
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index d3c52dd24a2a..b9eb209318ab 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -63,3 +63,23 @@ Why: Outside of Linux, the only implementations of anything even
63 people, who might be using implementations that I am not aware 63 people, who might be using implementations that I am not aware
64 of, to adjust to this upcoming change. 64 of, to adjust to this upcoming change.
65Who: Paul E. McKenney <paulmck@us.ibm.com> 65Who: Paul E. McKenney <paulmck@us.ibm.com>
66
67---------------------------
68
69What: IEEE1394 Audio and Music Data Transmission Protocol driver,
70 Connection Management Procedures driver
71When: November 2005
72Files: drivers/ieee1394/{amdtp,cmp}*
73Why: These are incomplete, have never worked, and are better implemented
74 in userland via raw1394 (see http://freebob.sourceforge.net/ for
75 example.)
76Who: Jody McIntyre <scjody@steamballoon.com>
77
78---------------------------
79
80What: raw1394: requests of type RAW1394_REQ_ISO_SEND, RAW1394_REQ_ISO_LISTEN
81When: November 2005
82Why: Deprecated in favour of the new ioctl-based rawiso interface, which is
83 more efficient. You should really be using libraw1394 for raw1394
84 access anyway.
85Who: Jody McIntyre <scjody@steamballoon.com>
diff --git a/Documentation/filesystems/sysfs-pci.txt b/Documentation/filesystems/sysfs-pci.txt
index e97d024eae77..988a62fae11f 100644
--- a/Documentation/filesystems/sysfs-pci.txt
+++ b/Documentation/filesystems/sysfs-pci.txt
@@ -7,7 +7,6 @@ that support it. For example, a given bus might look like this:
7 |-- 0000:17:00.0 7 |-- 0000:17:00.0
8 | |-- class 8 | |-- class
9 | |-- config 9 | |-- config
10 | |-- detach_state
11 | |-- device 10 | |-- device
12 | |-- irq 11 | |-- irq
13 | |-- local_cpus 12 | |-- local_cpus
@@ -19,7 +18,7 @@ that support it. For example, a given bus might look like this:
19 | |-- subsystem_device 18 | |-- subsystem_device
20 | |-- subsystem_vendor 19 | |-- subsystem_vendor
21 | `-- vendor 20 | `-- vendor
22 `-- detach_state 21 `-- ...
23 22
24The topmost element describes the PCI domain and bus number. In this case, 23The topmost element describes the PCI domain and bus number. In this case,
25the domain number is 0000 and the bus number is 17 (both values are in hex). 24the domain number is 0000 and the bus number is 17 (both values are in hex).
@@ -31,7 +30,6 @@ files, each with their own function.
31 ---- -------- 30 ---- --------
32 class PCI class (ascii, ro) 31 class PCI class (ascii, ro)
33 config PCI config space (binary, rw) 32 config PCI config space (binary, rw)
34 detach_state connection status (bool, rw)
35 device PCI device (ascii, ro) 33 device PCI device (ascii, ro)
36 irq IRQ number (ascii, ro) 34 irq IRQ number (ascii, ro)
37 local_cpus nearby CPU mask (cpumask, ro) 35 local_cpus nearby CPU mask (cpumask, ro)
@@ -85,4 +83,4 @@ useful return codes should be provided.
85 83
86Legacy resources are protected by the HAVE_PCI_LEGACY define. Platforms 84Legacy resources are protected by the HAVE_PCI_LEGACY define. Platforms
87wishing to support legacy functionality should define it and provide 85wishing to support legacy functionality should define it and provide
88pci_legacy_read, pci_legacy_write and pci_mmap_legacy_page_range functions. \ No newline at end of file 86pci_legacy_read, pci_legacy_write and pci_mmap_legacy_page_range functions.
diff --git a/Documentation/power/devices.txt b/Documentation/power/devices.txt
index 5d4ae9a39f1d..f987afe43e28 100644
--- a/Documentation/power/devices.txt
+++ b/Documentation/power/devices.txt
@@ -207,27 +207,6 @@ SYSTEM_SHUTDOWN, I do not understand this one too much. probably event
207#READY_AFTER_RESUME 207#READY_AFTER_RESUME
208# 208#
209 209
210Driver Detach Power Management
211
212The kernel now supports the ability to place a device in a low-power
213state when it is detached from its driver, which happens when its
214module is removed.
215
216Each device contains a 'detach_state' file in its sysfs directory
217which can be used to control this state. Reading from this file
218displays what the current detach state is set to. This is 0 (On) by
219default. A user may write a positive integer value to this file in the
220range of 1-4 inclusive.
221
222A value of 1-3 will indicate the device should be placed in that
223low-power state, which will cause ->suspend() to be called for that
224device. A value of 4 indicates that the device should be shutdown, so
225->shutdown() will be called for that device.
226
227The driver is responsible for reinitializing the device when the
228module is re-inserted during it's ->probe() (or equivalent) method.
229The driver core will not call any extra functions when binding the
230device to the driver.
231 210
232pm_message_t meaning 211pm_message_t meaning
233 212
diff --git a/Documentation/powerpc/hvcs.txt b/Documentation/powerpc/hvcs.txt
index c0a62e116e6e..dca75cbda6f8 100644
--- a/Documentation/powerpc/hvcs.txt
+++ b/Documentation/powerpc/hvcs.txt
@@ -347,8 +347,8 @@ address that is created by firmware. An example vty-server sysfs entry
347looks like the following: 347looks like the following:
348 348
349 Pow5:/sys/bus/vio/drivers/hvcs/30000004 # ls 349 Pow5:/sys/bus/vio/drivers/hvcs/30000004 # ls
350 . current_vty devspec name partner_vtys 350 . current_vty devspec name partner_vtys
351 .. detach_state index partner_clcs vterm_state 351 .. index partner_clcs vterm_state
352 352
353Each entry is provided, by default with a "name" attribute. Reading the 353Each entry is provided, by default with a "name" attribute. Reading the
354"name" attribute will reveal the device type as shown in the following 354"name" attribute will reveal the device type as shown in the following
diff --git a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt
index 44b6eea60ece..b9e6be00cadf 100644
--- a/Documentation/x86_64/boot-options.txt
+++ b/Documentation/x86_64/boot-options.txt
@@ -25,6 +25,9 @@ APICs
25 25
26 noapictimer Don't set up the APIC timer 26 noapictimer Don't set up the APIC timer
27 27
28 no_timer_check Don't check the IO-APIC timer. This can work around
29 problems with incorrect timer initialization on some boards.
30
28Early Console 31Early Console
29 32
30 syntax: earlyprintk=vga 33 syntax: earlyprintk=vga
diff --git a/Makefile b/Makefile
index bddcb861b49b..c11a317ea910 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 12 3SUBLEVEL = 12
4EXTRAVERSION =-rc4 4EXTRAVERSION =-rc5
5NAME=Woozy Numbat 5NAME=Woozy Numbat
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -530,7 +530,7 @@ endif
530include $(srctree)/arch/$(ARCH)/Makefile 530include $(srctree)/arch/$(ARCH)/Makefile
531 531
532# arch Makefile may override CC so keep this after arch Makefile is included 532# arch Makefile may override CC so keep this after arch Makefile is included
533NOSTDINC_FLAGS := -nostdinc -isystem $(shell $(CC) -print-file-name=include) 533NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
534CHECKFLAGS += $(NOSTDINC_FLAGS) 534CHECKFLAGS += $(NOSTDINC_FLAGS)
535 535
536# warn about C99 declaration after statement 536# warn about C99 declaration after statement
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 64e450dddb49..167fd89f8707 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -1150,16 +1150,13 @@ osf_usleep_thread(struct timeval32 __user *sleep, struct timeval32 __user *remai
1150 if (get_tv32(&tmp, sleep)) 1150 if (get_tv32(&tmp, sleep))
1151 goto fault; 1151 goto fault;
1152 1152
1153 ticks = tmp.tv_usec; 1153 ticks = timeval_to_jiffies(&tmp);
1154 ticks = (ticks + (1000000 / HZ) - 1) / (1000000 / HZ);
1155 ticks += tmp.tv_sec * HZ;
1156 1154
1157 current->state = TASK_INTERRUPTIBLE; 1155 current->state = TASK_INTERRUPTIBLE;
1158 ticks = schedule_timeout(ticks); 1156 ticks = schedule_timeout(ticks);
1159 1157
1160 if (remain) { 1158 if (remain) {
1161 tmp.tv_sec = ticks / HZ; 1159 jiffies_to_timeval(ticks, &tmp);
1162 tmp.tv_usec = ticks % HZ;
1163 if (put_tv32(remain, &tmp)) 1160 if (put_tv32(remain, &tmp))
1164 goto fault; 1161 goto fault;
1165 } 1162 }
diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c
index e23f534d4e1d..8d986b8401c2 100644
--- a/arch/arm/mach-s3c2410/clock.c
+++ b/arch/arm/mach-s3c2410/clock.c
@@ -478,7 +478,7 @@ static int s3c2440_clk_add(struct sys_device *sysdev)
478{ 478{
479 unsigned long upllcon = __raw_readl(S3C2410_UPLLCON); 479 unsigned long upllcon = __raw_readl(S3C2410_UPLLCON);
480 480
481 s3c2440_clk_upll.rate = s3c2410_get_pll(upllcon, clk_xtal.rate) * 2; 481 s3c2440_clk_upll.rate = s3c2410_get_pll(upllcon, clk_xtal.rate);
482 482
483 printk("S3C2440: Clock Support, UPLL %ld.%03ld MHz\n", 483 printk("S3C2440: Clock Support, UPLL %ld.%03ld MHz\n",
484 print_mhz(s3c2440_clk_upll.rate)); 484 print_mhz(s3c2440_clk_upll.rate));
diff --git a/arch/arm/mach-s3c2410/s3c2440.c b/arch/arm/mach-s3c2410/s3c2440.c
index 9a8cc5ae2255..d4c8281b55f6 100644
--- a/arch/arm/mach-s3c2410/s3c2440.c
+++ b/arch/arm/mach-s3c2410/s3c2440.c
@@ -192,9 +192,11 @@ void __init s3c2440_map_io(struct map_desc *mach_desc, int size)
192 192
193 iotable_init(s3c2440_iodesc, ARRAY_SIZE(s3c2440_iodesc)); 193 iotable_init(s3c2440_iodesc, ARRAY_SIZE(s3c2440_iodesc));
194 iotable_init(mach_desc, size); 194 iotable_init(mach_desc, size);
195
195 /* rename any peripherals used differing from the s3c2410 */ 196 /* rename any peripherals used differing from the s3c2410 */
196 197
197 s3c_device_i2c.name = "s3c2440-i2c"; 198 s3c_device_i2c.name = "s3c2440-i2c";
199 s3c_device_nand.name = "s3c2440-nand";
198 200
199 /* change irq for watchdog */ 201 /* change irq for watchdog */
200 202
@@ -225,7 +227,7 @@ void __init s3c2440_init_clocks(int xtal)
225 break; 227 break;
226 228
227 case S3C2440_CLKDIVN_HDIVN_2: 229 case S3C2440_CLKDIVN_HDIVN_2:
228 hdiv = 1; 230 hdiv = 2;
229 break; 231 break;
230 232
231 case S3C2440_CLKDIVN_HDIVN_4_8: 233 case S3C2440_CLKDIVN_HDIVN_4_8:
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index c4fc6be629de..48bac7da8c70 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -412,21 +412,20 @@ config CPU_BPREDICT_DISABLE
412 412
413config TLS_REG_EMUL 413config TLS_REG_EMUL
414 bool 414 bool
415 default y if (SMP || CPU_32v6) && (CPU_32v5 || CPU_32v4 || CPU_32v3) 415 default y if SMP && (CPU_32v5 || CPU_32v4 || CPU_32v3)
416 help 416 help
417 We might be running on an ARMv6+ processor which should have the TLS 417 An SMP system using a pre-ARMv6 processor (there are apparently
418 register but for some reason we can't use it, or maybe an SMP system 418 a few prototypes like that in existence) and therefore access to
419 using a pre-ARMv6 processor (there are apparently a few prototypes 419 that required register must be emulated.
420 like that in existence) and therefore access to that register must
421 be emulated.
422 420
423config HAS_TLS_REG 421config HAS_TLS_REG
424 bool 422 bool
425 depends on CPU_32v6 423 depends on !TLS_REG_EMUL
426 default y if !TLS_REG_EMUL 424 default y if SMP || CPU_32v7
427 help 425 help
428 This selects support for the CP15 thread register. 426 This selects support for the CP15 thread register.
429 It is defined to be available on ARMv6 or later. If a particular 427 It is defined to be available on some ARMv6 processors (including
430 ARMv6 or later CPU doesn't support it then it must omc;ide "select 428 all SMP capable ARMv6's) or later processors. User space may
431 TLS_REG_EMUL" along with its other caracteristics. 429 assume directly accessing that register and always obtain the
430 expected value only on ARMv7 and above.
432 431
diff --git a/arch/arm/mm/copypage-v4mc.S b/arch/arm/mm/copypage-v4mc.S
deleted file mode 100644
index 305af3dab3d8..000000000000
--- a/arch/arm/mm/copypage-v4mc.S
+++ /dev/null
@@ -1,80 +0,0 @@
1/*
2 * linux/arch/arm/lib/copy_page-armv4mc.S
3 *
4 * Copyright (C) 1995-2001 Russell King
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 * ASM optimised string functions
11 */
12#include <linux/linkage.h>
13#include <linux/init.h>
14#include <asm/constants.h>
15
16 .text
17 .align 5
18/*
19 * ARMv4 mini-dcache optimised copy_user_page
20 *
21 * We flush the destination cache lines just before we write the data into the
22 * corresponding address. Since the Dcache is read-allocate, this removes the
23 * Dcache aliasing issue. The writes will be forwarded to the write buffer,
24 * and merged as appropriate.
25 *
26 * Note: We rely on all ARMv4 processors implementing the "invalidate D line"
27 * instruction. If your processor does not supply this, you have to write your
28 * own copy_user_page that does the right thing.
29 */
30ENTRY(v4_mc_copy_user_page)
31 stmfd sp!, {r4, lr} @ 2
32 mov r4, r0
33 mov r0, r1
34 bl map_page_minicache
35 mov r1, #PAGE_SZ/64 @ 1
36 ldmia r0!, {r2, r3, ip, lr} @ 4
371: mcr p15, 0, r4, c7, c6, 1 @ 1 invalidate D line
38 stmia r4!, {r2, r3, ip, lr} @ 4
39 ldmia r0!, {r2, r3, ip, lr} @ 4+1
40 stmia r4!, {r2, r3, ip, lr} @ 4
41 ldmia r0!, {r2, r3, ip, lr} @ 4
42 mcr p15, 0, r4, c7, c6, 1 @ 1 invalidate D line
43 stmia r4!, {r2, r3, ip, lr} @ 4
44 ldmia r0!, {r2, r3, ip, lr} @ 4
45 subs r1, r1, #1 @ 1
46 stmia r4!, {r2, r3, ip, lr} @ 4
47 ldmneia r0!, {r2, r3, ip, lr} @ 4
48 bne 1b @ 1
49 ldmfd sp!, {r4, pc} @ 3
50
51 .align 5
52/*
53 * ARMv4 optimised clear_user_page
54 *
55 * Same story as above.
56 */
57ENTRY(v4_mc_clear_user_page)
58 str lr, [sp, #-4]!
59 mov r1, #PAGE_SZ/64 @ 1
60 mov r2, #0 @ 1
61 mov r3, #0 @ 1
62 mov ip, #0 @ 1
63 mov lr, #0 @ 1
641: mcr p15, 0, r0, c7, c6, 1 @ 1 invalidate D line
65 stmia r0!, {r2, r3, ip, lr} @ 4
66 stmia r0!, {r2, r3, ip, lr} @ 4
67 mcr p15, 0, r0, c7, c6, 1 @ 1 invalidate D line
68 stmia r0!, {r2, r3, ip, lr} @ 4
69 stmia r0!, {r2, r3, ip, lr} @ 4
70 subs r1, r1, #1 @ 1
71 bne 1b @ 1
72 ldr pc, [sp], #4
73
74 __INITDATA
75
76 .type v4_mc_user_fns, #object
77ENTRY(v4_mc_user_fns)
78 .long v4_mc_clear_user_page
79 .long v4_mc_copy_user_page
80 .size v4_mc_user_fns, . - v4_mc_user_fns
diff --git a/arch/arm/mm/copypage-v4mc.c b/arch/arm/mm/copypage-v4mc.c
new file mode 100644
index 000000000000..fc69dccdace1
--- /dev/null
+++ b/arch/arm/mm/copypage-v4mc.c
@@ -0,0 +1,111 @@
1/*
2 * linux/arch/arm/lib/copypage-armv4mc.S
3 *
4 * Copyright (C) 1995-2005 Russell King
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 * This handles the mini data cache, as found on SA11x0 and XScale
11 * processors. When we copy a user page page, we map it in such a way
12 * that accesses to this page will not touch the main data cache, but
13 * will be cached in the mini data cache. This prevents us thrashing
14 * the main data cache on page faults.
15 */
16#include <linux/init.h>
17#include <linux/mm.h>
18
19#include <asm/page.h>
20#include <asm/pgtable.h>
21#include <asm/tlbflush.h>
22
23/*
24 * 0xffff8000 to 0xffffffff is reserved for any ARM architecture
25 * specific hacks for copying pages efficiently.
26 */
27#define minicache_pgprot __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | \
28 L_PTE_CACHEABLE)
29
30#define TOP_PTE(x) pte_offset_kernel(top_pmd, x)
31
32static DEFINE_SPINLOCK(minicache_lock);
33
34/*
35 * ARMv4 mini-dcache optimised copy_user_page
36 *
37 * We flush the destination cache lines just before we write the data into the
38 * corresponding address. Since the Dcache is read-allocate, this removes the
39 * Dcache aliasing issue. The writes will be forwarded to the write buffer,
40 * and merged as appropriate.
41 *
42 * Note: We rely on all ARMv4 processors implementing the "invalidate D line"
43 * instruction. If your processor does not supply this, you have to write your
44 * own copy_user_page that does the right thing.
45 */
46static void __attribute__((naked))
47mc_copy_user_page(void *from, void *to)
48{
49 asm volatile(
50 "stmfd sp!, {r4, lr} @ 2\n\
51 mov r4, %2 @ 1\n\
52 ldmia %0!, {r2, r3, ip, lr} @ 4\n\
531: mcr p15, 0, %1, c7, c6, 1 @ 1 invalidate D line\n\
54 stmia %1!, {r2, r3, ip, lr} @ 4\n\
55 ldmia %0!, {r2, r3, ip, lr} @ 4+1\n\
56 stmia %1!, {r2, r3, ip, lr} @ 4\n\
57 ldmia %0!, {r2, r3, ip, lr} @ 4\n\
58 mcr p15, 0, %1, c7, c6, 1 @ 1 invalidate D line\n\
59 stmia %1!, {r2, r3, ip, lr} @ 4\n\
60 ldmia %0!, {r2, r3, ip, lr} @ 4\n\
61 subs r4, r4, #1 @ 1\n\
62 stmia %1!, {r2, r3, ip, lr} @ 4\n\
63 ldmneia %0!, {r2, r3, ip, lr} @ 4\n\
64 bne 1b @ 1\n\
65 ldmfd sp!, {r4, pc} @ 3"
66 :
67 : "r" (from), "r" (to), "I" (PAGE_SIZE / 64));
68}
69
70void v4_mc_copy_user_page(void *kto, const void *kfrom, unsigned long vaddr)
71{
72 spin_lock(&minicache_lock);
73
74 set_pte(TOP_PTE(0xffff8000), pfn_pte(__pa(kfrom) >> PAGE_SHIFT, minicache_pgprot));
75 flush_tlb_kernel_page(0xffff8000);
76
77 mc_copy_user_page((void *)0xffff8000, kto);
78
79 spin_unlock(&minicache_lock);
80}
81
82/*
83 * ARMv4 optimised clear_user_page
84 */
85void __attribute__((naked))
86v4_mc_clear_user_page(void *kaddr, unsigned long vaddr)
87{
88 asm volatile(
89 "str lr, [sp, #-4]!\n\
90 mov r1, %0 @ 1\n\
91 mov r2, #0 @ 1\n\
92 mov r3, #0 @ 1\n\
93 mov ip, #0 @ 1\n\
94 mov lr, #0 @ 1\n\
951: mcr p15, 0, r0, c7, c6, 1 @ 1 invalidate D line\n\
96 stmia r0!, {r2, r3, ip, lr} @ 4\n\
97 stmia r0!, {r2, r3, ip, lr} @ 4\n\
98 mcr p15, 0, r0, c7, c6, 1 @ 1 invalidate D line\n\
99 stmia r0!, {r2, r3, ip, lr} @ 4\n\
100 stmia r0!, {r2, r3, ip, lr} @ 4\n\
101 subs r1, r1, #1 @ 1\n\
102 bne 1b @ 1\n\
103 ldr pc, [sp], #4"
104 :
105 : "I" (PAGE_SIZE / 64));
106}
107
108struct cpu_user_fns v4_mc_user_fns __initdata = {
109 .cpu_clear_user_page = v4_mc_clear_user_page,
110 .cpu_copy_user_page = v4_mc_copy_user_page,
111};
diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c
index 694ac8208858..a8c00236bd3d 100644
--- a/arch/arm/mm/copypage-v6.c
+++ b/arch/arm/mm/copypage-v6.c
@@ -26,8 +26,8 @@
26#define to_address (0xffffc000) 26#define to_address (0xffffc000)
27#define to_pgprot PAGE_KERNEL 27#define to_pgprot PAGE_KERNEL
28 28
29static pte_t *from_pte; 29#define TOP_PTE(x) pte_offset_kernel(top_pmd, x)
30static pte_t *to_pte; 30
31static DEFINE_SPINLOCK(v6_lock); 31static DEFINE_SPINLOCK(v6_lock);
32 32
33#define DCACHE_COLOUR(vaddr) ((vaddr & (SHMLBA - 1)) >> PAGE_SHIFT) 33#define DCACHE_COLOUR(vaddr) ((vaddr & (SHMLBA - 1)) >> PAGE_SHIFT)
@@ -74,8 +74,8 @@ void v6_copy_user_page_aliasing(void *kto, const void *kfrom, unsigned long vadd
74 */ 74 */
75 spin_lock(&v6_lock); 75 spin_lock(&v6_lock);
76 76
77 set_pte(from_pte + offset, pfn_pte(__pa(kfrom) >> PAGE_SHIFT, from_pgprot)); 77 set_pte(TOP_PTE(from_address) + offset, pfn_pte(__pa(kfrom) >> PAGE_SHIFT, from_pgprot));
78 set_pte(to_pte + offset, pfn_pte(__pa(kto) >> PAGE_SHIFT, to_pgprot)); 78 set_pte(TOP_PTE(to_address) + offset, pfn_pte(__pa(kto) >> PAGE_SHIFT, to_pgprot));
79 79
80 from = from_address + (offset << PAGE_SHIFT); 80 from = from_address + (offset << PAGE_SHIFT);
81 to = to_address + (offset << PAGE_SHIFT); 81 to = to_address + (offset << PAGE_SHIFT);
@@ -114,7 +114,7 @@ void v6_clear_user_page_aliasing(void *kaddr, unsigned long vaddr)
114 */ 114 */
115 spin_lock(&v6_lock); 115 spin_lock(&v6_lock);
116 116
117 set_pte(to_pte + offset, pfn_pte(__pa(kaddr) >> PAGE_SHIFT, to_pgprot)); 117 set_pte(TOP_PTE(to_address) + offset, pfn_pte(__pa(kaddr) >> PAGE_SHIFT, to_pgprot));
118 flush_tlb_kernel_page(to); 118 flush_tlb_kernel_page(to);
119 clear_page((void *)to); 119 clear_page((void *)to);
120 120
@@ -129,21 +129,6 @@ struct cpu_user_fns v6_user_fns __initdata = {
129static int __init v6_userpage_init(void) 129static int __init v6_userpage_init(void)
130{ 130{
131 if (cache_is_vipt_aliasing()) { 131 if (cache_is_vipt_aliasing()) {
132 pgd_t *pgd;
133 pmd_t *pmd;
134
135 pgd = pgd_offset_k(from_address);
136 pmd = pmd_alloc(&init_mm, pgd, from_address);
137 if (!pmd)
138 BUG();
139 from_pte = pte_alloc_kernel(&init_mm, pmd, from_address);
140 if (!from_pte)
141 BUG();
142
143 to_pte = pte_alloc_kernel(&init_mm, pmd, to_address);
144 if (!to_pte)
145 BUG();
146
147 cpu_user.cpu_clear_user_page = v6_clear_user_page_aliasing; 132 cpu_user.cpu_clear_user_page = v6_clear_user_page_aliasing;
148 cpu_user.cpu_copy_user_page = v6_copy_user_page_aliasing; 133 cpu_user.cpu_copy_user_page = v6_copy_user_page_aliasing;
149 } 134 }
@@ -151,5 +136,4 @@ static int __init v6_userpage_init(void)
151 return 0; 136 return 0;
152} 137}
153 138
154__initcall(v6_userpage_init); 139core_initcall(v6_userpage_init);
155
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index c6de48d89503..4085ed983e46 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -13,6 +13,29 @@
13 13
14#include <asm/cacheflush.h> 14#include <asm/cacheflush.h>
15#include <asm/system.h> 15#include <asm/system.h>
16#include <asm/tlbflush.h>
17
18#ifdef CONFIG_CPU_CACHE_VIPT
19#define ALIAS_FLUSH_START 0xffff4000
20
21#define TOP_PTE(x) pte_offset_kernel(top_pmd, x)
22
23static void flush_pfn_alias(unsigned long pfn, unsigned long vaddr)
24{
25 unsigned long to = ALIAS_FLUSH_START + (CACHE_COLOUR(vaddr) << PAGE_SHIFT);
26
27 set_pte(TOP_PTE(to), pfn_pte(pfn, PAGE_KERNEL));
28 flush_tlb_kernel_page(to);
29
30 asm( "mcrr p15, 0, %1, %0, c14\n"
31 " mcrr p15, 0, %1, %0, c5\n"
32 :
33 : "r" (to), "r" (to + PAGE_SIZE - L1_CACHE_BYTES)
34 : "cc");
35}
36#else
37#define flush_pfn_alias(pfn,vaddr) do { } while (0)
38#endif
16 39
17static void __flush_dcache_page(struct address_space *mapping, struct page *page) 40static void __flush_dcache_page(struct address_space *mapping, struct page *page)
18{ 41{
@@ -37,6 +60,18 @@ static void __flush_dcache_page(struct address_space *mapping, struct page *page
37 return; 60 return;
38 61
39 /* 62 /*
63 * This is a page cache page. If we have a VIPT cache, we
64 * only need to do one flush - which would be at the relevant
65 * userspace colour, which is congruent with page->index.
66 */
67 if (cache_is_vipt()) {
68 if (cache_is_vipt_aliasing())
69 flush_pfn_alias(page_to_pfn(page),
70 page->index << PAGE_CACHE_SHIFT);
71 return;
72 }
73
74 /*
40 * There are possible user space mappings of this page: 75 * There are possible user space mappings of this page:
41 * - VIVT cache: we need to also write back and invalidate all user 76 * - VIVT cache: we need to also write back and invalidate all user
42 * data in the current VM view associated with this page. 77 * data in the current VM view associated with this page.
@@ -57,8 +92,6 @@ static void __flush_dcache_page(struct address_space *mapping, struct page *page
57 continue; 92 continue;
58 offset = (pgoff - mpnt->vm_pgoff) << PAGE_SHIFT; 93 offset = (pgoff - mpnt->vm_pgoff) << PAGE_SHIFT;
59 flush_cache_page(mpnt, mpnt->vm_start + offset, page_to_pfn(page)); 94 flush_cache_page(mpnt, mpnt->vm_start + offset, page_to_pfn(page));
60 if (cache_is_vipt())
61 break;
62 } 95 }
63 flush_dcache_mmap_unlock(mapping); 96 flush_dcache_mmap_unlock(mapping);
64} 97}
diff --git a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c
index 585dfb8e20b9..2c2b93d77d43 100644
--- a/arch/arm/mm/mm-armv.c
+++ b/arch/arm/mm/mm-armv.c
@@ -37,6 +37,8 @@ pgprot_t pgprot_kernel;
37 37
38EXPORT_SYMBOL(pgprot_kernel); 38EXPORT_SYMBOL(pgprot_kernel);
39 39
40pmd_t *top_pmd;
41
40struct cachepolicy { 42struct cachepolicy {
41 const char policy[16]; 43 const char policy[16];
42 unsigned int cr_mask; 44 unsigned int cr_mask;
@@ -142,6 +144,16 @@ __setup("noalign", noalign_setup);
142 144
143#define FIRST_KERNEL_PGD_NR (FIRST_USER_PGD_NR + USER_PTRS_PER_PGD) 145#define FIRST_KERNEL_PGD_NR (FIRST_USER_PGD_NR + USER_PTRS_PER_PGD)
144 146
147static inline pmd_t *pmd_off(pgd_t *pgd, unsigned long virt)
148{
149 return pmd_offset(pgd, virt);
150}
151
152static inline pmd_t *pmd_off_k(unsigned long virt)
153{
154 return pmd_off(pgd_offset_k(virt), virt);
155}
156
145/* 157/*
146 * need to get a 16k page for level 1 158 * need to get a 16k page for level 1
147 */ 159 */
@@ -220,7 +232,7 @@ void free_pgd_slow(pgd_t *pgd)
220 return; 232 return;
221 233
222 /* pgd is always present and good */ 234 /* pgd is always present and good */
223 pmd = (pmd_t *)pgd; 235 pmd = pmd_off(pgd, 0);
224 if (pmd_none(*pmd)) 236 if (pmd_none(*pmd))
225 goto free; 237 goto free;
226 if (pmd_bad(*pmd)) { 238 if (pmd_bad(*pmd)) {
@@ -246,9 +258,8 @@ free:
246static inline void 258static inline void
247alloc_init_section(unsigned long virt, unsigned long phys, int prot) 259alloc_init_section(unsigned long virt, unsigned long phys, int prot)
248{ 260{
249 pmd_t *pmdp; 261 pmd_t *pmdp = pmd_off_k(virt);
250 262
251 pmdp = pmd_offset(pgd_offset_k(virt), virt);
252 if (virt & (1 << 20)) 263 if (virt & (1 << 20))
253 pmdp++; 264 pmdp++;
254 265
@@ -283,11 +294,9 @@ alloc_init_supersection(unsigned long virt, unsigned long phys, int prot)
283static inline void 294static inline void
284alloc_init_page(unsigned long virt, unsigned long phys, unsigned int prot_l1, pgprot_t prot) 295alloc_init_page(unsigned long virt, unsigned long phys, unsigned int prot_l1, pgprot_t prot)
285{ 296{
286 pmd_t *pmdp; 297 pmd_t *pmdp = pmd_off_k(virt);
287 pte_t *ptep; 298 pte_t *ptep;
288 299
289 pmdp = pmd_offset(pgd_offset_k(virt), virt);
290
291 if (pmd_none(*pmdp)) { 300 if (pmd_none(*pmdp)) {
292 unsigned long pmdval; 301 unsigned long pmdval;
293 ptep = alloc_bootmem_low_pages(2 * PTRS_PER_PTE * 302 ptep = alloc_bootmem_low_pages(2 * PTRS_PER_PTE *
@@ -310,7 +319,7 @@ alloc_init_page(unsigned long virt, unsigned long phys, unsigned int prot_l1, pg
310 */ 319 */
311static inline void clear_mapping(unsigned long virt) 320static inline void clear_mapping(unsigned long virt)
312{ 321{
313 pmd_clear(pmd_offset(pgd_offset_k(virt), virt)); 322 pmd_clear(pmd_off_k(virt));
314} 323}
315 324
316struct mem_types { 325struct mem_types {
@@ -578,7 +587,7 @@ void setup_mm_for_reboot(char mode)
578 PMD_TYPE_SECT; 587 PMD_TYPE_SECT;
579 if (cpu_arch <= CPU_ARCH_ARMv5) 588 if (cpu_arch <= CPU_ARCH_ARMv5)
580 pmdval |= PMD_BIT4; 589 pmdval |= PMD_BIT4;
581 pmd = pmd_offset(pgd + i, i << PGDIR_SHIFT); 590 pmd = pmd_off(pgd, i << PGDIR_SHIFT);
582 pmd[0] = __pmd(pmdval); 591 pmd[0] = __pmd(pmdval);
583 pmd[1] = __pmd(pmdval + (1 << (PGDIR_SHIFT - 1))); 592 pmd[1] = __pmd(pmdval + (1 << (PGDIR_SHIFT - 1)));
584 flush_pmd_entry(pmd); 593 flush_pmd_entry(pmd);
@@ -675,6 +684,8 @@ void __init memtable_init(struct meminfo *mi)
675 684
676 flush_cache_all(); 685 flush_cache_all();
677 flush_tlb_all(); 686 flush_tlb_all();
687
688 top_pmd = pmd_off_k(0xffff0000);
678} 689}
679 690
680/* 691/*
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index e382f32d435e..dfd904f6883b 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -1163,7 +1163,7 @@ config PCI_DIRECT
1163 1163
1164config PCI_MMCONFIG 1164config PCI_MMCONFIG
1165 bool 1165 bool
1166 depends on PCI && (PCI_GOMMCONFIG || (PCI_GOANY && ACPI)) 1166 depends on PCI && ACPI && (PCI_GOMMCONFIG || PCI_GOANY)
1167 select ACPI_BOOT 1167 select ACPI_BOOT
1168 default y 1168 default y
1169 1169
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index 16dbc4151be4..73aeaf5a9d4e 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -24,9 +24,6 @@ __asm__(".align 4\nvide: ret");
24 24
25static void __init init_amd(struct cpuinfo_x86 *c) 25static void __init init_amd(struct cpuinfo_x86 *c)
26{ 26{
27#ifdef CONFIG_X86_SMP
28 int cpu = c == &boot_cpu_data ? 0 : c - cpu_data;
29#endif
30 u32 l, h; 27 u32 l, h;
31 int mbytes = num_physpages >> (20-PAGE_SHIFT); 28 int mbytes = num_physpages >> (20-PAGE_SHIFT);
32 int r; 29 int r;
@@ -198,14 +195,19 @@ static void __init init_amd(struct cpuinfo_x86 *c)
198 c->x86_num_cores = 1; 195 c->x86_num_cores = 1;
199 } 196 }
200 197
201#ifdef CONFIG_X86_SMP 198#ifdef CONFIG_X86_HT
202 /* 199 /*
203 * On a AMD dual core setup the lower bits of the APIC id 200 * On a AMD dual core setup the lower bits of the APIC id
204 * distingush the cores. Assumes number of cores is a power 201 * distingush the cores. Assumes number of cores is a power
205 * of two. 202 * of two.
206 */ 203 */
207 if (c->x86_num_cores > 1) { 204 if (c->x86_num_cores > 1) {
208 cpu_core_id[cpu] = cpu >> hweight32(c->x86_num_cores - 1); 205 int cpu = smp_processor_id();
206 unsigned bits = 0;
207 while ((1 << bits) < c->x86_num_cores)
208 bits++;
209 cpu_core_id[cpu] = phys_proc_id[cpu] & ((1<<bits)-1);
210 phys_proc_id[cpu] >>= bits;
209 printk(KERN_INFO "CPU %d(%d) -> Core %d\n", 211 printk(KERN_INFO "CPU %d(%d) -> Core %d\n",
210 cpu, c->x86_num_cores, cpu_core_id[cpu]); 212 cpu, c->x86_num_cores, cpu_core_id[cpu]);
211 } 213 }
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index 6be0310e3cd3..d199e525680a 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -243,6 +243,10 @@ static void __init early_cpu_detect(void)
243 } 243 }
244 244
245 early_intel_workaround(c); 245 early_intel_workaround(c);
246
247#ifdef CONFIG_X86_HT
248 phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
249#endif
246} 250}
247 251
248void __init generic_identify(struct cpuinfo_x86 * c) 252void __init generic_identify(struct cpuinfo_x86 * c)
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index cbea7ac582e5..35bfe138cb1a 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -888,6 +888,7 @@ void *xquad_portio;
888 888
889cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned; 889cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned;
890cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned; 890cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned;
891EXPORT_SYMBOL(cpu_core_map);
891 892
892static void __init smp_boot_cpus(unsigned int max_cpus) 893static void __init smp_boot_cpus(unsigned int max_cpus)
893{ 894{
diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
index 903d739ca74a..a6e0ddd65bd0 100644
--- a/arch/i386/mach-voyager/voyager_smp.c
+++ b/arch/i386/mach-voyager/voyager_smp.c
@@ -97,7 +97,6 @@ static void ack_vic_irq(unsigned int irq);
97static void vic_enable_cpi(void); 97static void vic_enable_cpi(void);
98static void do_boot_cpu(__u8 cpuid); 98static void do_boot_cpu(__u8 cpuid);
99static void do_quad_bootstrap(void); 99static void do_quad_bootstrap(void);
100static inline void wrapper_smp_local_timer_interrupt(struct pt_regs *);
101 100
102int hard_smp_processor_id(void); 101int hard_smp_processor_id(void);
103 102
@@ -126,6 +125,14 @@ send_QIC_CPI(__u32 cpuset, __u8 cpi)
126} 125}
127 126
128static inline void 127static inline void
128wrapper_smp_local_timer_interrupt(struct pt_regs *regs)
129{
130 irq_enter();
131 smp_local_timer_interrupt(regs);
132 irq_exit();
133}
134
135static inline void
129send_one_CPI(__u8 cpu, __u8 cpi) 136send_one_CPI(__u8 cpu, __u8 cpi)
130{ 137{
131 if(voyager_quad_processors & (1<<cpu)) 138 if(voyager_quad_processors & (1<<cpu))
@@ -1249,14 +1256,6 @@ smp_vic_timer_interrupt(struct pt_regs *regs)
1249 smp_local_timer_interrupt(regs); 1256 smp_local_timer_interrupt(regs);
1250} 1257}
1251 1258
1252static inline void
1253wrapper_smp_local_timer_interrupt(struct pt_regs *regs)
1254{
1255 irq_enter();
1256 smp_local_timer_interrupt(regs);
1257 irq_exit();
1258}
1259
1260/* local (per CPU) timer interrupt. It does both profiling and 1259/* local (per CPU) timer interrupt. It does both profiling and
1261 * process statistics/rescheduling. 1260 * process statistics/rescheduling.
1262 * 1261 *
diff --git a/arch/i386/mm/ioremap.c b/arch/i386/mm/ioremap.c
index db06f7399913..ab542792b27b 100644
--- a/arch/i386/mm/ioremap.c
+++ b/arch/i386/mm/ioremap.c
@@ -238,19 +238,21 @@ void iounmap(volatile void __iomem *addr)
238 addr < phys_to_virt(ISA_END_ADDRESS)) 238 addr < phys_to_virt(ISA_END_ADDRESS))
239 return; 239 return;
240 240
241 p = remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr)); 241 write_lock(&vmlist_lock);
242 p = __remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr));
242 if (!p) { 243 if (!p) {
243 printk("__iounmap: bad address %p\n", addr); 244 printk("iounmap: bad address %p\n", addr);
244 return; 245 goto out_unlock;
245 } 246 }
246 247
247 if ((p->flags >> 20) && p->phys_addr < virt_to_phys(high_memory) - 1) { 248 if ((p->flags >> 20) && p->phys_addr < virt_to_phys(high_memory) - 1) {
248 /* p->size includes the guard page, but cpa doesn't like that */
249 change_page_attr(virt_to_page(__va(p->phys_addr)), 249 change_page_attr(virt_to_page(__va(p->phys_addr)),
250 p->size >> PAGE_SHIFT, 250 p->size >> PAGE_SHIFT,
251 PAGE_KERNEL); 251 PAGE_KERNEL);
252 global_flush_tlb(); 252 global_flush_tlb();
253 } 253 }
254out_unlock:
255 write_unlock(&vmlist_lock);
254 kfree(p); 256 kfree(p);
255} 257}
256 258
diff --git a/arch/i386/pci/fixup.c b/arch/i386/pci/fixup.c
index be52c5ac4e05..8e8e895e1b5a 100644
--- a/arch/i386/pci/fixup.c
+++ b/arch/i386/pci/fixup.c
@@ -253,7 +253,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2, pci
253#define MAX_PCIEROOT 6 253#define MAX_PCIEROOT 6
254static int quirk_aspm_offset[MAX_PCIEROOT << 3]; 254static int quirk_aspm_offset[MAX_PCIEROOT << 3];
255 255
256#define GET_INDEX(a, b) (((a - PCI_DEVICE_ID_INTEL_MCH_PA) << 3) + b) 256#define GET_INDEX(a, b) ((((a) - PCI_DEVICE_ID_INTEL_MCH_PA) << 3) + ((b) & 7))
257 257
258static int quirk_pcie_aspm_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) 258static int quirk_pcie_aspm_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
259{ 259{
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index d6598da4b67b..da21b1d07c15 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -1029,7 +1029,6 @@ void pcibios_penalize_isa_irq(int irq)
1029static int pirq_enable_irq(struct pci_dev *dev) 1029static int pirq_enable_irq(struct pci_dev *dev)
1030{ 1030{
1031 u8 pin; 1031 u8 pin;
1032 extern int via_interrupt_line_quirk;
1033 struct pci_dev *temp_dev; 1032 struct pci_dev *temp_dev;
1034 1033
1035 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 1034 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
@@ -1084,10 +1083,6 @@ static int pirq_enable_irq(struct pci_dev *dev)
1084 printk(KERN_WARNING "PCI: No IRQ known for interrupt pin %c of device %s.%s\n", 1083 printk(KERN_WARNING "PCI: No IRQ known for interrupt pin %c of device %s.%s\n",
1085 'A' + pin, pci_name(dev), msg); 1084 'A' + pin, pci_name(dev), msg);
1086 } 1085 }
1087 /* VIA bridges use interrupt line for apic/pci steering across
1088 the V-Link */
1089 else if (via_interrupt_line_quirk)
1090 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq & 15);
1091 return 0; 1086 return 0;
1092} 1087}
1093 1088
diff --git a/arch/ia64/ia32/ia32_ioctl.c b/arch/ia64/ia32/ia32_ioctl.c
index 9845dabe2613..164b211f4174 100644
--- a/arch/ia64/ia32/ia32_ioctl.c
+++ b/arch/ia64/ia32/ia32_ioctl.c
@@ -13,7 +13,6 @@
13 13
14#define INCLUDES 14#define INCLUDES
15#include "compat_ioctl.c" 15#include "compat_ioctl.c"
16#include <asm/ioctl32.h>
17 16
18#define IOCTL_NR(a) ((a) & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT)) 17#define IOCTL_NR(a) ((a) & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT))
19 18
diff --git a/arch/mips/vr41xx/common/pmu.c b/arch/mips/vr41xx/common/pmu.c
index c5f1043de938..53166f3598b2 100644
--- a/arch/mips/vr41xx/common/pmu.c
+++ b/arch/mips/vr41xx/common/pmu.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * pmu.c, Power Management Unit routines for NEC VR4100 series. 2 * pmu.c, Power Management Unit routines for NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2003-2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2003-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
@@ -17,7 +17,9 @@
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#include <linux/errno.h>
20#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/ioport.h>
21#include <linux/kernel.h> 23#include <linux/kernel.h>
22#include <linux/smp.h> 24#include <linux/smp.h>
23#include <linux/types.h> 25#include <linux/types.h>
@@ -27,20 +29,31 @@
27#include <asm/reboot.h> 29#include <asm/reboot.h>
28#include <asm/system.h> 30#include <asm/system.h>
29 31
30#define PMUCNT2REG KSEG1ADDR(0x0f0000c6) 32#define PMU_TYPE1_BASE 0x0b0000a0UL
33#define PMU_TYPE1_SIZE 0x0eUL
34
35#define PMU_TYPE2_BASE 0x0f0000c0UL
36#define PMU_TYPE2_SIZE 0x10UL
37
38#define PMUCNT2REG 0x06
31 #define SOFTRST 0x0010 39 #define SOFTRST 0x0010
32 40
41static void __iomem *pmu_base;
42
43#define pmu_read(offset) readw(pmu_base + (offset))
44#define pmu_write(offset, value) writew((value), pmu_base + (offset))
45
33static inline void software_reset(void) 46static inline void software_reset(void)
34{ 47{
35 uint16_t val; 48 uint16_t pmucnt2;
36 49
37 switch (current_cpu_data.cputype) { 50 switch (current_cpu_data.cputype) {
38 case CPU_VR4122: 51 case CPU_VR4122:
39 case CPU_VR4131: 52 case CPU_VR4131:
40 case CPU_VR4133: 53 case CPU_VR4133:
41 val = readw(PMUCNT2REG); 54 pmucnt2 = pmu_read(PMUCNT2REG);
42 val |= SOFTRST; 55 pmucnt2 |= SOFTRST;
43 writew(val, PMUCNT2REG); 56 pmu_write(PMUCNT2REG, pmucnt2);
44 break; 57 break;
45 default: 58 default:
46 break; 59 break;
@@ -71,6 +84,34 @@ static void vr41xx_power_off(void)
71 84
72static int __init vr41xx_pmu_init(void) 85static int __init vr41xx_pmu_init(void)
73{ 86{
87 unsigned long start, size;
88
89 switch (current_cpu_data.cputype) {
90 case CPU_VR4111:
91 case CPU_VR4121:
92 start = PMU_TYPE1_BASE;
93 size = PMU_TYPE1_SIZE;
94 break;
95 case CPU_VR4122:
96 case CPU_VR4131:
97 case CPU_VR4133:
98 start = PMU_TYPE2_BASE;
99 size = PMU_TYPE2_SIZE;
100 break;
101 default:
102 printk("Unexpected CPU of NEC VR4100 series\n");
103 return -ENODEV;
104 }
105
106 if (request_mem_region(start, size, "PMU") == NULL)
107 return -EBUSY;
108
109 pmu_base = ioremap(start, size);
110 if (pmu_base == NULL) {
111 release_mem_region(start, size);
112 return -EBUSY;
113 }
114
74 _machine_restart = vr41xx_restart; 115 _machine_restart = vr41xx_restart;
75 _machine_halt = vr41xx_halt; 116 _machine_halt = vr41xx_halt;
76 _machine_power_off = vr41xx_power_off; 117 _machine_power_off = vr41xx_power_off;
@@ -78,4 +119,4 @@ static int __init vr41xx_pmu_init(void)
78 return 0; 119 return 0;
79} 120}
80 121
81early_initcall(vr41xx_pmu_init); 122core_initcall(vr41xx_pmu_init);
diff --git a/arch/ppc/kernel/head_44x.S b/arch/ppc/kernel/head_44x.S
index 9b6a8e513657..6c7ae6052464 100644
--- a/arch/ppc/kernel/head_44x.S
+++ b/arch/ppc/kernel/head_44x.S
@@ -330,8 +330,9 @@ interrupt_base:
330 /* If we are faulting a kernel address, we have to use the 330 /* If we are faulting a kernel address, we have to use the
331 * kernel page tables. 331 * kernel page tables.
332 */ 332 */
333 andis. r11, r10, 0x8000 333 lis r11, TASK_SIZE@h
334 beq 3f 334 cmplw r10, r11
335 blt+ 3f
335 lis r11, swapper_pg_dir@h 336 lis r11, swapper_pg_dir@h
336 ori r11, r11, swapper_pg_dir@l 337 ori r11, r11, swapper_pg_dir@l
337 338
@@ -464,8 +465,9 @@ interrupt_base:
464 /* If we are faulting a kernel address, we have to use the 465 /* If we are faulting a kernel address, we have to use the
465 * kernel page tables. 466 * kernel page tables.
466 */ 467 */
467 andis. r11, r10, 0x8000 468 lis r11, TASK_SIZE@h
468 beq 3f 469 cmplw r10, r11
470 blt+ 3f
469 lis r11, swapper_pg_dir@h 471 lis r11, swapper_pg_dir@h
470 ori r11, r11, swapper_pg_dir@l 472 ori r11, r11, swapper_pg_dir@l
471 473
@@ -533,8 +535,9 @@ interrupt_base:
533 /* If we are faulting a kernel address, we have to use the 535 /* If we are faulting a kernel address, we have to use the
534 * kernel page tables. 536 * kernel page tables.
535 */ 537 */
536 andis. r11, r10, 0x8000 538 lis r11, TASK_SIZE@h
537 beq 3f 539 cmplw r10, r11
540 blt+ 3f
538 lis r11, swapper_pg_dir@h 541 lis r11, swapper_pg_dir@h
539 ori r11, r11, swapper_pg_dir@l 542 ori r11, r11, swapper_pg_dir@l
540 543
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index 5dfb42f1a152..5c20266e3b1f 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -499,7 +499,7 @@ static int __init set_preferred_console(void)
499{ 499{
500 struct device_node *prom_stdout; 500 struct device_node *prom_stdout;
501 char *name; 501 char *name;
502 int offset; 502 int offset = 0;
503 503
504 if (of_stdout_device == NULL) 504 if (of_stdout_device == NULL)
505 return -ENODEV; 505 return -ENODEV;
@@ -753,6 +753,8 @@ void __init setup_arch(char **cmdline_p)
753 strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE); 753 strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
754 *cmdline_p = cmd_line; 754 *cmdline_p = cmd_line;
755 755
756 parse_early_param();
757
756 /* set up the bootmem stuff with available memory */ 758 /* set up the bootmem stuff with available memory */
757 do_init_bootmem(); 759 do_init_bootmem();
758 if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab); 760 if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
diff --git a/arch/ppc/lib/string.S b/arch/ppc/lib/string.S
index 8d08a2eb225e..36c9b97fd92a 100644
--- a/arch/ppc/lib/string.S
+++ b/arch/ppc/lib/string.S
@@ -446,6 +446,7 @@ _GLOBAL(__copy_tofrom_user)
446#ifdef CONFIG_8xx 446#ifdef CONFIG_8xx
447 /* Don't use prefetch on 8xx */ 447 /* Don't use prefetch on 8xx */
448 mtctr r0 448 mtctr r0
449 li r0,0
44953: COPY_16_BYTES_WITHEX(0) 45053: COPY_16_BYTES_WITHEX(0)
450 bdnz 53b 451 bdnz 53b
451 452
@@ -564,7 +565,9 @@ _GLOBAL(__copy_tofrom_user)
564/* or write fault in cacheline loop */ 565/* or write fault in cacheline loop */
565105: li r9,1 566105: li r9,1
56692: li r3,LG_CACHELINE_BYTES 56792: li r3,LG_CACHELINE_BYTES
567 b 99f 568 mfctr r8
569 add r0,r0,r8
570 b 106f
568/* read fault in final word loop */ 571/* read fault in final word loop */
569108: li r9,0 572108: li r9,0
570 b 93f 573 b 93f
@@ -585,7 +588,7 @@ _GLOBAL(__copy_tofrom_user)
585 * r5 + (ctr << r3), and r9 is 0 for read or 1 for write. 588 * r5 + (ctr << r3), and r9 is 0 for read or 1 for write.
586 */ 589 */
58799: mfctr r0 59099: mfctr r0
588 slw r3,r0,r3 591106: slw r3,r0,r3
589 add. r3,r3,r5 592 add. r3,r3,r5
590 beq 120f /* shouldn't happen */ 593 beq 120f /* shouldn't happen */
591 cmpwi 0,r9,0 594 cmpwi 0,r9,0
diff --git a/arch/ppc/mm/init.c b/arch/ppc/mm/init.c
index be02a7fec2b7..363c157e3617 100644
--- a/arch/ppc/mm/init.c
+++ b/arch/ppc/mm/init.c
@@ -179,6 +179,7 @@ void free_initmem(void)
179 if (!have_of) 179 if (!have_of)
180 FREESEC(openfirmware); 180 FREESEC(openfirmware);
181 printk("\n"); 181 printk("\n");
182 ppc_md.progress = NULL;
182#undef FREESEC 183#undef FREESEC
183} 184}
184 185
diff --git a/arch/ppc/syslib/ipic.c b/arch/ppc/syslib/ipic.c
index acb2cde3171f..580ed658e872 100644
--- a/arch/ppc/syslib/ipic.c
+++ b/arch/ppc/syslib/ipic.c
@@ -479,7 +479,7 @@ void __init ipic_init(phys_addr_t phys_addr,
479 temp = 0; 479 temp = 0;
480 for (i = 0 ; i < senses_count ; i++) { 480 for (i = 0 ; i < senses_count ; i++) {
481 if ((senses[i] & IRQ_SENSE_MASK) == IRQ_SENSE_EDGE) { 481 if ((senses[i] & IRQ_SENSE_MASK) == IRQ_SENSE_EDGE) {
482 temp |= 1 << (16 - i); 482 temp |= 1 << (15 - i);
483 if (i != 0) 483 if (i != 0)
484 irq_desc[i + irq_offset + MPC83xx_IRQ_EXT1 - 1].status = 0; 484 irq_desc[i + irq_offset + MPC83xx_IRQ_EXT1 - 1].status = 0;
485 else 485 else
diff --git a/arch/ppc/syslib/mpc83xx_devices.c b/arch/ppc/syslib/mpc83xx_devices.c
index 5c1a919eaabf..75c8e9834ae7 100644
--- a/arch/ppc/syslib/mpc83xx_devices.c
+++ b/arch/ppc/syslib/mpc83xx_devices.c
@@ -61,6 +61,7 @@ static struct plat_serial8250_port serial_platform_data[] = {
61 .iotype = UPIO_MEM, 61 .iotype = UPIO_MEM,
62 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, 62 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
63 }, 63 },
64 { },
64}; 65};
65 66
66struct platform_device ppc_sys_platform_devices[] = { 67struct platform_device ppc_sys_platform_devices[] = {
diff --git a/arch/ppc/syslib/mpc85xx_devices.c b/arch/ppc/syslib/mpc85xx_devices.c
index a231795ee26f..1e658ef57e75 100644
--- a/arch/ppc/syslib/mpc85xx_devices.c
+++ b/arch/ppc/syslib/mpc85xx_devices.c
@@ -61,6 +61,7 @@ static struct plat_serial8250_port serial_platform_data[] = {
61 .iotype = UPIO_MEM, 61 .iotype = UPIO_MEM,
62 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ, 62 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ,
63 }, 63 },
64 { },
64}; 65};
65 66
66struct platform_device ppc_sys_platform_devices[] = { 67struct platform_device ppc_sys_platform_devices[] = {
diff --git a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c
index 7619e16fccae..9d4ed68b5804 100644
--- a/arch/ppc/syslib/open_pic.c
+++ b/arch/ppc/syslib/open_pic.c
@@ -557,12 +557,10 @@ static void __init openpic_initipi(u_int ipi, u_int pri, u_int vec)
557 */ 557 */
558void openpic_cause_IPI(u_int ipi, cpumask_t cpumask) 558void openpic_cause_IPI(u_int ipi, cpumask_t cpumask)
559{ 559{
560 cpumask_t phys;
561 DECL_THIS_CPU; 560 DECL_THIS_CPU;
562 561
563 CHECK_THIS_CPU; 562 CHECK_THIS_CPU;
564 check_arg_ipi(ipi); 563 check_arg_ipi(ipi);
565 phys = physmask(cpumask);
566 openpic_write(&OpenPIC->THIS_CPU.IPI_Dispatch(ipi), 564 openpic_write(&OpenPIC->THIS_CPU.IPI_Dispatch(ipi),
567 cpus_addr(physmask(cpumask))[0]); 565 cpus_addr(physmask(cpumask))[0]);
568} 566}
diff --git a/arch/ppc64/kernel/mf.c b/arch/ppc64/kernel/mf.c
index 1bd52ece497c..5aca7e8005a8 100644
--- a/arch/ppc64/kernel/mf.c
+++ b/arch/ppc64/kernel/mf.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * mf.c 2 * mf.c
3 * Copyright (C) 2001 Troy D. Armstrong IBM Corporation 3 * Copyright (C) 2001 Troy D. Armstrong IBM Corporation
4 * Copyright (C) 2004 Stephen Rothwell IBM Corporation 4 * Copyright (C) 2004-2005 Stephen Rothwell IBM Corporation
5 * 5 *
6 * This modules exists as an interface between a Linux secondary partition 6 * This modules exists as an interface between a Linux secondary partition
7 * running on an iSeries and the primary partition's Virtual Service 7 * running on an iSeries and the primary partition's Virtual Service
@@ -36,10 +36,12 @@
36 36
37#include <asm/time.h> 37#include <asm/time.h>
38#include <asm/uaccess.h> 38#include <asm/uaccess.h>
39#include <asm/paca.h>
39#include <asm/iSeries/vio.h> 40#include <asm/iSeries/vio.h>
40#include <asm/iSeries/mf.h> 41#include <asm/iSeries/mf.h>
41#include <asm/iSeries/HvLpConfig.h> 42#include <asm/iSeries/HvLpConfig.h>
42#include <asm/iSeries/ItSpCommArea.h> 43#include <asm/iSeries/ItSpCommArea.h>
44#include <asm/iSeries/ItLpQueue.h>
43 45
44/* 46/*
45 * This is the structure layout for the Machine Facilites LPAR event 47 * This is the structure layout for the Machine Facilites LPAR event
@@ -696,36 +698,23 @@ static void get_rtc_time_complete(void *token, struct ce_msg_data *ce_msg)
696 complete(&rtc->com); 698 complete(&rtc->com);
697} 699}
698 700
699int mf_get_rtc(struct rtc_time *tm) 701static int rtc_set_tm(int rc, u8 *ce_msg, struct rtc_time *tm)
700{ 702{
701 struct ce_msg_comp_data ce_complete;
702 struct rtc_time_data rtc_data;
703 int rc;
704
705 memset(&ce_complete, 0, sizeof(ce_complete));
706 memset(&rtc_data, 0, sizeof(rtc_data));
707 init_completion(&rtc_data.com);
708 ce_complete.handler = &get_rtc_time_complete;
709 ce_complete.token = &rtc_data;
710 rc = signal_ce_msg_simple(0x40, &ce_complete);
711 if (rc)
712 return rc;
713 wait_for_completion(&rtc_data.com);
714 tm->tm_wday = 0; 703 tm->tm_wday = 0;
715 tm->tm_yday = 0; 704 tm->tm_yday = 0;
716 tm->tm_isdst = 0; 705 tm->tm_isdst = 0;
717 if (rtc_data.rc) { 706 if (rc) {
718 tm->tm_sec = 0; 707 tm->tm_sec = 0;
719 tm->tm_min = 0; 708 tm->tm_min = 0;
720 tm->tm_hour = 0; 709 tm->tm_hour = 0;
721 tm->tm_mday = 15; 710 tm->tm_mday = 15;
722 tm->tm_mon = 5; 711 tm->tm_mon = 5;
723 tm->tm_year = 52; 712 tm->tm_year = 52;
724 return rtc_data.rc; 713 return rc;
725 } 714 }
726 715
727 if ((rtc_data.ce_msg.ce_msg[2] == 0xa9) || 716 if ((ce_msg[2] == 0xa9) ||
728 (rtc_data.ce_msg.ce_msg[2] == 0xaf)) { 717 (ce_msg[2] == 0xaf)) {
729 /* TOD clock is not set */ 718 /* TOD clock is not set */
730 tm->tm_sec = 1; 719 tm->tm_sec = 1;
731 tm->tm_min = 1; 720 tm->tm_min = 1;
@@ -736,7 +725,6 @@ int mf_get_rtc(struct rtc_time *tm)
736 mf_set_rtc(tm); 725 mf_set_rtc(tm);
737 } 726 }
738 { 727 {
739 u8 *ce_msg = rtc_data.ce_msg.ce_msg;
740 u8 year = ce_msg[5]; 728 u8 year = ce_msg[5];
741 u8 sec = ce_msg[6]; 729 u8 sec = ce_msg[6];
742 u8 min = ce_msg[7]; 730 u8 min = ce_msg[7];
@@ -765,6 +753,63 @@ int mf_get_rtc(struct rtc_time *tm)
765 return 0; 753 return 0;
766} 754}
767 755
756int mf_get_rtc(struct rtc_time *tm)
757{
758 struct ce_msg_comp_data ce_complete;
759 struct rtc_time_data rtc_data;
760 int rc;
761
762 memset(&ce_complete, 0, sizeof(ce_complete));
763 memset(&rtc_data, 0, sizeof(rtc_data));
764 init_completion(&rtc_data.com);
765 ce_complete.handler = &get_rtc_time_complete;
766 ce_complete.token = &rtc_data;
767 rc = signal_ce_msg_simple(0x40, &ce_complete);
768 if (rc)
769 return rc;
770 wait_for_completion(&rtc_data.com);
771 return rtc_set_tm(rtc_data.rc, rtc_data.ce_msg.ce_msg, tm);
772}
773
774struct boot_rtc_time_data {
775 int busy;
776 struct ce_msg_data ce_msg;
777 int rc;
778};
779
780static void get_boot_rtc_time_complete(void *token, struct ce_msg_data *ce_msg)
781{
782 struct boot_rtc_time_data *rtc = token;
783
784 memcpy(&rtc->ce_msg, ce_msg, sizeof(rtc->ce_msg));
785 rtc->rc = 0;
786 rtc->busy = 0;
787}
788
789int mf_get_boot_rtc(struct rtc_time *tm)
790{
791 struct ce_msg_comp_data ce_complete;
792 struct boot_rtc_time_data rtc_data;
793 int rc;
794
795 memset(&ce_complete, 0, sizeof(ce_complete));
796 memset(&rtc_data, 0, sizeof(rtc_data));
797 rtc_data.busy = 1;
798 ce_complete.handler = &get_boot_rtc_time_complete;
799 ce_complete.token = &rtc_data;
800 rc = signal_ce_msg_simple(0x40, &ce_complete);
801 if (rc)
802 return rc;
803 /* We need to poll here as we are not yet taking interrupts */
804 while (rtc_data.busy) {
805 extern unsigned long lpevent_count;
806 struct ItLpQueue *lpq = get_paca()->lpqueue_ptr;
807 if (lpq && ItLpQueue_isLpIntPending(lpq))
808 lpevent_count += ItLpQueue_process(lpq, NULL);
809 }
810 return rtc_set_tm(rtc_data.rc, rtc_data.ce_msg.ce_msg, tm);
811}
812
768int mf_set_rtc(struct rtc_time *tm) 813int mf_set_rtc(struct rtc_time *tm)
769{ 814{
770 char ce_time[12]; 815 char ce_time[12];
diff --git a/arch/ppc64/kernel/pmac_smp.c b/arch/ppc64/kernel/pmac_smp.c
index c27588ede2fe..a23de37227bf 100644
--- a/arch/ppc64/kernel/pmac_smp.c
+++ b/arch/ppc64/kernel/pmac_smp.c
@@ -68,6 +68,7 @@ extern struct smp_ops_t *smp_ops;
68 68
69static void (*pmac_tb_freeze)(int freeze); 69static void (*pmac_tb_freeze)(int freeze);
70static struct device_node *pmac_tb_clock_chip_host; 70static struct device_node *pmac_tb_clock_chip_host;
71static u8 pmac_tb_pulsar_addr;
71static DEFINE_SPINLOCK(timebase_lock); 72static DEFINE_SPINLOCK(timebase_lock);
72static unsigned long timebase; 73static unsigned long timebase;
73 74
@@ -106,12 +107,9 @@ static void smp_core99_pulsar_tb_freeze(int freeze)
106 u8 data; 107 u8 data;
107 int rc; 108 int rc;
108 109
109 /* Strangely, the device-tree says address is 0xd2, but darwin
110 * accesses 0xd0 ...
111 */
112 pmac_low_i2c_setmode(pmac_tb_clock_chip_host, pmac_low_i2c_mode_combined); 110 pmac_low_i2c_setmode(pmac_tb_clock_chip_host, pmac_low_i2c_mode_combined);
113 rc = pmac_low_i2c_xfer(pmac_tb_clock_chip_host, 111 rc = pmac_low_i2c_xfer(pmac_tb_clock_chip_host,
114 0xd4 | pmac_low_i2c_read, 112 pmac_tb_pulsar_addr | pmac_low_i2c_read,
115 0x2e, &data, 1); 113 0x2e, &data, 1);
116 if (rc != 0) 114 if (rc != 0)
117 goto bail; 115 goto bail;
@@ -120,7 +118,7 @@ static void smp_core99_pulsar_tb_freeze(int freeze)
120 118
121 pmac_low_i2c_setmode(pmac_tb_clock_chip_host, pmac_low_i2c_mode_stdsub); 119 pmac_low_i2c_setmode(pmac_tb_clock_chip_host, pmac_low_i2c_mode_stdsub);
122 rc = pmac_low_i2c_xfer(pmac_tb_clock_chip_host, 120 rc = pmac_low_i2c_xfer(pmac_tb_clock_chip_host,
123 0xd4 | pmac_low_i2c_write, 121 pmac_tb_pulsar_addr | pmac_low_i2c_write,
124 0x2e, &data, 1); 122 0x2e, &data, 1);
125 bail: 123 bail:
126 if (rc != 0) { 124 if (rc != 0) {
@@ -185,6 +183,12 @@ static int __init smp_core99_probe(void)
185 if (ncpus <= 1) 183 if (ncpus <= 1)
186 return 1; 184 return 1;
187 185
186 /* HW sync only on these platforms */
187 if (!machine_is_compatible("PowerMac7,2") &&
188 !machine_is_compatible("PowerMac7,3") &&
189 !machine_is_compatible("RackMac3,1"))
190 goto nohwsync;
191
188 /* Look for the clock chip */ 192 /* Look for the clock chip */
189 for (cc = NULL; (cc = of_find_node_by_name(cc, "i2c-hwclock")) != NULL;) { 193 for (cc = NULL; (cc = of_find_node_by_name(cc, "i2c-hwclock")) != NULL;) {
190 struct device_node *p = of_get_parent(cc); 194 struct device_node *p = of_get_parent(cc);
@@ -198,11 +202,18 @@ static int __init smp_core99_probe(void)
198 goto next; 202 goto next;
199 switch (*reg) { 203 switch (*reg) {
200 case 0xd2: 204 case 0xd2:
201 pmac_tb_freeze = smp_core99_cypress_tb_freeze; 205 if (device_is_compatible(cc, "pulsar-legacy-slewing")) {
202 printk(KERN_INFO "Timebase clock is Cypress chip\n"); 206 pmac_tb_freeze = smp_core99_pulsar_tb_freeze;
207 pmac_tb_pulsar_addr = 0xd2;
208 printk(KERN_INFO "Timebase clock is Pulsar chip\n");
209 } else if (device_is_compatible(cc, "cy28508")) {
210 pmac_tb_freeze = smp_core99_cypress_tb_freeze;
211 printk(KERN_INFO "Timebase clock is Cypress chip\n");
212 }
203 break; 213 break;
204 case 0xd4: 214 case 0xd4:
205 pmac_tb_freeze = smp_core99_pulsar_tb_freeze; 215 pmac_tb_freeze = smp_core99_pulsar_tb_freeze;
216 pmac_tb_pulsar_addr = 0xd4;
206 printk(KERN_INFO "Timebase clock is Pulsar chip\n"); 217 printk(KERN_INFO "Timebase clock is Pulsar chip\n");
207 break; 218 break;
208 } 219 }
@@ -210,12 +221,15 @@ static int __init smp_core99_probe(void)
210 pmac_tb_clock_chip_host = p; 221 pmac_tb_clock_chip_host = p;
211 smp_ops->give_timebase = smp_core99_give_timebase; 222 smp_ops->give_timebase = smp_core99_give_timebase;
212 smp_ops->take_timebase = smp_core99_take_timebase; 223 smp_ops->take_timebase = smp_core99_take_timebase;
224 of_node_put(cc);
225 of_node_put(p);
213 break; 226 break;
214 } 227 }
215 next: 228 next:
216 of_node_put(p); 229 of_node_put(p);
217 } 230 }
218 231
232 nohwsync:
219 mpic_request_ipis(); 233 mpic_request_ipis();
220 234
221 return ncpus; 235 return ncpus;
diff --git a/arch/ppc64/kernel/prom_init.c b/arch/ppc64/kernel/prom_init.c
index 35ec42de962e..6f79b7b9b445 100644
--- a/arch/ppc64/kernel/prom_init.c
+++ b/arch/ppc64/kernel/prom_init.c
@@ -1750,7 +1750,44 @@ static void __init flatten_device_tree(void)
1750 prom_printf("Device tree struct 0x%x -> 0x%x\n", 1750 prom_printf("Device tree struct 0x%x -> 0x%x\n",
1751 RELOC(dt_struct_start), RELOC(dt_struct_end)); 1751 RELOC(dt_struct_start), RELOC(dt_struct_end));
1752 1752
1753 } 1753}
1754
1755
1756static void __init fixup_device_tree(void)
1757{
1758 unsigned long offset = reloc_offset();
1759 phandle u3, i2c, mpic;
1760 u32 u3_rev;
1761 u32 interrupts[2];
1762 u32 parent;
1763
1764 /* Some G5s have a missing interrupt definition, fix it up here */
1765 u3 = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000"));
1766 if ((long)u3 <= 0)
1767 return;
1768 i2c = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/i2c@f8001000"));
1769 if ((long)i2c <= 0)
1770 return;
1771 mpic = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/mpic@f8040000"));
1772 if ((long)mpic <= 0)
1773 return;
1774
1775 /* check if proper rev of u3 */
1776 if (prom_getprop(u3, "device-rev", &u3_rev, sizeof(u3_rev)) <= 0)
1777 return;
1778 if (u3_rev != 0x35)
1779 return;
1780 /* does it need fixup ? */
1781 if (prom_getproplen(i2c, "interrupts") > 0)
1782 return;
1783 /* interrupt on this revision of u3 is number 0 and level */
1784 interrupts[0] = 0;
1785 interrupts[1] = 1;
1786 prom_setprop(i2c, "interrupts", &interrupts, sizeof(interrupts));
1787 parent = (u32)mpic;
1788 prom_setprop(i2c, "interrupt-parent", &parent, sizeof(parent));
1789}
1790
1754 1791
1755static void __init prom_find_boot_cpu(void) 1792static void __init prom_find_boot_cpu(void)
1756{ 1793{
@@ -1920,6 +1957,11 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4, unsigned long
1920 } 1957 }
1921 1958
1922 /* 1959 /*
1960 * Fixup any known bugs in the device-tree
1961 */
1962 fixup_device_tree();
1963
1964 /*
1923 * Now finally create the flattened device-tree 1965 * Now finally create the flattened device-tree
1924 */ 1966 */
1925 prom_printf("copying OF device tree ...\n"); 1967 prom_printf("copying OF device tree ...\n");
diff --git a/arch/ppc64/kernel/rtc.c b/arch/ppc64/kernel/rtc.c
index 3e70b91375fc..67989055a9fe 100644
--- a/arch/ppc64/kernel/rtc.c
+++ b/arch/ppc64/kernel/rtc.c
@@ -292,47 +292,10 @@ int iSeries_set_rtc_time(struct rtc_time *tm)
292 292
293void iSeries_get_boot_time(struct rtc_time *tm) 293void iSeries_get_boot_time(struct rtc_time *tm)
294{ 294{
295 unsigned long time;
296 static unsigned long lastsec = 1;
297
298 u32 dataWord1 = *((u32 *)(&xSpCommArea.xBcdTimeAtIplStart));
299 u32 dataWord2 = *(((u32 *)&(xSpCommArea.xBcdTimeAtIplStart)) + 1);
300 int year = 1970;
301 int year1 = ( dataWord1 >> 24 ) & 0x000000FF;
302 int year2 = ( dataWord1 >> 16 ) & 0x000000FF;
303 int sec = ( dataWord1 >> 8 ) & 0x000000FF;
304 int min = dataWord1 & 0x000000FF;
305 int hour = ( dataWord2 >> 24 ) & 0x000000FF;
306 int day = ( dataWord2 >> 8 ) & 0x000000FF;
307 int mon = dataWord2 & 0x000000FF;
308
309 if ( piranha_simulator ) 295 if ( piranha_simulator )
310 return; 296 return;
311 297
312 BCD_TO_BIN(sec); 298 mf_get_boot_rtc(tm);
313 BCD_TO_BIN(min);
314 BCD_TO_BIN(hour);
315 BCD_TO_BIN(day);
316 BCD_TO_BIN(mon);
317 BCD_TO_BIN(year1);
318 BCD_TO_BIN(year2);
319 year = year1 * 100 + year2;
320
321 time = mktime(year, mon, day, hour, min, sec);
322 time += ( jiffies / HZ );
323
324 /* Now THIS is a nasty hack!
325 * It ensures that the first two calls get different answers.
326 * That way the loop in init_time (time.c) will not think
327 * the clock is stuck.
328 */
329 if ( lastsec ) {
330 time -= lastsec;
331 --lastsec;
332 }
333
334 to_tm(time, tm);
335 tm->tm_year -= 1900;
336 tm->tm_mon -= 1; 299 tm->tm_mon -= 1;
337} 300}
338#endif 301#endif
diff --git a/arch/ppc64/kernel/time.c b/arch/ppc64/kernel/time.c
index 772a465b49f9..3d54745108c7 100644
--- a/arch/ppc64/kernel/time.c
+++ b/arch/ppc64/kernel/time.c
@@ -515,6 +515,7 @@ void __init time_init(void)
515 do_gtod.varp = &do_gtod.vars[0]; 515 do_gtod.varp = &do_gtod.vars[0];
516 do_gtod.var_idx = 0; 516 do_gtod.var_idx = 0;
517 do_gtod.varp->tb_orig_stamp = tb_last_stamp; 517 do_gtod.varp->tb_orig_stamp = tb_last_stamp;
518 get_paca()->next_jiffy_update_tb = tb_last_stamp + tb_ticks_per_jiffy;
518 do_gtod.varp->stamp_xsec = xtime.tv_sec * XSEC_PER_SEC; 519 do_gtod.varp->stamp_xsec = xtime.tv_sec * XSEC_PER_SEC;
519 do_gtod.tb_ticks_per_sec = tb_ticks_per_sec; 520 do_gtod.tb_ticks_per_sec = tb_ticks_per_sec;
520 do_gtod.varp->tb_to_xs = tb_to_xs; 521 do_gtod.varp->tb_to_xs = tb_to_xs;
diff --git a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c
index 292983413ae2..33ca56c90da2 100644
--- a/arch/sparc64/kernel/pci_iommu.c
+++ b/arch/sparc64/kernel/pci_iommu.c
@@ -8,6 +8,7 @@
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/sched.h> 9#include <linux/sched.h>
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/delay.h>
11 12
12#include <asm/pbm.h> 13#include <asm/pbm.h>
13 14
@@ -379,6 +380,56 @@ bad:
379 return PCI_DMA_ERROR_CODE; 380 return PCI_DMA_ERROR_CODE;
380} 381}
381 382
383static void pci_strbuf_flush(struct pci_strbuf *strbuf, struct pci_iommu *iommu, u32 vaddr, unsigned long ctx, unsigned long npages)
384{
385 int limit;
386
387 PCI_STC_FLUSHFLAG_INIT(strbuf);
388 if (strbuf->strbuf_ctxflush &&
389 iommu->iommu_ctxflush) {
390 unsigned long matchreg, flushreg;
391
392 flushreg = strbuf->strbuf_ctxflush;
393 matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx);
394
395 limit = 100000;
396 pci_iommu_write(flushreg, ctx);
397 for(;;) {
398 if (((long)pci_iommu_read(matchreg)) >= 0L)
399 break;
400 limit--;
401 if (!limit)
402 break;
403 udelay(1);
404 }
405 if (!limit)
406 printk(KERN_WARNING "pci_strbuf_flush: ctx flush "
407 "timeout vaddr[%08x] ctx[%lx]\n",
408 vaddr, ctx);
409 } else {
410 unsigned long i;
411
412 for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE)
413 pci_iommu_write(strbuf->strbuf_pflush, vaddr);
414 }
415
416 pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa);
417 (void) pci_iommu_read(iommu->write_complete_reg);
418
419 limit = 100000;
420 while (!PCI_STC_FLUSHFLAG_SET(strbuf)) {
421 limit--;
422 if (!limit)
423 break;
424 udelay(1);
425 membar("#LoadLoad");
426 }
427 if (!limit)
428 printk(KERN_WARNING "pci_strbuf_flush: flushflag timeout "
429 "vaddr[%08x] ctx[%lx] npages[%ld]\n",
430 vaddr, ctx, npages);
431}
432
382/* Unmap a single streaming mode DMA translation. */ 433/* Unmap a single streaming mode DMA translation. */
383void pci_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int direction) 434void pci_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int direction)
384{ 435{
@@ -386,7 +437,7 @@ void pci_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int
386 struct pci_iommu *iommu; 437 struct pci_iommu *iommu;
387 struct pci_strbuf *strbuf; 438 struct pci_strbuf *strbuf;
388 iopte_t *base; 439 iopte_t *base;
389 unsigned long flags, npages, i, ctx; 440 unsigned long flags, npages, ctx;
390 441
391 if (direction == PCI_DMA_NONE) 442 if (direction == PCI_DMA_NONE)
392 BUG(); 443 BUG();
@@ -414,29 +465,8 @@ void pci_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int
414 ctx = (iopte_val(*base) & IOPTE_CONTEXT) >> 47UL; 465 ctx = (iopte_val(*base) & IOPTE_CONTEXT) >> 47UL;
415 466
416 /* Step 1: Kick data out of streaming buffers if necessary. */ 467 /* Step 1: Kick data out of streaming buffers if necessary. */
417 if (strbuf->strbuf_enabled) { 468 if (strbuf->strbuf_enabled)
418 u32 vaddr = bus_addr; 469 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages);
419
420 PCI_STC_FLUSHFLAG_INIT(strbuf);
421 if (strbuf->strbuf_ctxflush &&
422 iommu->iommu_ctxflush) {
423 unsigned long matchreg, flushreg;
424
425 flushreg = strbuf->strbuf_ctxflush;
426 matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx);
427 do {
428 pci_iommu_write(flushreg, ctx);
429 } while(((long)pci_iommu_read(matchreg)) < 0L);
430 } else {
431 for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE)
432 pci_iommu_write(strbuf->strbuf_pflush, vaddr);
433 }
434
435 pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa);
436 (void) pci_iommu_read(iommu->write_complete_reg);
437 while (!PCI_STC_FLUSHFLAG_SET(strbuf))
438 membar("#LoadLoad");
439 }
440 470
441 /* Step 2: Clear out first TSB entry. */ 471 /* Step 2: Clear out first TSB entry. */
442 iopte_make_dummy(iommu, base); 472 iopte_make_dummy(iommu, base);
@@ -647,29 +677,8 @@ void pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems,
647 ctx = (iopte_val(*base) & IOPTE_CONTEXT) >> 47UL; 677 ctx = (iopte_val(*base) & IOPTE_CONTEXT) >> 47UL;
648 678
649 /* Step 1: Kick data out of streaming buffers if necessary. */ 679 /* Step 1: Kick data out of streaming buffers if necessary. */
650 if (strbuf->strbuf_enabled) { 680 if (strbuf->strbuf_enabled)
651 u32 vaddr = (u32) bus_addr; 681 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages);
652
653 PCI_STC_FLUSHFLAG_INIT(strbuf);
654 if (strbuf->strbuf_ctxflush &&
655 iommu->iommu_ctxflush) {
656 unsigned long matchreg, flushreg;
657
658 flushreg = strbuf->strbuf_ctxflush;
659 matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx);
660 do {
661 pci_iommu_write(flushreg, ctx);
662 } while(((long)pci_iommu_read(matchreg)) < 0L);
663 } else {
664 for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE)
665 pci_iommu_write(strbuf->strbuf_pflush, vaddr);
666 }
667
668 pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa);
669 (void) pci_iommu_read(iommu->write_complete_reg);
670 while (!PCI_STC_FLUSHFLAG_SET(strbuf))
671 membar("#LoadLoad");
672 }
673 682
674 /* Step 2: Clear out first TSB entry. */ 683 /* Step 2: Clear out first TSB entry. */
675 iopte_make_dummy(iommu, base); 684 iopte_make_dummy(iommu, base);
@@ -715,28 +724,7 @@ void pci_dma_sync_single_for_cpu(struct pci_dev *pdev, dma_addr_t bus_addr, size
715 } 724 }
716 725
717 /* Step 2: Kick data out of streaming buffers. */ 726 /* Step 2: Kick data out of streaming buffers. */
718 PCI_STC_FLUSHFLAG_INIT(strbuf); 727 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages);
719 if (iommu->iommu_ctxflush &&
720 strbuf->strbuf_ctxflush) {
721 unsigned long matchreg, flushreg;
722
723 flushreg = strbuf->strbuf_ctxflush;
724 matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx);
725 do {
726 pci_iommu_write(flushreg, ctx);
727 } while(((long)pci_iommu_read(matchreg)) < 0L);
728 } else {
729 unsigned long i;
730
731 for (i = 0; i < npages; i++, bus_addr += IO_PAGE_SIZE)
732 pci_iommu_write(strbuf->strbuf_pflush, bus_addr);
733 }
734
735 /* Step 3: Perform flush synchronization sequence. */
736 pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa);
737 (void) pci_iommu_read(iommu->write_complete_reg);
738 while (!PCI_STC_FLUSHFLAG_SET(strbuf))
739 membar("#LoadLoad");
740 728
741 spin_unlock_irqrestore(&iommu->lock, flags); 729 spin_unlock_irqrestore(&iommu->lock, flags);
742} 730}
@@ -749,7 +737,8 @@ void pci_dma_sync_sg_for_cpu(struct pci_dev *pdev, struct scatterlist *sglist, i
749 struct pcidev_cookie *pcp; 737 struct pcidev_cookie *pcp;
750 struct pci_iommu *iommu; 738 struct pci_iommu *iommu;
751 struct pci_strbuf *strbuf; 739 struct pci_strbuf *strbuf;
752 unsigned long flags, ctx; 740 unsigned long flags, ctx, npages, i;
741 u32 bus_addr;
753 742
754 pcp = pdev->sysdata; 743 pcp = pdev->sysdata;
755 iommu = pcp->pbm->iommu; 744 iommu = pcp->pbm->iommu;
@@ -772,36 +761,14 @@ void pci_dma_sync_sg_for_cpu(struct pci_dev *pdev, struct scatterlist *sglist, i
772 } 761 }
773 762
774 /* Step 2: Kick data out of streaming buffers. */ 763 /* Step 2: Kick data out of streaming buffers. */
775 PCI_STC_FLUSHFLAG_INIT(strbuf); 764 bus_addr = sglist[0].dma_address & IO_PAGE_MASK;
776 if (iommu->iommu_ctxflush && 765 for(i = 1; i < nelems; i++)
777 strbuf->strbuf_ctxflush) { 766 if (!sglist[i].dma_length)
778 unsigned long matchreg, flushreg; 767 break;
779 768 i--;
780 flushreg = strbuf->strbuf_ctxflush; 769 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length)
781 matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx); 770 - bus_addr) >> IO_PAGE_SHIFT;
782 do { 771 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages);
783 pci_iommu_write(flushreg, ctx);
784 } while (((long)pci_iommu_read(matchreg)) < 0L);
785 } else {
786 unsigned long i, npages;
787 u32 bus_addr;
788
789 bus_addr = sglist[0].dma_address & IO_PAGE_MASK;
790
791 for(i = 1; i < nelems; i++)
792 if (!sglist[i].dma_length)
793 break;
794 i--;
795 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length) - bus_addr) >> IO_PAGE_SHIFT;
796 for (i = 0; i < npages; i++, bus_addr += IO_PAGE_SIZE)
797 pci_iommu_write(strbuf->strbuf_pflush, bus_addr);
798 }
799
800 /* Step 3: Perform flush synchronization sequence. */
801 pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa);
802 (void) pci_iommu_read(iommu->write_complete_reg);
803 while (!PCI_STC_FLUSHFLAG_SET(strbuf))
804 membar("#LoadLoad");
805 772
806 spin_unlock_irqrestore(&iommu->lock, flags); 773 spin_unlock_irqrestore(&iommu->lock, flags);
807} 774}
diff --git a/arch/sparc64/kernel/sbus.c b/arch/sparc64/kernel/sbus.c
index 14d9c3a21b9a..76ea6455433f 100644
--- a/arch/sparc64/kernel/sbus.c
+++ b/arch/sparc64/kernel/sbus.c
@@ -117,19 +117,34 @@ static void iommu_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages
117 117
118#define STRBUF_TAG_VALID 0x02UL 118#define STRBUF_TAG_VALID 0x02UL
119 119
120static void strbuf_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages) 120static void sbus_strbuf_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages)
121{ 121{
122 unsigned long n;
123 int limit;
124
122 iommu->strbuf_flushflag = 0UL; 125 iommu->strbuf_flushflag = 0UL;
123 while (npages--) 126 n = npages;
124 upa_writeq(base + (npages << IO_PAGE_SHIFT), 127 while (n--)
128 upa_writeq(base + (n << IO_PAGE_SHIFT),
125 iommu->strbuf_regs + STRBUF_PFLUSH); 129 iommu->strbuf_regs + STRBUF_PFLUSH);
126 130
127 /* Whoopee cushion! */ 131 /* Whoopee cushion! */
128 upa_writeq(__pa(&iommu->strbuf_flushflag), 132 upa_writeq(__pa(&iommu->strbuf_flushflag),
129 iommu->strbuf_regs + STRBUF_FSYNC); 133 iommu->strbuf_regs + STRBUF_FSYNC);
130 upa_readq(iommu->sbus_control_reg); 134 upa_readq(iommu->sbus_control_reg);
131 while (iommu->strbuf_flushflag == 0UL) 135
136 limit = 100000;
137 while (iommu->strbuf_flushflag == 0UL) {
138 limit--;
139 if (!limit)
140 break;
141 udelay(1);
132 membar("#LoadLoad"); 142 membar("#LoadLoad");
143 }
144 if (!limit)
145 printk(KERN_WARNING "sbus_strbuf_flush: flushflag timeout "
146 "vaddr[%08x] npages[%ld]\n",
147 base, npages);
133} 148}
134 149
135static iopte_t *alloc_streaming_cluster(struct sbus_iommu *iommu, unsigned long npages) 150static iopte_t *alloc_streaming_cluster(struct sbus_iommu *iommu, unsigned long npages)
@@ -406,7 +421,7 @@ void sbus_unmap_single(struct sbus_dev *sdev, dma_addr_t dma_addr, size_t size,
406 421
407 spin_lock_irqsave(&iommu->lock, flags); 422 spin_lock_irqsave(&iommu->lock, flags);
408 free_streaming_cluster(iommu, dma_base, size >> IO_PAGE_SHIFT); 423 free_streaming_cluster(iommu, dma_base, size >> IO_PAGE_SHIFT);
409 strbuf_flush(iommu, dma_base, size >> IO_PAGE_SHIFT); 424 sbus_strbuf_flush(iommu, dma_base, size >> IO_PAGE_SHIFT);
410 spin_unlock_irqrestore(&iommu->lock, flags); 425 spin_unlock_irqrestore(&iommu->lock, flags);
411} 426}
412 427
@@ -569,7 +584,7 @@ void sbus_unmap_sg(struct sbus_dev *sdev, struct scatterlist *sg, int nents, int
569 iommu = sdev->bus->iommu; 584 iommu = sdev->bus->iommu;
570 spin_lock_irqsave(&iommu->lock, flags); 585 spin_lock_irqsave(&iommu->lock, flags);
571 free_streaming_cluster(iommu, dvma_base, size >> IO_PAGE_SHIFT); 586 free_streaming_cluster(iommu, dvma_base, size >> IO_PAGE_SHIFT);
572 strbuf_flush(iommu, dvma_base, size >> IO_PAGE_SHIFT); 587 sbus_strbuf_flush(iommu, dvma_base, size >> IO_PAGE_SHIFT);
573 spin_unlock_irqrestore(&iommu->lock, flags); 588 spin_unlock_irqrestore(&iommu->lock, flags);
574} 589}
575 590
@@ -581,7 +596,7 @@ void sbus_dma_sync_single_for_cpu(struct sbus_dev *sdev, dma_addr_t base, size_t
581 size = (IO_PAGE_ALIGN(base + size) - (base & IO_PAGE_MASK)); 596 size = (IO_PAGE_ALIGN(base + size) - (base & IO_PAGE_MASK));
582 597
583 spin_lock_irqsave(&iommu->lock, flags); 598 spin_lock_irqsave(&iommu->lock, flags);
584 strbuf_flush(iommu, base & IO_PAGE_MASK, size >> IO_PAGE_SHIFT); 599 sbus_strbuf_flush(iommu, base & IO_PAGE_MASK, size >> IO_PAGE_SHIFT);
585 spin_unlock_irqrestore(&iommu->lock, flags); 600 spin_unlock_irqrestore(&iommu->lock, flags);
586} 601}
587 602
@@ -605,7 +620,7 @@ void sbus_dma_sync_sg_for_cpu(struct sbus_dev *sdev, struct scatterlist *sg, int
605 size = IO_PAGE_ALIGN(sg[i].dma_address + sg[i].dma_length) - base; 620 size = IO_PAGE_ALIGN(sg[i].dma_address + sg[i].dma_length) - base;
606 621
607 spin_lock_irqsave(&iommu->lock, flags); 622 spin_lock_irqsave(&iommu->lock, flags);
608 strbuf_flush(iommu, base, size >> IO_PAGE_SHIFT); 623 sbus_strbuf_flush(iommu, base, size >> IO_PAGE_SHIFT);
609 spin_unlock_irqrestore(&iommu->lock, flags); 624 spin_unlock_irqrestore(&iommu->lock, flags);
610} 625}
611 626
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index 12c3d84b7460..b7e6a91952b2 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -383,6 +383,17 @@ static void __init process_switch(char c)
383 /* Use PROM debug console. */ 383 /* Use PROM debug console. */
384 register_console(&prom_debug_console); 384 register_console(&prom_debug_console);
385 break; 385 break;
386 case 'P':
387 /* Force UltraSPARC-III P-Cache on. */
388 if (tlb_type != cheetah) {
389 printk("BOOT: Ignoring P-Cache force option.\n");
390 break;
391 }
392 cheetah_pcache_forced_on = 1;
393 add_taint(TAINT_MACHINE_CHECK);
394 cheetah_enable_pcache();
395 break;
396
386 default: 397 default:
387 printk("Unknown boot switch (-%c)\n", c); 398 printk("Unknown boot switch (-%c)\n", c);
388 break; 399 break;
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 6dff06a44e76..e5b9c7a27789 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -123,6 +123,9 @@ void __init smp_callin(void)
123 123
124 smp_setup_percpu_timer(); 124 smp_setup_percpu_timer();
125 125
126 if (cheetah_pcache_forced_on)
127 cheetah_enable_pcache();
128
126 local_irq_enable(); 129 local_irq_enable();
127 130
128 calibrate_delay(); 131 calibrate_delay();
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index 56b203a2af69..a9f4596d7c2b 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -421,6 +421,25 @@ asmlinkage void cee_log(unsigned long ce_status,
421 } 421 }
422} 422}
423 423
424int cheetah_pcache_forced_on;
425
426void cheetah_enable_pcache(void)
427{
428 unsigned long dcr;
429
430 printk("CHEETAH: Enabling P-Cache on cpu %d.\n",
431 smp_processor_id());
432
433 __asm__ __volatile__("ldxa [%%g0] %1, %0"
434 : "=r" (dcr)
435 : "i" (ASI_DCU_CONTROL_REG));
436 dcr |= (DCU_PE | DCU_HPE | DCU_SPE | DCU_SL);
437 __asm__ __volatile__("stxa %0, [%%g0] %1\n\t"
438 "membar #Sync"
439 : /* no outputs */
440 : "r" (dcr), "i" (ASI_DCU_CONTROL_REG));
441}
442
424/* Cheetah error trap handling. */ 443/* Cheetah error trap handling. */
425static unsigned long ecache_flush_physbase; 444static unsigned long ecache_flush_physbase;
426static unsigned long ecache_flush_linesize; 445static unsigned long ecache_flush_linesize;
diff --git a/arch/um/Kconfig_x86_64 b/arch/um/Kconfig_x86_64
index fd8d7e8982b1..f162f50f0b17 100644
--- a/arch/um/Kconfig_x86_64
+++ b/arch/um/Kconfig_x86_64
@@ -6,6 +6,10 @@ config 64BIT
6 bool 6 bool
7 default y 7 default y
8 8
9config TOP_ADDR
10 hex
11 default 0x80000000
12
9config 3_LEVEL_PGTABLES 13config 3_LEVEL_PGTABLES
10 bool 14 bool
11 default y 15 default y
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 0150038af795..14a12d6b3df6 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -20,9 +20,17 @@
20#include "os.h" 20#include "os.h"
21 21
22#ifdef CONFIG_NOCONFIG_CHAN 22#ifdef CONFIG_NOCONFIG_CHAN
23
24/* The printk's here are wrong because we are complaining that there is no
25 * output device, but printk is printing to that output device. The user will
26 * never see the error. printf would be better, except it can't run on a
27 * kernel stack because it will overflow it.
28 * Use printk for now since that will avoid crashing.
29 */
30
23static void *not_configged_init(char *str, int device, struct chan_opts *opts) 31static void *not_configged_init(char *str, int device, struct chan_opts *opts)
24{ 32{
25 printf(KERN_ERR "Using a channel type which is configured out of " 33 printk(KERN_ERR "Using a channel type which is configured out of "
26 "UML\n"); 34 "UML\n");
27 return(NULL); 35 return(NULL);
28} 36}
@@ -30,27 +38,27 @@ static void *not_configged_init(char *str, int device, struct chan_opts *opts)
30static int not_configged_open(int input, int output, int primary, void *data, 38static int not_configged_open(int input, int output, int primary, void *data,
31 char **dev_out) 39 char **dev_out)
32{ 40{
33 printf(KERN_ERR "Using a channel type which is configured out of " 41 printk(KERN_ERR "Using a channel type which is configured out of "
34 "UML\n"); 42 "UML\n");
35 return(-ENODEV); 43 return(-ENODEV);
36} 44}
37 45
38static void not_configged_close(int fd, void *data) 46static void not_configged_close(int fd, void *data)
39{ 47{
40 printf(KERN_ERR "Using a channel type which is configured out of " 48 printk(KERN_ERR "Using a channel type which is configured out of "
41 "UML\n"); 49 "UML\n");
42} 50}
43 51
44static int not_configged_read(int fd, char *c_out, void *data) 52static int not_configged_read(int fd, char *c_out, void *data)
45{ 53{
46 printf(KERN_ERR "Using a channel type which is configured out of " 54 printk(KERN_ERR "Using a channel type which is configured out of "
47 "UML\n"); 55 "UML\n");
48 return(-EIO); 56 return(-EIO);
49} 57}
50 58
51static int not_configged_write(int fd, const char *buf, int len, void *data) 59static int not_configged_write(int fd, const char *buf, int len, void *data)
52{ 60{
53 printf(KERN_ERR "Using a channel type which is configured out of " 61 printk(KERN_ERR "Using a channel type which is configured out of "
54 "UML\n"); 62 "UML\n");
55 return(-EIO); 63 return(-EIO);
56} 64}
@@ -58,7 +66,7 @@ static int not_configged_write(int fd, const char *buf, int len, void *data)
58static int not_configged_console_write(int fd, const char *buf, int len, 66static int not_configged_console_write(int fd, const char *buf, int len,
59 void *data) 67 void *data)
60{ 68{
61 printf(KERN_ERR "Using a channel type which is configured out of " 69 printk(KERN_ERR "Using a channel type which is configured out of "
62 "UML\n"); 70 "UML\n");
63 return(-EIO); 71 return(-EIO);
64} 72}
@@ -66,7 +74,7 @@ static int not_configged_console_write(int fd, const char *buf, int len,
66static int not_configged_window_size(int fd, void *data, unsigned short *rows, 74static int not_configged_window_size(int fd, void *data, unsigned short *rows,
67 unsigned short *cols) 75 unsigned short *cols)
68{ 76{
69 printf(KERN_ERR "Using a channel type which is configured out of " 77 printk(KERN_ERR "Using a channel type which is configured out of "
70 "UML\n"); 78 "UML\n");
71 return(-ENODEV); 79 return(-ENODEV);
72} 80}
diff --git a/arch/um/drivers/mcast_kern.c b/arch/um/drivers/mcast_kern.c
index faf714e87b5b..217438cdef33 100644
--- a/arch/um/drivers/mcast_kern.c
+++ b/arch/um/drivers/mcast_kern.c
@@ -73,7 +73,6 @@ int mcast_setup(char *str, char **mac_out, void *data)
73 struct mcast_init *init = data; 73 struct mcast_init *init = data;
74 char *port_str = NULL, *ttl_str = NULL, *remain; 74 char *port_str = NULL, *ttl_str = NULL, *remain;
75 char *last; 75 char *last;
76 int n;
77 76
78 *init = ((struct mcast_init) 77 *init = ((struct mcast_init)
79 { .addr = "239.192.168.1", 78 { .addr = "239.192.168.1",
@@ -89,13 +88,12 @@ int mcast_setup(char *str, char **mac_out, void *data)
89 } 88 }
90 89
91 if(port_str != NULL){ 90 if(port_str != NULL){
92 n = simple_strtoul(port_str, &last, 10); 91 init->port = simple_strtoul(port_str, &last, 10);
93 if((*last != '\0') || (last == port_str)){ 92 if((*last != '\0') || (last == port_str)){
94 printk(KERN_ERR "mcast_setup - Bad port : '%s'\n", 93 printk(KERN_ERR "mcast_setup - Bad port : '%s'\n",
95 port_str); 94 port_str);
96 return(0); 95 return(0);
97 } 96 }
98 init->port = htons(n);
99 } 97 }
100 98
101 if(ttl_str != NULL){ 99 if(ttl_str != NULL){
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c
index 0fe1d9fa9139..7a0d115b29d0 100644
--- a/arch/um/drivers/mcast_user.c
+++ b/arch/um/drivers/mcast_user.c
@@ -38,7 +38,7 @@ static struct sockaddr_in *new_addr(char *addr, unsigned short port)
38 } 38 }
39 sin->sin_family = AF_INET; 39 sin->sin_family = AF_INET;
40 sin->sin_addr.s_addr = in_aton(addr); 40 sin->sin_addr.s_addr = in_aton(addr);
41 sin->sin_port = port; 41 sin->sin_port = htons(port);
42 return(sin); 42 return(sin);
43} 43}
44 44
@@ -55,28 +55,25 @@ static int mcast_open(void *data)
55 struct mcast_data *pri = data; 55 struct mcast_data *pri = data;
56 struct sockaddr_in *sin = pri->mcast_addr; 56 struct sockaddr_in *sin = pri->mcast_addr;
57 struct ip_mreq mreq; 57 struct ip_mreq mreq;
58 int fd, yes = 1; 58 int fd = -EINVAL, yes = 1, err = -EINVAL;;
59 59
60 60
61 if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) { 61 if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0))
62 fd = -EINVAL;
63 goto out; 62 goto out;
64 }
65 63
66 fd = socket(AF_INET, SOCK_DGRAM, 0); 64 fd = socket(AF_INET, SOCK_DGRAM, 0);
65
67 if (fd < 0){ 66 if (fd < 0){
68 printk("mcast_open : data socket failed, errno = %d\n", 67 printk("mcast_open : data socket failed, errno = %d\n",
69 errno); 68 errno);
70 fd = -ENOMEM; 69 fd = -errno;
71 goto out; 70 goto out;
72 } 71 }
73 72
74 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { 73 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
75 printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", 74 printk("mcast_open: SO_REUSEADDR failed, errno = %d\n",
76 errno); 75 errno);
77 os_close_file(fd); 76 goto out_close;
78 fd = -EINVAL;
79 goto out;
80 } 77 }
81 78
82 /* set ttl according to config */ 79 /* set ttl according to config */
@@ -84,26 +81,20 @@ static int mcast_open(void *data)
84 sizeof(pri->ttl)) < 0) { 81 sizeof(pri->ttl)) < 0) {
85 printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", 82 printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n",
86 errno); 83 errno);
87 os_close_file(fd); 84 goto out_close;
88 fd = -EINVAL;
89 goto out;
90 } 85 }
91 86
92 /* set LOOP, so data does get fed back to local sockets */ 87 /* set LOOP, so data does get fed back to local sockets */
93 if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { 88 if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
94 printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", 89 printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n",
95 errno); 90 errno);
96 os_close_file(fd); 91 goto out_close;
97 fd = -EINVAL;
98 goto out;
99 } 92 }
100 93
101 /* bind socket to mcast address */ 94 /* bind socket to mcast address */
102 if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { 95 if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) {
103 printk("mcast_open : data bind failed, errno = %d\n", errno); 96 printk("mcast_open : data bind failed, errno = %d\n", errno);
104 os_close_file(fd); 97 goto out_close;
105 fd = -EINVAL;
106 goto out;
107 } 98 }
108 99
109 /* subscribe to the multicast group */ 100 /* subscribe to the multicast group */
@@ -117,12 +108,15 @@ static int mcast_open(void *data)
117 "interface on the host.\n"); 108 "interface on the host.\n");
118 printk("eth0 should be configured in order to use the " 109 printk("eth0 should be configured in order to use the "
119 "multicast transport.\n"); 110 "multicast transport.\n");
120 os_close_file(fd); 111 goto out_close;
121 fd = -EINVAL;
122 } 112 }
123 113
124 out: 114 out:
125 return(fd); 115 return fd;
116
117 out_close:
118 os_close_file(fd);
119 return err;
126} 120}
127 121
128static void mcast_close(int fd, void *data) 122static void mcast_close(int fd, void *data)
@@ -164,14 +158,3 @@ struct net_user_info mcast_user_info = {
164 .delete_address = NULL, 158 .delete_address = NULL,
165 .max_packet = MAX_PACKET - ETH_HEADER_OTHER 159 .max_packet = MAX_PACKET - ETH_HEADER_OTHER
166}; 160};
167
168/*
169 * Overrides for Emacs so that we follow Linus's tabbing style.
170 * Emacs will notice this stuff at the end of the file and automatically
171 * adjust the settings for this buffer only. This must remain at the end
172 * of the file.
173 * ---------------------------------------------------------------------------
174 * Local variables:
175 * c-file-style: "linux"
176 * End:
177 */
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 9a56ff94308d..88f956c34fed 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -55,7 +55,7 @@
55#include "mem_kern.h" 55#include "mem_kern.h"
56#include "cow.h" 56#include "cow.h"
57 57
58enum ubd_req { UBD_READ, UBD_WRITE, UBD_MMAP }; 58enum ubd_req { UBD_READ, UBD_WRITE };
59 59
60struct io_thread_req { 60struct io_thread_req {
61 enum ubd_req op; 61 enum ubd_req op;
@@ -68,8 +68,6 @@ struct io_thread_req {
68 unsigned long sector_mask; 68 unsigned long sector_mask;
69 unsigned long long cow_offset; 69 unsigned long long cow_offset;
70 unsigned long bitmap_words[2]; 70 unsigned long bitmap_words[2];
71 int map_fd;
72 unsigned long long map_offset;
73 int error; 71 int error;
74}; 72};
75 73
@@ -122,10 +120,6 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
122 120
123#define MAX_DEV (8) 121#define MAX_DEV (8)
124 122
125/* Changed in early boot */
126static int ubd_do_mmap = 0;
127#define UBD_MMAP_BLOCK_SIZE PAGE_SIZE
128
129static struct block_device_operations ubd_blops = { 123static struct block_device_operations ubd_blops = {
130 .owner = THIS_MODULE, 124 .owner = THIS_MODULE,
131 .open = ubd_open, 125 .open = ubd_open,
@@ -175,12 +169,6 @@ struct ubd {
175 int no_cow; 169 int no_cow;
176 struct cow cow; 170 struct cow cow;
177 struct platform_device pdev; 171 struct platform_device pdev;
178
179 int map_writes;
180 int map_reads;
181 int nomap_writes;
182 int nomap_reads;
183 int write_maps;
184}; 172};
185 173
186#define DEFAULT_COW { \ 174#define DEFAULT_COW { \
@@ -200,11 +188,6 @@ struct ubd {
200 .openflags = OPEN_FLAGS, \ 188 .openflags = OPEN_FLAGS, \
201 .no_cow = 0, \ 189 .no_cow = 0, \
202 .cow = DEFAULT_COW, \ 190 .cow = DEFAULT_COW, \
203 .map_writes = 0, \
204 .map_reads = 0, \
205 .nomap_writes = 0, \
206 .nomap_reads = 0, \
207 .write_maps = 0, \
208} 191}
209 192
210struct ubd ubd_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD }; 193struct ubd ubd_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD };
@@ -314,13 +297,6 @@ static int ubd_setup_common(char *str, int *index_out)
314 int major; 297 int major;
315 298
316 str++; 299 str++;
317 if(!strcmp(str, "mmap")){
318 CHOOSE_MODE(printk("mmap not supported by the ubd "
319 "driver in tt mode\n"),
320 ubd_do_mmap = 1);
321 return(0);
322 }
323
324 if(!strcmp(str, "sync")){ 300 if(!strcmp(str, "sync")){
325 global_openflags = of_sync(global_openflags); 301 global_openflags = of_sync(global_openflags);
326 return(0); 302 return(0);
@@ -524,7 +500,7 @@ static void ubd_handler(void)
524{ 500{
525 struct io_thread_req req; 501 struct io_thread_req req;
526 struct request *rq = elv_next_request(ubd_queue); 502 struct request *rq = elv_next_request(ubd_queue);
527 int n, err; 503 int n;
528 504
529 do_ubd = NULL; 505 do_ubd = NULL;
530 intr_count++; 506 intr_count++;
@@ -538,19 +514,6 @@ static void ubd_handler(void)
538 return; 514 return;
539 } 515 }
540 516
541 if((req.op != UBD_MMAP) &&
542 ((req.offset != ((__u64) (rq->sector)) << 9) ||
543 (req.length != (rq->current_nr_sectors) << 9)))
544 panic("I/O op mismatch");
545
546 if(req.map_fd != -1){
547 err = physmem_subst_mapping(req.buffer, req.map_fd,
548 req.map_offset, 1);
549 if(err)
550 printk("ubd_handler - physmem_subst_mapping failed, "
551 "err = %d\n", -err);
552 }
553
554 ubd_finish(rq, req.error); 517 ubd_finish(rq, req.error);
555 reactivate_fd(thread_fd, UBD_IRQ); 518 reactivate_fd(thread_fd, UBD_IRQ);
556 do_ubd_request(ubd_queue); 519 do_ubd_request(ubd_queue);
@@ -583,14 +546,10 @@ static int ubd_file_size(struct ubd *dev, __u64 *size_out)
583 546
584static void ubd_close(struct ubd *dev) 547static void ubd_close(struct ubd *dev)
585{ 548{
586 if(ubd_do_mmap)
587 physmem_forget_descriptor(dev->fd);
588 os_close_file(dev->fd); 549 os_close_file(dev->fd);
589 if(dev->cow.file == NULL) 550 if(dev->cow.file == NULL)
590 return; 551 return;
591 552
592 if(ubd_do_mmap)
593 physmem_forget_descriptor(dev->cow.fd);
594 os_close_file(dev->cow.fd); 553 os_close_file(dev->cow.fd);
595 vfree(dev->cow.bitmap); 554 vfree(dev->cow.bitmap);
596 dev->cow.bitmap = NULL; 555 dev->cow.bitmap = NULL;
@@ -1010,94 +969,13 @@ static void cowify_req(struct io_thread_req *req, unsigned long *bitmap,
1010 req->bitmap_words, bitmap_len); 969 req->bitmap_words, bitmap_len);
1011} 970}
1012 971
1013static int mmap_fd(struct request *req, struct ubd *dev, __u64 offset)
1014{
1015 __u64 sector;
1016 unsigned char *bitmap;
1017 int bit, i;
1018
1019 /* mmap must have been requested on the command line */
1020 if(!ubd_do_mmap)
1021 return(-1);
1022
1023 /* The buffer must be page aligned */
1024 if(((unsigned long) req->buffer % UBD_MMAP_BLOCK_SIZE) != 0)
1025 return(-1);
1026
1027 /* The request must be a page long */
1028 if((req->current_nr_sectors << 9) != PAGE_SIZE)
1029 return(-1);
1030
1031 if(dev->cow.file == NULL)
1032 return(dev->fd);
1033
1034 sector = offset >> 9;
1035 bitmap = (unsigned char *) dev->cow.bitmap;
1036 bit = ubd_test_bit(sector, bitmap);
1037
1038 for(i = 1; i < req->current_nr_sectors; i++){
1039 if(ubd_test_bit(sector + i, bitmap) != bit)
1040 return(-1);
1041 }
1042
1043 if(bit || (rq_data_dir(req) == WRITE))
1044 offset += dev->cow.data_offset;
1045
1046 /* The data on disk must be page aligned */
1047 if((offset % UBD_MMAP_BLOCK_SIZE) != 0)
1048 return(-1);
1049
1050 return(bit ? dev->fd : dev->cow.fd);
1051}
1052
1053static int prepare_mmap_request(struct ubd *dev, int fd, __u64 offset,
1054 struct request *req,
1055 struct io_thread_req *io_req)
1056{
1057 int err;
1058
1059 if(rq_data_dir(req) == WRITE){
1060 /* Writes are almost no-ops since the new data is already in the
1061 * host page cache
1062 */
1063 dev->map_writes++;
1064 if(dev->cow.file != NULL)
1065 cowify_bitmap(io_req->offset, io_req->length,
1066 &io_req->sector_mask, &io_req->cow_offset,
1067 dev->cow.bitmap, dev->cow.bitmap_offset,
1068 io_req->bitmap_words,
1069 dev->cow.bitmap_len);
1070 }
1071 else {
1072 int w;
1073
1074 if((dev->cow.file != NULL) && (fd == dev->cow.fd))
1075 w = 0;
1076 else w = dev->openflags.w;
1077
1078 if((dev->cow.file != NULL) && (fd == dev->fd))
1079 offset += dev->cow.data_offset;
1080
1081 err = physmem_subst_mapping(req->buffer, fd, offset, w);
1082 if(err){
1083 printk("physmem_subst_mapping failed, err = %d\n",
1084 -err);
1085 return(1);
1086 }
1087 dev->map_reads++;
1088 }
1089 io_req->op = UBD_MMAP;
1090 io_req->buffer = req->buffer;
1091 return(0);
1092}
1093
1094/* Called with ubd_io_lock held */ 972/* Called with ubd_io_lock held */
1095static int prepare_request(struct request *req, struct io_thread_req *io_req) 973static int prepare_request(struct request *req, struct io_thread_req *io_req)
1096{ 974{
1097 struct gendisk *disk = req->rq_disk; 975 struct gendisk *disk = req->rq_disk;
1098 struct ubd *dev = disk->private_data; 976 struct ubd *dev = disk->private_data;
1099 __u64 offset; 977 __u64 offset;
1100 int len, fd; 978 int len;
1101 979
1102 if(req->rq_status == RQ_INACTIVE) return(1); 980 if(req->rq_status == RQ_INACTIVE) return(1);
1103 981
@@ -1114,34 +992,12 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req)
1114 992
1115 io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd; 993 io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd;
1116 io_req->fds[1] = dev->fd; 994 io_req->fds[1] = dev->fd;
1117 io_req->map_fd = -1;
1118 io_req->cow_offset = -1; 995 io_req->cow_offset = -1;
1119 io_req->offset = offset; 996 io_req->offset = offset;
1120 io_req->length = len; 997 io_req->length = len;
1121 io_req->error = 0; 998 io_req->error = 0;
1122 io_req->sector_mask = 0; 999 io_req->sector_mask = 0;
1123 1000
1124 fd = mmap_fd(req, dev, io_req->offset);
1125 if(fd > 0){
1126 /* If mmapping is otherwise OK, but the first access to the
1127 * page is a write, then it's not mapped in yet. So we have
1128 * to write the data to disk first, then we can map the disk
1129 * page in and continue normally from there.
1130 */
1131 if((rq_data_dir(req) == WRITE) && !is_remapped(req->buffer)){
1132 io_req->map_fd = dev->fd;
1133 io_req->map_offset = io_req->offset +
1134 dev->cow.data_offset;
1135 dev->write_maps++;
1136 }
1137 else return(prepare_mmap_request(dev, fd, io_req->offset, req,
1138 io_req));
1139 }
1140
1141 if(rq_data_dir(req) == READ)
1142 dev->nomap_reads++;
1143 else dev->nomap_writes++;
1144
1145 io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE; 1001 io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE;
1146 io_req->offsets[0] = 0; 1002 io_req->offsets[0] = 0;
1147 io_req->offsets[1] = dev->cow.data_offset; 1003 io_req->offsets[1] = dev->cow.data_offset;
@@ -1229,143 +1085,6 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
1229 return(-EINVAL); 1085 return(-EINVAL);
1230} 1086}
1231 1087
1232static int ubd_check_remapped(int fd, unsigned long address, int is_write,
1233 __u64 offset)
1234{
1235 __u64 bitmap_offset;
1236 unsigned long new_bitmap[2];
1237 int i, err, n;
1238
1239 /* If it's not a write access, we can't do anything about it */
1240 if(!is_write)
1241 return(0);
1242
1243 /* We have a write */
1244 for(i = 0; i < sizeof(ubd_dev) / sizeof(ubd_dev[0]); i++){
1245 struct ubd *dev = &ubd_dev[i];
1246
1247 if((dev->fd != fd) && (dev->cow.fd != fd))
1248 continue;
1249
1250 /* It's a write to a ubd device */
1251
1252 /* This should be impossible now */
1253 if(!dev->openflags.w){
1254 /* It's a write access on a read-only device - probably
1255 * shouldn't happen. If the kernel is trying to change
1256 * something with no intention of writing it back out,
1257 * then this message will clue us in that this needs
1258 * fixing
1259 */
1260 printk("Write access to mapped page from readonly ubd "
1261 "device %d\n", i);
1262 return(0);
1263 }
1264
1265 /* It's a write to a writeable ubd device - it must be COWed
1266 * because, otherwise, the page would have been mapped in
1267 * writeable
1268 */
1269
1270 if(!dev->cow.file)
1271 panic("Write fault on writeable non-COW ubd device %d",
1272 i);
1273
1274 /* It should also be an access to the backing file since the
1275 * COW pages should be mapped in read-write
1276 */
1277
1278 if(fd == dev->fd)
1279 panic("Write fault on a backing page of ubd "
1280 "device %d\n", i);
1281
1282 /* So, we do the write, copying the backing data to the COW
1283 * file...
1284 */
1285
1286 err = os_seek_file(dev->fd, offset + dev->cow.data_offset);
1287 if(err < 0)
1288 panic("Couldn't seek to %lld in COW file of ubd "
1289 "device %d, err = %d",
1290 offset + dev->cow.data_offset, i, -err);
1291
1292 n = os_write_file(dev->fd, (void *) address, PAGE_SIZE);
1293 if(n != PAGE_SIZE)
1294 panic("Couldn't copy data to COW file of ubd "
1295 "device %d, err = %d", i, -n);
1296
1297 /* ... updating the COW bitmap... */
1298
1299 cowify_bitmap(offset, PAGE_SIZE, NULL, &bitmap_offset,
1300 dev->cow.bitmap, dev->cow.bitmap_offset,
1301 new_bitmap, dev->cow.bitmap_len);
1302
1303 err = os_seek_file(dev->fd, bitmap_offset);
1304 if(err < 0)
1305 panic("Couldn't seek to %lld in COW file of ubd "
1306 "device %d, err = %d", bitmap_offset, i, -err);
1307
1308 n = os_write_file(dev->fd, new_bitmap, sizeof(new_bitmap));
1309 if(n != sizeof(new_bitmap))
1310 panic("Couldn't update bitmap of ubd device %d, "
1311 "err = %d", i, -n);
1312
1313 /* Maybe we can map the COW page in, and maybe we can't. If
1314 * it is a pre-V3 COW file, we can't, since the alignment will
1315 * be wrong. If it is a V3 or later COW file which has been
1316 * moved to a system with a larger page size, then maybe we
1317 * can't, depending on the exact location of the page.
1318 */
1319
1320 offset += dev->cow.data_offset;
1321
1322 /* Remove the remapping, putting the original anonymous page
1323 * back. If the COW file can be mapped in, that is done.
1324 * Otherwise, the COW page is read in.
1325 */
1326
1327 if(!physmem_remove_mapping((void *) address))
1328 panic("Address 0x%lx not remapped by ubd device %d",
1329 address, i);
1330 if((offset % UBD_MMAP_BLOCK_SIZE) == 0)
1331 physmem_subst_mapping((void *) address, dev->fd,
1332 offset, 1);
1333 else {
1334 err = os_seek_file(dev->fd, offset);
1335 if(err < 0)
1336 panic("Couldn't seek to %lld in COW file of "
1337 "ubd device %d, err = %d", offset, i,
1338 -err);
1339
1340 n = os_read_file(dev->fd, (void *) address, PAGE_SIZE);
1341 if(n != PAGE_SIZE)
1342 panic("Failed to read page from offset %llx of "
1343 "COW file of ubd device %d, err = %d",
1344 offset, i, -n);
1345 }
1346
1347 return(1);
1348 }
1349
1350 /* It's not a write on a ubd device */
1351 return(0);
1352}
1353
1354static struct remapper ubd_remapper = {
1355 .list = LIST_HEAD_INIT(ubd_remapper.list),
1356 .proc = ubd_check_remapped,
1357};
1358
1359static int ubd_remapper_setup(void)
1360{
1361 if(ubd_do_mmap)
1362 register_remapper(&ubd_remapper);
1363
1364 return(0);
1365}
1366
1367__initcall(ubd_remapper_setup);
1368
1369static int same_backing_files(char *from_cmdline, char *from_cow, char *cow) 1088static int same_backing_files(char *from_cmdline, char *from_cow, char *cow)
1370{ 1089{
1371 struct uml_stat buf1, buf2; 1090 struct uml_stat buf1, buf2;
@@ -1568,15 +1287,6 @@ void do_io(struct io_thread_req *req)
1568 int err; 1287 int err;
1569 __u64 off; 1288 __u64 off;
1570 1289
1571 if(req->op == UBD_MMAP){
1572 /* Touch the page to force the host to do any necessary IO to
1573 * get it into memory
1574 */
1575 n = *((volatile int *) req->buffer);
1576 req->error = update_bitmap(req);
1577 return;
1578 }
1579
1580 nsectors = req->length / req->sectorsize; 1290 nsectors = req->length / req->sectorsize;
1581 start = 0; 1291 start = 0;
1582 do { 1292 do {
diff --git a/arch/um/include/sysdep-i386/ptrace.h b/arch/um/include/sysdep-i386/ptrace.h
index 84ec7ff5cf8c..6eaeb9919983 100644
--- a/arch/um/include/sysdep-i386/ptrace.h
+++ b/arch/um/include/sysdep-i386/ptrace.h
@@ -31,7 +31,6 @@ extern int sysemu_supported;
31#ifdef UML_CONFIG_MODE_SKAS 31#ifdef UML_CONFIG_MODE_SKAS
32 32
33#include "skas_ptregs.h" 33#include "skas_ptregs.h"
34#include "sysdep/faultinfo.h"
35 34
36#define REGS_IP(r) ((r)[HOST_IP]) 35#define REGS_IP(r) ((r)[HOST_IP])
37#define REGS_SP(r) ((r)[HOST_SP]) 36#define REGS_SP(r) ((r)[HOST_SP])
@@ -59,6 +58,7 @@ extern int sysemu_supported;
59#define PTRACE_SYSEMU_SINGLESTEP 32 58#define PTRACE_SYSEMU_SINGLESTEP 32
60#endif 59#endif
61 60
61#include "sysdep/faultinfo.h"
62#include "choose-mode.h" 62#include "choose-mode.h"
63 63
64union uml_pt_regs { 64union uml_pt_regs {
diff --git a/arch/um/include/sysdep-x86_64/checksum.h b/arch/um/include/sysdep-x86_64/checksum.h
index 572c6c19be33..ea97005af694 100644
--- a/arch/um/include/sysdep-x86_64/checksum.h
+++ b/arch/um/include/sysdep-x86_64/checksum.h
@@ -9,8 +9,6 @@
9#include "linux/in6.h" 9#include "linux/in6.h"
10#include "asm/uaccess.h" 10#include "asm/uaccess.h"
11 11
12extern unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst, int len,
13 int sum, int *err_ptr);
14extern unsigned csum_partial(const unsigned char *buff, unsigned len, 12extern unsigned csum_partial(const unsigned char *buff, unsigned len,
15 unsigned sum); 13 unsigned sum);
16 14
@@ -31,10 +29,15 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *
31} 29}
32 30
33static __inline__ 31static __inline__
34unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, 32unsigned int csum_partial_copy_from_user(const unsigned char *src,
35 int len, int sum, int *err_ptr) 33 unsigned char *dst, int len, int sum,
34 int *err_ptr)
36{ 35{
37 return csum_partial_copy_from(src, dst, len, sum, err_ptr); 36 if(copy_from_user(dst, src, len)){
37 *err_ptr = -EFAULT;
38 return(-1);
39 }
40 return csum_partial(dst, len, sum);
38} 41}
39 42
40/** 43/**
@@ -137,15 +140,6 @@ static inline unsigned add32_with_carry(unsigned a, unsigned b)
137 return a; 140 return a;
138} 141}
139 142
140#endif 143extern unsigned short ip_compute_csum(unsigned char * buff, int len);
141 144
142/* 145#endif
143 * Overrides for Emacs so that we follow Linus's tabbing style.
144 * Emacs will notice this stuff at the end of the file and automatically
145 * adjust the settings for this buffer only. This must remain at the end
146 * of the file.
147 * ---------------------------------------------------------------------------
148 * Local variables:
149 * c-file-style: "linux"
150 * End:
151 */
diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h
index 348e8fcd513f..be8acd5efd97 100644
--- a/arch/um/include/sysdep-x86_64/ptrace.h
+++ b/arch/um/include/sysdep-x86_64/ptrace.h
@@ -135,6 +135,7 @@ extern int mode_tt;
135 __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs)) 135 __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs))
136#define UPT_SC(r) ((r)->tt.sc) 136#define UPT_SC(r) ((r)->tt.sc)
137#define UPT_SYSCALL_NR(r) __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall) 137#define UPT_SYSCALL_NR(r) __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall)
138#define UPT_SYSCALL_RET(r) UPT_RAX(r)
138 139
139extern int user_context(unsigned long sp); 140extern int user_context(unsigned long sp);
140 141
@@ -196,32 +197,32 @@ struct syscall_args {
196 197
197 198
198#define UPT_SET(regs, reg, val) \ 199#define UPT_SET(regs, reg, val) \
199 ({ unsigned long val; \ 200 ({ unsigned long __upt_val = val; \
200 switch(reg){ \ 201 switch(reg){ \
201 case R8: UPT_R8(regs) = val; break; \ 202 case R8: UPT_R8(regs) = __upt_val; break; \
202 case R9: UPT_R9(regs) = val; break; \ 203 case R9: UPT_R9(regs) = __upt_val; break; \
203 case R10: UPT_R10(regs) = val; break; \ 204 case R10: UPT_R10(regs) = __upt_val; break; \
204 case R11: UPT_R11(regs) = val; break; \ 205 case R11: UPT_R11(regs) = __upt_val; break; \
205 case R12: UPT_R12(regs) = val; break; \ 206 case R12: UPT_R12(regs) = __upt_val; break; \
206 case R13: UPT_R13(regs) = val; break; \ 207 case R13: UPT_R13(regs) = __upt_val; break; \
207 case R14: UPT_R14(regs) = val; break; \ 208 case R14: UPT_R14(regs) = __upt_val; break; \
208 case R15: UPT_R15(regs) = val; break; \ 209 case R15: UPT_R15(regs) = __upt_val; break; \
209 case RIP: UPT_IP(regs) = val; break; \ 210 case RIP: UPT_IP(regs) = __upt_val; break; \
210 case RSP: UPT_SP(regs) = val; break; \ 211 case RSP: UPT_SP(regs) = __upt_val; break; \
211 case RAX: UPT_RAX(regs) = val; break; \ 212 case RAX: UPT_RAX(regs) = __upt_val; break; \
212 case RBX: UPT_RBX(regs) = val; break; \ 213 case RBX: UPT_RBX(regs) = __upt_val; break; \
213 case RCX: UPT_RCX(regs) = val; break; \ 214 case RCX: UPT_RCX(regs) = __upt_val; break; \
214 case RDX: UPT_RDX(regs) = val; break; \ 215 case RDX: UPT_RDX(regs) = __upt_val; break; \
215 case RSI: UPT_RSI(regs) = val; break; \ 216 case RSI: UPT_RSI(regs) = __upt_val; break; \
216 case RDI: UPT_RDI(regs) = val; break; \ 217 case RDI: UPT_RDI(regs) = __upt_val; break; \
217 case RBP: UPT_RBP(regs) = val; break; \ 218 case RBP: UPT_RBP(regs) = __upt_val; break; \
218 case ORIG_RAX: UPT_ORIG_RAX(regs) = val; break; \ 219 case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \
219 case CS: UPT_CS(regs) = val; break; \ 220 case CS: UPT_CS(regs) = __upt_val; break; \
220 case DS: UPT_DS(regs) = val; break; \ 221 case DS: UPT_DS(regs) = __upt_val; break; \
221 case ES: UPT_ES(regs) = val; break; \ 222 case ES: UPT_ES(regs) = __upt_val; break; \
222 case FS: UPT_FS(regs) = val; break; \ 223 case FS: UPT_FS(regs) = __upt_val; break; \
223 case GS: UPT_GS(regs) = val; break; \ 224 case GS: UPT_GS(regs) = __upt_val; break; \
224 case EFLAGS: UPT_EFLAGS(regs) = val; break; \ 225 case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \
225 default : \ 226 default : \
226 panic("Bad register in UPT_SET : %d\n", reg); \ 227 panic("Bad register in UPT_SET : %d\n", reg); \
227 break; \ 228 break; \
@@ -245,14 +246,3 @@ struct syscall_args {
245 CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo)) 246 CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo))
246 247
247#endif 248#endif
248
249/*
250 * Overrides for Emacs so that we follow Linus's tabbing style.
251 * Emacs will notice this stuff at the end of the file and automatically
252 * adjust the settings for this buffer only. This must remain at the end
253 * of the file.
254 * ---------------------------------------------------------------------------
255 * Local variables:
256 * c-file-style: "linux"
257 * End:
258 */
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index 9736ca27c5f0..a8918e80df96 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -14,7 +14,7 @@ obj-y = config.o exec_kern.o exitcode.o \
14 tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o umid.o \ 14 tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o umid.o \
15 user_util.o 15 user_util.o
16 16
17obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o 17obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
18obj-$(CONFIG_GPROF) += gprof_syms.o 18obj-$(CONFIG_GPROF) += gprof_syms.o
19obj-$(CONFIG_GCOV) += gmon_syms.o 19obj-$(CONFIG_GCOV) += gmon_syms.o
20obj-$(CONFIG_TTY_LOG) += tty_log.o 20obj-$(CONFIG_TTY_LOG) += tty_log.o
diff --git a/arch/um/kernel/checksum.c b/arch/um/kernel/checksum.c
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/arch/um/kernel/checksum.c
+++ /dev/null
diff --git a/arch/um/kernel/initrd.c b/arch/um/kernel/initrd.c
new file mode 100644
index 000000000000..82ecf904b09c
--- /dev/null
+++ b/arch/um/kernel/initrd.c
@@ -0,0 +1,78 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include "linux/init.h"
7#include "linux/bootmem.h"
8#include "linux/initrd.h"
9#include "asm/types.h"
10#include "user_util.h"
11#include "kern_util.h"
12#include "initrd.h"
13#include "init.h"
14#include "os.h"
15
16/* Changed by uml_initrd_setup, which is a setup */
17static char *initrd __initdata = NULL;
18
19static int __init read_initrd(void)
20{
21 void *area;
22 long long size;
23 int err;
24
25 if(initrd == NULL) return 0;
26 err = os_file_size(initrd, &size);
27 if(err) return 0;
28 area = alloc_bootmem(size);
29 if(area == NULL) return 0;
30 if(load_initrd(initrd, area, size) == -1) return 0;
31 initrd_start = (unsigned long) area;
32 initrd_end = initrd_start + size;
33 return 0;
34}
35
36__uml_postsetup(read_initrd);
37
38static int __init uml_initrd_setup(char *line, int *add)
39{
40 initrd = line;
41 return 0;
42}
43
44__uml_setup("initrd=", uml_initrd_setup,
45"initrd=<initrd image>\n"
46" This is used to boot UML from an initrd image. The argument is the\n"
47" name of the file containing the image.\n\n"
48);
49
50int load_initrd(char *filename, void *buf, int size)
51{
52 int fd, n;
53
54 fd = os_open_file(filename, of_read(OPENFLAGS()), 0);
55 if(fd < 0){
56 printk("Opening '%s' failed - err = %d\n", filename, -fd);
57 return(-1);
58 }
59 n = os_read_file(fd, buf, size);
60 if(n != size){
61 printk("Read of %d bytes from '%s' failed, err = %d\n", size,
62 filename, -n);
63 return(-1);
64 }
65
66 os_close_file(fd);
67 return(0);
68}
69/*
70 * Overrides for Emacs so that we follow Linus's tabbing style.
71 * Emacs will notice this stuff at the end of the file and automatically
72 * adjust the settings for this buffer only. This must remain at the end
73 * of the file.
74 * ---------------------------------------------------------------------------
75 * Local variables:
76 * c-file-style: "linux"
77 * End:
78 */
diff --git a/arch/um/kernel/irq_user.c b/arch/um/kernel/irq_user.c
index 6d6f9484b884..b3074cbaa479 100644
--- a/arch/um/kernel/irq_user.c
+++ b/arch/um/kernel/irq_user.c
@@ -236,9 +236,15 @@ static void free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg)
236 (*prev)->fd, pollfds[i].fd); 236 (*prev)->fd, pollfds[i].fd);
237 goto out; 237 goto out;
238 } 238 }
239 memcpy(&pollfds[i], &pollfds[i + 1], 239
240 (pollfds_num - i - 1) * sizeof(pollfds[0]));
241 pollfds_num--; 240 pollfds_num--;
241
242 /* This moves the *whole* array after pollfds[i] (though
243 * it doesn't spot as such)! */
244
245 memmove(&pollfds[i], &pollfds[i + 1],
246 (pollfds_num - i) * sizeof(pollfds[0]));
247
242 if(last_irq_ptr == &old_fd->next) 248 if(last_irq_ptr == &old_fd->next)
243 last_irq_ptr = prev; 249 last_irq_ptr = prev;
244 *prev = (*prev)->next; 250 *prev = (*prev)->next;
diff --git a/arch/um/kernel/ksyms.c b/arch/um/kernel/ksyms.c
index 78d69dc74b26..99439fa15ef4 100644
--- a/arch/um/kernel/ksyms.c
+++ b/arch/um/kernel/ksyms.c
@@ -57,6 +57,7 @@ EXPORT_SYMBOL(copy_to_user_tt);
57EXPORT_SYMBOL(strncpy_from_user_skas); 57EXPORT_SYMBOL(strncpy_from_user_skas);
58EXPORT_SYMBOL(copy_to_user_skas); 58EXPORT_SYMBOL(copy_to_user_skas);
59EXPORT_SYMBOL(copy_from_user_skas); 59EXPORT_SYMBOL(copy_from_user_skas);
60EXPORT_SYMBOL(clear_user_skas);
60#endif 61#endif
61EXPORT_SYMBOL(uml_strdup); 62EXPORT_SYMBOL(uml_strdup);
62 63
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index f156661781cb..c22825f13e40 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -100,12 +100,37 @@ void mem_init(void)
100#endif 100#endif
101} 101}
102 102
103/*
104 * Create a page table and place a pointer to it in a middle page
105 * directory entry.
106 */
107static void __init one_page_table_init(pmd_t *pmd)
108{
109 if (pmd_none(*pmd)) {
110 pte_t *pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
111 set_pmd(pmd, __pmd(_KERNPG_TABLE +
112 (unsigned long) __pa(pte)));
113 if (pte != pte_offset_kernel(pmd, 0))
114 BUG();
115 }
116}
117
118static void __init one_md_table_init(pud_t *pud)
119{
120#ifdef CONFIG_3_LEVEL_PGTABLES
121 pmd_t *pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
122 set_pud(pud, __pud(_KERNPG_TABLE + (unsigned long) __pa(pmd_table)));
123 if (pmd_table != pmd_offset(pud, 0))
124 BUG();
125#endif
126}
127
103static void __init fixrange_init(unsigned long start, unsigned long end, 128static void __init fixrange_init(unsigned long start, unsigned long end,
104 pgd_t *pgd_base) 129 pgd_t *pgd_base)
105{ 130{
106 pgd_t *pgd; 131 pgd_t *pgd;
132 pud_t *pud;
107 pmd_t *pmd; 133 pmd_t *pmd;
108 pte_t *pte;
109 int i, j; 134 int i, j;
110 unsigned long vaddr; 135 unsigned long vaddr;
111 136
@@ -115,15 +140,12 @@ static void __init fixrange_init(unsigned long start, unsigned long end,
115 pgd = pgd_base + i; 140 pgd = pgd_base + i;
116 141
117 for ( ; (i < PTRS_PER_PGD) && (vaddr < end); pgd++, i++) { 142 for ( ; (i < PTRS_PER_PGD) && (vaddr < end); pgd++, i++) {
118 pmd = (pmd_t *)pgd; 143 pud = pud_offset(pgd, vaddr);
144 if (pud_none(*pud))
145 one_md_table_init(pud);
146 pmd = pmd_offset(pud, vaddr);
119 for (; (j < PTRS_PER_PMD) && (vaddr != end); pmd++, j++) { 147 for (; (j < PTRS_PER_PMD) && (vaddr != end); pmd++, j++) {
120 if (pmd_none(*pmd)) { 148 one_page_table_init(pmd);
121 pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
122 set_pmd(pmd, __pmd(_KERNPG_TABLE +
123 (unsigned long) __pa(pte)));
124 if (pte != pte_offset_kernel(pmd, 0))
125 BUG();
126 }
127 vaddr += PMD_SIZE; 149 vaddr += PMD_SIZE;
128 } 150 }
129 j = 0; 151 j = 0;
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 2b75d8d9ba73..2925e15324de 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -28,9 +28,9 @@ static inline void set_singlestepping(struct task_struct *child, int on)
28 child->thread.singlestep_syscall = 0; 28 child->thread.singlestep_syscall = 0;
29 29
30#ifdef SUBARCH_SET_SINGLESTEPPING 30#ifdef SUBARCH_SET_SINGLESTEPPING
31 SUBARCH_SET_SINGLESTEPPING(child, on) 31 SUBARCH_SET_SINGLESTEPPING(child, on);
32#endif 32#endif
33 } 33}
34 34
35/* 35/*
36 * Called by kernel/ptrace.c when detaching.. 36 * Called by kernel/ptrace.c when detaching..
@@ -83,7 +83,7 @@ long sys_ptrace(long request, long pid, long addr, long data)
83 } 83 }
84 84
85#ifdef SUBACH_PTRACE_SPECIAL 85#ifdef SUBACH_PTRACE_SPECIAL
86 SUBARCH_PTRACE_SPECIAL(child,request,addr,data) 86 SUBARCH_PTRACE_SPECIAL(child,request,addr,data);
87#endif 87#endif
88 88
89 ret = ptrace_check_attach(child, request == PTRACE_KILL); 89 ret = ptrace_check_attach(child, request == PTRACE_KILL);
diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c
index 5fca2c61eb98..1de22d8a313a 100644
--- a/arch/um/kernel/trap_kern.c
+++ b/arch/um/kernel/trap_kern.c
@@ -57,10 +57,11 @@ int handle_page_fault(unsigned long address, unsigned long ip,
57 *code_out = SEGV_ACCERR; 57 *code_out = SEGV_ACCERR;
58 if(is_write && !(vma->vm_flags & VM_WRITE)) 58 if(is_write && !(vma->vm_flags & VM_WRITE))
59 goto out; 59 goto out;
60
61 if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
62 goto out;
63
60 page = address & PAGE_MASK; 64 page = address & PAGE_MASK;
61 pgd = pgd_offset(mm, page);
62 pud = pud_offset(pgd, page);
63 pmd = pmd_offset(pud, page);
64 do { 65 do {
65 survive: 66 survive:
66 switch (handle_mm_fault(mm, vma, address, is_write)){ 67 switch (handle_mm_fault(mm, vma, address, is_write)){
@@ -106,33 +107,6 @@ out_of_memory:
106 goto out; 107 goto out;
107} 108}
108 109
109LIST_HEAD(physmem_remappers);
110
111void register_remapper(struct remapper *info)
112{
113 list_add(&info->list, &physmem_remappers);
114}
115
116static int check_remapped_addr(unsigned long address, int is_write)
117{
118 struct remapper *remapper;
119 struct list_head *ele;
120 __u64 offset;
121 int fd;
122
123 fd = phys_mapping(__pa(address), &offset);
124 if(fd == -1)
125 return(0);
126
127 list_for_each(ele, &physmem_remappers){
128 remapper = list_entry(ele, struct remapper, list);
129 if((*remapper->proc)(fd, address, is_write, offset))
130 return(1);
131 }
132
133 return(0);
134}
135
136/* 110/*
137 * We give a *copy* of the faultinfo in the regs to segv. 111 * We give a *copy* of the faultinfo in the regs to segv.
138 * This must be done, since nesting SEGVs could overwrite 112 * This must be done, since nesting SEGVs could overwrite
@@ -151,8 +125,6 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc)
151 flush_tlb_kernel_vm(); 125 flush_tlb_kernel_vm();
152 return(0); 126 return(0);
153 } 127 }
154 else if(check_remapped_addr(address & PAGE_MASK, is_write))
155 return(0);
156 else if(current->mm == NULL) 128 else if(current->mm == NULL)
157 panic("Segfault with no mm"); 129 panic("Segfault with no mm");
158 err = handle_page_fault(address, ip, is_write, is_user, &si.si_code); 130 err = handle_page_fault(address, ip, is_write, is_user, &si.si_code);
diff --git a/arch/um/kernel/tt/ksyms.c b/arch/um/kernel/tt/ksyms.c
index 92ec85d67c7c..84a9385a8fef 100644
--- a/arch/um/kernel/tt/ksyms.c
+++ b/arch/um/kernel/tt/ksyms.c
@@ -12,6 +12,7 @@ EXPORT_SYMBOL(__do_copy_to_user);
12EXPORT_SYMBOL(__do_strncpy_from_user); 12EXPORT_SYMBOL(__do_strncpy_from_user);
13EXPORT_SYMBOL(__do_strnlen_user); 13EXPORT_SYMBOL(__do_strnlen_user);
14EXPORT_SYMBOL(__do_clear_user); 14EXPORT_SYMBOL(__do_clear_user);
15EXPORT_SYMBOL(clear_user_tt);
15 16
16EXPORT_SYMBOL(tracing_pid); 17EXPORT_SYMBOL(tracing_pid);
17EXPORT_SYMBOL(honeypot); 18EXPORT_SYMBOL(honeypot);
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index 76eadb309189..dd5355500bdc 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -73,6 +73,8 @@ SECTIONS
73 73
74 .got : { *(.got.plt) *(.got) } 74 .got : { *(.got.plt) *(.got) }
75 .dynamic : { *(.dynamic) } 75 .dynamic : { *(.dynamic) }
76 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
77 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
76 /* We want the small data sections together, so single-instruction offsets 78 /* We want the small data sections together, so single-instruction offsets
77 can access them all, and initialized data all before uninitialized, so 79 can access them all, and initialized data all before uninitialized, so
78 we can shorten the on-disk segment size. */ 80 we can shorten the on-disk segment size. */
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile
index fcd67c3414e4..4351e5605506 100644
--- a/arch/um/sys-i386/Makefile
+++ b/arch/um/sys-i386/Makefile
@@ -9,11 +9,11 @@ USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o
9 9
10SYMLINKS = bitops.c semaphore.c highmem.c module.c 10SYMLINKS = bitops.c semaphore.c highmem.c module.c
11 11
12include arch/um/scripts/Makefile.rules
13
12bitops.c-dir = lib 14bitops.c-dir = lib
13semaphore.c-dir = kernel 15semaphore.c-dir = kernel
14highmem.c-dir = mm 16highmem.c-dir = mm
15module.c-dir = kernel 17module.c-dir = kernel
16 18
17subdir- := util 19subdir- := util
18
19include arch/um/scripts/Makefile.rules
diff --git a/arch/um/sys-i386/delay.c b/arch/um/sys-i386/delay.c
index e9892eef51ce..2c11b9770e8b 100644
--- a/arch/um/sys-i386/delay.c
+++ b/arch/um/sys-i386/delay.c
@@ -1,5 +1,7 @@
1#include "linux/delay.h" 1#include <linux/module.h>
2#include "asm/param.h" 2#include <linux/kernel.h>
3#include <linux/delay.h>
4#include <asm/param.h>
3 5
4void __delay(unsigned long time) 6void __delay(unsigned long time)
5{ 7{
@@ -20,13 +22,19 @@ void __udelay(unsigned long usecs)
20 int i, n; 22 int i, n;
21 23
22 n = (loops_per_jiffy * HZ * usecs) / MILLION; 24 n = (loops_per_jiffy * HZ * usecs) / MILLION;
23 for(i=0;i<n;i++) ; 25 for(i=0;i<n;i++)
26 cpu_relax();
24} 27}
25 28
29EXPORT_SYMBOL(__udelay);
30
26void __const_udelay(unsigned long usecs) 31void __const_udelay(unsigned long usecs)
27{ 32{
28 int i, n; 33 int i, n;
29 34
30 n = (loops_per_jiffy * HZ * usecs) / MILLION; 35 n = (loops_per_jiffy * HZ * usecs) / MILLION;
31 for(i=0;i<n;i++) ; 36 for(i=0;i<n;i++)
37 cpu_relax();
32} 38}
39
40EXPORT_SYMBOL(__const_udelay);
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile
index 3d7da911cc8c..608466ad6b22 100644
--- a/arch/um/sys-x86_64/Makefile
+++ b/arch/um/sys-x86_64/Makefile
@@ -14,11 +14,11 @@ obj-$(CONFIG_MODULES) += module.o um_module.o
14 14
15USER_OBJS := ptrace_user.o sigcontext.o 15USER_OBJS := ptrace_user.o sigcontext.o
16 16
17include arch/um/scripts/Makefile.rules
18
19SYMLINKS = bitops.c csum-copy.S csum-partial.c csum-wrappers.c memcpy.S \ 17SYMLINKS = bitops.c csum-copy.S csum-partial.c csum-wrappers.c memcpy.S \
20 semaphore.c thunk.S module.c 18 semaphore.c thunk.S module.c
21 19
20include arch/um/scripts/Makefile.rules
21
22bitops.c-dir = lib 22bitops.c-dir = lib
23csum-copy.S-dir = lib 23csum-copy.S-dir = lib
24csum-partial.c-dir = lib 24csum-partial.c-dir = lib
@@ -28,6 +28,4 @@ semaphore.c-dir = kernel
28thunk.S-dir = lib 28thunk.S-dir = lib
29module.c-dir = kernel 29module.c-dir = kernel
30 30
31CFLAGS_csum-partial.o := -Dcsum_partial=arch_csum_partial
32
33subdir- := util 31subdir- := util
diff --git a/arch/um/sys-x86_64/delay.c b/arch/um/sys-x86_64/delay.c
index 651332aeec22..137f4446b439 100644
--- a/arch/um/sys-x86_64/delay.c
+++ b/arch/um/sys-x86_64/delay.c
@@ -5,40 +5,37 @@
5 * Licensed under the GPL 5 * Licensed under the GPL
6 */ 6 */
7 7
8#include "linux/delay.h" 8#include <linux/module.h>
9#include "asm/processor.h" 9#include <linux/delay.h>
10#include "asm/param.h" 10#include <asm/processor.h>
11#include <asm/param.h>
11 12
12void __delay(unsigned long loops) 13void __delay(unsigned long loops)
13{ 14{
14 unsigned long i; 15 unsigned long i;
15 16
16 for(i = 0; i < loops; i++) ; 17 for(i = 0; i < loops; i++)
18 cpu_relax();
17} 19}
18 20
19void __udelay(unsigned long usecs) 21void __udelay(unsigned long usecs)
20{ 22{
21 int i, n; 23 unsigned long i, n;
22 24
23 n = (loops_per_jiffy * HZ * usecs) / MILLION; 25 n = (loops_per_jiffy * HZ * usecs) / MILLION;
24 for(i=0;i<n;i++) ; 26 for(i=0;i<n;i++)
27 cpu_relax();
25} 28}
26 29
30EXPORT_SYMBOL(__udelay);
31
27void __const_udelay(unsigned long usecs) 32void __const_udelay(unsigned long usecs)
28{ 33{
29 int i, n; 34 unsigned long i, n;
30 35
31 n = (loops_per_jiffy * HZ * usecs) / MILLION; 36 n = (loops_per_jiffy * HZ * usecs) / MILLION;
32 for(i=0;i<n;i++) ; 37 for(i=0;i<n;i++)
38 cpu_relax();
33} 39}
34 40
35/* 41EXPORT_SYMBOL(__const_udelay);
36 * Overrides for Emacs so that we follow Linus's tabbing style.
37 * Emacs will notice this stuff at the end of the file and automatically
38 * adjust the settings for this buffer only. This must remain at the end
39 * of the file.
40 * ---------------------------------------------------------------------------
41 * Local variables:
42 * c-file-style: "linux"
43 * End:
44 */
diff --git a/arch/um/sys-x86_64/ksyms.c b/arch/um/sys-x86_64/ksyms.c
index a27f0ee6a4f6..859273808203 100644
--- a/arch/um/sys-x86_64/ksyms.c
+++ b/arch/um/sys-x86_64/ksyms.c
@@ -16,5 +16,4 @@ EXPORT_SYMBOL(__up_wakeup);
16EXPORT_SYMBOL(__memcpy); 16EXPORT_SYMBOL(__memcpy);
17 17
18/* Networking helper routines. */ 18/* Networking helper routines. */
19/*EXPORT_SYMBOL(csum_partial_copy_from); 19EXPORT_SYMBOL(ip_compute_csum);
20EXPORT_SYMBOL(csum_partial_copy_to);*/
diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c
index b593bb256f2c..74eee5c7c6dd 100644
--- a/arch/um/sys-x86_64/ptrace.c
+++ b/arch/um/sys-x86_64/ptrace.c
@@ -5,10 +5,11 @@
5 */ 5 */
6 6
7#define __FRAME_OFFSETS 7#define __FRAME_OFFSETS
8#include "asm/ptrace.h" 8#include <asm/ptrace.h>
9#include "linux/sched.h" 9#include <linux/sched.h>
10#include "linux/errno.h" 10#include <linux/errno.h>
11#include "asm/elf.h" 11#include <asm/uaccess.h>
12#include <asm/elf.h>
12 13
13/* XXX x86_64 */ 14/* XXX x86_64 */
14unsigned long not_ss; 15unsigned long not_ss;
diff --git a/arch/um/sys-x86_64/syscalls.c b/arch/um/sys-x86_64/syscalls.c
index dd9914642b8e..d4a59657fb99 100644
--- a/arch/um/sys-x86_64/syscalls.c
+++ b/arch/um/sys-x86_64/syscalls.c
@@ -15,6 +15,7 @@
15#include "asm/unistd.h" 15#include "asm/unistd.h"
16#include "asm/prctl.h" /* XXX This should get the constants from libc */ 16#include "asm/prctl.h" /* XXX This should get the constants from libc */
17#include "choose-mode.h" 17#include "choose-mode.h"
18#include "kern.h"
18 19
19asmlinkage long sys_uname64(struct new_utsname __user * name) 20asmlinkage long sys_uname64(struct new_utsname __user * name)
20{ 21{
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c
index 5e14792e4838..513d17ceafd4 100644
--- a/arch/um/sys-x86_64/user-offsets.c
+++ b/arch/um/sys-x86_64/user-offsets.c
@@ -3,6 +3,14 @@
3#include <signal.h> 3#include <signal.h>
4#define __FRAME_OFFSETS 4#define __FRAME_OFFSETS
5#include <asm/ptrace.h> 5#include <asm/ptrace.h>
6#include <asm/types.h>
7/* For some reason, x86_64 defines u64 and u32 only in <pci/types.h>, which I
8 * refuse to include here, even though they're used throughout the headers.
9 * These are used in asm/user.h, and that include can't be avoided because of
10 * the sizeof(struct user_regs_struct) below.
11 */
12typedef __u64 u64;
13typedef __u32 u32;
6#include <asm/user.h> 14#include <asm/user.h>
7 15
8#define DEFINE(sym, val) \ 16#define DEFINE(sym, val) \
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 44ee7f6acf7b..0f430d9d3632 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -303,6 +303,20 @@ config HPET_TIMER
303 as it is off-chip. You can find the HPET spec at 303 as it is off-chip. You can find the HPET spec at
304 <http://www.intel.com/labs/platcomp/hpet/hpetspec.htm>. 304 <http://www.intel.com/labs/platcomp/hpet/hpetspec.htm>.
305 305
306config X86_PM_TIMER
307 bool "PM timer"
308 default y
309 help
310 Support the ACPI PM timer for time keeping. This is slow,
311 but is useful on some chipsets without HPET on systems with more
312 than one CPU. On a single processor or single socket multi core
313 system it is normally not required.
314 When the PM timer is active 64bit vsyscalls are disabled
315 and should not be enabled (/proc/sys/kernel/vsyscall64 should
316 not be changed).
317 The kernel selects the PM timer only as a last resort, so it is
318 useful to enable just in case.
319
306config HPET_EMULATE_RTC 320config HPET_EMULATE_RTC
307 bool "Provide RTC interrupt" 321 bool "Provide RTC interrupt"
308 depends on HPET_TIMER && RTC=y 322 depends on HPET_TIMER && RTC=y
@@ -407,7 +421,7 @@ config PCI_DIRECT
407 421
408config PCI_MMCONFIG 422config PCI_MMCONFIG
409 bool "Support mmconfig PCI config space access" 423 bool "Support mmconfig PCI config space access"
410 depends on PCI 424 depends on PCI && ACPI
411 select ACPI_BOOT 425 select ACPI_BOOT
412 426
413config UNORDERED_IO 427config UNORDERED_IO
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index 9ce51dee30b3..569595b74c7c 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.11-bk7 3# Linux kernel version: 2.6.12-rc4
4# Sat Mar 12 23:43:44 2005 4# Fri May 13 06:39:11 2005
5# 5#
6CONFIG_X86_64=y 6CONFIG_X86_64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
@@ -11,8 +11,6 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
11CONFIG_GENERIC_CALIBRATE_DELAY=y 11CONFIG_GENERIC_CALIBRATE_DELAY=y
12CONFIG_X86_CMPXCHG=y 12CONFIG_X86_CMPXCHG=y
13CONFIG_EARLY_PRINTK=y 13CONFIG_EARLY_PRINTK=y
14CONFIG_HPET_TIMER=y
15CONFIG_HPET_EMULATE_RTC=y
16CONFIG_GENERIC_ISA_DMA=y 14CONFIG_GENERIC_ISA_DMA=y
17CONFIG_GENERIC_IOMAP=y 15CONFIG_GENERIC_IOMAP=y
18 16
@@ -22,6 +20,7 @@ CONFIG_GENERIC_IOMAP=y
22CONFIG_EXPERIMENTAL=y 20CONFIG_EXPERIMENTAL=y
23CONFIG_CLEAN_COMPILE=y 21CONFIG_CLEAN_COMPILE=y
24CONFIG_LOCK_KERNEL=y 22CONFIG_LOCK_KERNEL=y
23CONFIG_INIT_ENV_ARG_LIMIT=32
25 24
26# 25#
27# General setup 26# General setup
@@ -33,7 +32,6 @@ CONFIG_POSIX_MQUEUE=y
33# CONFIG_BSD_PROCESS_ACCT is not set 32# CONFIG_BSD_PROCESS_ACCT is not set
34CONFIG_SYSCTL=y 33CONFIG_SYSCTL=y
35# CONFIG_AUDIT is not set 34# CONFIG_AUDIT is not set
36CONFIG_LOG_BUF_SHIFT=18
37# CONFIG_HOTPLUG is not set 35# CONFIG_HOTPLUG is not set
38CONFIG_KOBJECT_UEVENT=y 36CONFIG_KOBJECT_UEVENT=y
39CONFIG_IKCONFIG=y 37CONFIG_IKCONFIG=y
@@ -43,10 +41,11 @@ CONFIG_IKCONFIG_PROC=y
43CONFIG_KALLSYMS=y 41CONFIG_KALLSYMS=y
44CONFIG_KALLSYMS_ALL=y 42CONFIG_KALLSYMS_ALL=y
45# CONFIG_KALLSYMS_EXTRA_PASS is not set 43# CONFIG_KALLSYMS_EXTRA_PASS is not set
44CONFIG_PRINTK=y
45CONFIG_BUG=y
46CONFIG_BASE_FULL=y 46CONFIG_BASE_FULL=y
47CONFIG_FUTEX=y 47CONFIG_FUTEX=y
48CONFIG_EPOLL=y 48CONFIG_EPOLL=y
49# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
50CONFIG_SHMEM=y 49CONFIG_SHMEM=y
51CONFIG_CC_ALIGN_FUNCTIONS=0 50CONFIG_CC_ALIGN_FUNCTIONS=0
52CONFIG_CC_ALIGN_LABELS=0 51CONFIG_CC_ALIGN_LABELS=0
@@ -93,6 +92,9 @@ CONFIG_DISCONTIGMEM=y
93CONFIG_NUMA=y 92CONFIG_NUMA=y
94CONFIG_HAVE_DEC_LOCK=y 93CONFIG_HAVE_DEC_LOCK=y
95CONFIG_NR_CPUS=8 94CONFIG_NR_CPUS=8
95CONFIG_HPET_TIMER=y
96CONFIG_X86_PM_TIMER=y
97CONFIG_HPET_EMULATE_RTC=y
96CONFIG_GART_IOMMU=y 98CONFIG_GART_IOMMU=y
97CONFIG_SWIOTLB=y 99CONFIG_SWIOTLB=y
98CONFIG_X86_MCE=y 100CONFIG_X86_MCE=y
@@ -100,6 +102,7 @@ CONFIG_X86_MCE_INTEL=y
100CONFIG_SECCOMP=y 102CONFIG_SECCOMP=y
101CONFIG_GENERIC_HARDIRQS=y 103CONFIG_GENERIC_HARDIRQS=y
102CONFIG_GENERIC_IRQ_PROBE=y 104CONFIG_GENERIC_IRQ_PROBE=y
105CONFIG_ISA_DMA_API=y
103 106
104# 107#
105# Power management options 108# Power management options
@@ -129,7 +132,7 @@ CONFIG_ACPI_NUMA=y
129# CONFIG_ACPI_IBM is not set 132# CONFIG_ACPI_IBM is not set
130CONFIG_ACPI_TOSHIBA=y 133CONFIG_ACPI_TOSHIBA=y
131CONFIG_ACPI_BLACKLIST_YEAR=2001 134CONFIG_ACPI_BLACKLIST_YEAR=2001
132CONFIG_ACPI_DEBUG=y 135# CONFIG_ACPI_DEBUG is not set
133CONFIG_ACPI_BUS=y 136CONFIG_ACPI_BUS=y
134CONFIG_ACPI_EC=y 137CONFIG_ACPI_EC=y
135CONFIG_ACPI_POWER=y 138CONFIG_ACPI_POWER=y
@@ -141,6 +144,7 @@ CONFIG_ACPI_SYSTEM=y
141# CPU Frequency scaling 144# CPU Frequency scaling
142# 145#
143CONFIG_CPU_FREQ=y 146CONFIG_CPU_FREQ=y
147CONFIG_CPU_FREQ_TABLE=y
144# CONFIG_CPU_FREQ_DEBUG is not set 148# CONFIG_CPU_FREQ_DEBUG is not set
145CONFIG_CPU_FREQ_STAT=y 149CONFIG_CPU_FREQ_STAT=y
146# CONFIG_CPU_FREQ_STAT_DETAILS is not set 150# CONFIG_CPU_FREQ_STAT_DETAILS is not set
@@ -150,7 +154,6 @@ CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
150# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set 154# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
151CONFIG_CPU_FREQ_GOV_USERSPACE=y 155CONFIG_CPU_FREQ_GOV_USERSPACE=y
152CONFIG_CPU_FREQ_GOV_ONDEMAND=y 156CONFIG_CPU_FREQ_GOV_ONDEMAND=y
153CONFIG_CPU_FREQ_TABLE=y
154 157
155# 158#
156# CPUFreq processor drivers 159# CPUFreq processor drivers
@@ -164,6 +167,7 @@ CONFIG_X86_ACPI_CPUFREQ=y
164# shared options 167# shared options
165# 168#
166CONFIG_X86_ACPI_CPUFREQ_PROC_INTF=y 169CONFIG_X86_ACPI_CPUFREQ_PROC_INTF=y
170# CONFIG_X86_SPEEDSTEP_LIB is not set
167 171
168# 172#
169# Bus options (PCI etc.) 173# Bus options (PCI etc.)
@@ -172,9 +176,11 @@ CONFIG_PCI=y
172CONFIG_PCI_DIRECT=y 176CONFIG_PCI_DIRECT=y
173CONFIG_PCI_MMCONFIG=y 177CONFIG_PCI_MMCONFIG=y
174CONFIG_UNORDERED_IO=y 178CONFIG_UNORDERED_IO=y
179# CONFIG_PCIEPORTBUS is not set
175CONFIG_PCI_MSI=y 180CONFIG_PCI_MSI=y
176# CONFIG_PCI_LEGACY_PROC is not set 181# CONFIG_PCI_LEGACY_PROC is not set
177# CONFIG_PCI_NAMES is not set 182# CONFIG_PCI_NAMES is not set
183# CONFIG_PCI_DEBUG is not set
178 184
179# 185#
180# PCCARD (PCMCIA/CardBus) support 186# PCCARD (PCMCIA/CardBus) support
@@ -182,10 +188,6 @@ CONFIG_PCI_MSI=y
182# CONFIG_PCCARD is not set 188# CONFIG_PCCARD is not set
183 189
184# 190#
185# PC-card bridges
186#
187
188#
189# PCI Hotplug Support 191# PCI Hotplug Support
190# 192#
191# CONFIG_HOTPLUG_PCI is not set 193# CONFIG_HOTPLUG_PCI is not set
@@ -254,7 +256,7 @@ CONFIG_LBD=y
254# IO Schedulers 256# IO Schedulers
255# 257#
256CONFIG_IOSCHED_NOOP=y 258CONFIG_IOSCHED_NOOP=y
257CONFIG_IOSCHED_AS=y 259# CONFIG_IOSCHED_AS is not set
258CONFIG_IOSCHED_DEADLINE=y 260CONFIG_IOSCHED_DEADLINE=y
259CONFIG_IOSCHED_CFQ=y 261CONFIG_IOSCHED_CFQ=y
260# CONFIG_ATA_OVER_ETH is not set 262# CONFIG_ATA_OVER_ETH is not set
@@ -308,7 +310,8 @@ CONFIG_BLK_DEV_AMD74XX=y
308CONFIG_BLK_DEV_PIIX=y 310CONFIG_BLK_DEV_PIIX=y
309# CONFIG_BLK_DEV_NS87415 is not set 311# CONFIG_BLK_DEV_NS87415 is not set
310# CONFIG_BLK_DEV_PDC202XX_OLD is not set 312# CONFIG_BLK_DEV_PDC202XX_OLD is not set
311# CONFIG_BLK_DEV_PDC202XX_NEW is not set 313CONFIG_BLK_DEV_PDC202XX_NEW=y
314# CONFIG_PDC202XX_FORCE is not set
312# CONFIG_BLK_DEV_SVWKS is not set 315# CONFIG_BLK_DEV_SVWKS is not set
313# CONFIG_BLK_DEV_SIIMAGE is not set 316# CONFIG_BLK_DEV_SIIMAGE is not set
314# CONFIG_BLK_DEV_SIS5513 is not set 317# CONFIG_BLK_DEV_SIS5513 is not set
@@ -353,7 +356,7 @@ CONFIG_BLK_DEV_SD=y
353# 356#
354# SCSI low-level drivers 357# SCSI low-level drivers
355# 358#
356CONFIG_BLK_DEV_3W_XXXX_RAID=y 359# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
357# CONFIG_SCSI_3W_9XXX is not set 360# CONFIG_SCSI_3W_9XXX is not set
358# CONFIG_SCSI_ACARD is not set 361# CONFIG_SCSI_ACARD is not set
359# CONFIG_SCSI_AACRAID is not set 362# CONFIG_SCSI_AACRAID is not set
@@ -384,7 +387,6 @@ CONFIG_SCSI_SATA_VIA=y
384# CONFIG_SCSI_BUSLOGIC is not set 387# CONFIG_SCSI_BUSLOGIC is not set
385# CONFIG_SCSI_DMX3191D is not set 388# CONFIG_SCSI_DMX3191D is not set
386# CONFIG_SCSI_EATA is not set 389# CONFIG_SCSI_EATA is not set
387# CONFIG_SCSI_EATA_PIO is not set
388# CONFIG_SCSI_FUTURE_DOMAIN is not set 390# CONFIG_SCSI_FUTURE_DOMAIN is not set
389# CONFIG_SCSI_GDTH is not set 391# CONFIG_SCSI_GDTH is not set
390# CONFIG_SCSI_IPS is not set 392# CONFIG_SCSI_IPS is not set
@@ -392,7 +394,6 @@ CONFIG_SCSI_SATA_VIA=y
392# CONFIG_SCSI_INIA100 is not set 394# CONFIG_SCSI_INIA100 is not set
393# CONFIG_SCSI_SYM53C8XX_2 is not set 395# CONFIG_SCSI_SYM53C8XX_2 is not set
394# CONFIG_SCSI_IPR is not set 396# CONFIG_SCSI_IPR is not set
395# CONFIG_SCSI_QLOGIC_ISP is not set
396# CONFIG_SCSI_QLOGIC_FC is not set 397# CONFIG_SCSI_QLOGIC_FC is not set
397# CONFIG_SCSI_QLOGIC_1280 is not set 398# CONFIG_SCSI_QLOGIC_1280 is not set
398CONFIG_SCSI_QLA2XXX=y 399CONFIG_SCSI_QLA2XXX=y
@@ -401,6 +402,7 @@ CONFIG_SCSI_QLA2XXX=y
401# CONFIG_SCSI_QLA2300 is not set 402# CONFIG_SCSI_QLA2300 is not set
402# CONFIG_SCSI_QLA2322 is not set 403# CONFIG_SCSI_QLA2322 is not set
403# CONFIG_SCSI_QLA6312 is not set 404# CONFIG_SCSI_QLA6312 is not set
405# CONFIG_SCSI_LPFC is not set
404# CONFIG_SCSI_DC395x is not set 406# CONFIG_SCSI_DC395x is not set
405# CONFIG_SCSI_DC390T is not set 407# CONFIG_SCSI_DC390T is not set
406# CONFIG_SCSI_DEBUG is not set 408# CONFIG_SCSI_DEBUG is not set
@@ -437,7 +439,6 @@ CONFIG_NET=y
437# 439#
438CONFIG_PACKET=y 440CONFIG_PACKET=y
439# CONFIG_PACKET_MMAP is not set 441# CONFIG_PACKET_MMAP is not set
440# CONFIG_NETLINK_DEV is not set
441CONFIG_UNIX=y 442CONFIG_UNIX=y
442# CONFIG_NET_KEY is not set 443# CONFIG_NET_KEY is not set
443CONFIG_INET=y 444CONFIG_INET=y
@@ -502,7 +503,7 @@ CONFIG_NETDEVICES=y
502# CONFIG_DUMMY is not set 503# CONFIG_DUMMY is not set
503# CONFIG_BONDING is not set 504# CONFIG_BONDING is not set
504# CONFIG_EQUALIZER is not set 505# CONFIG_EQUALIZER is not set
505# CONFIG_TUN is not set 506CONFIG_TUN=y
506 507
507# 508#
508# ARCnet devices 509# ARCnet devices
@@ -525,8 +526,7 @@ CONFIG_MII=y
525# CONFIG_HP100 is not set 526# CONFIG_HP100 is not set
526CONFIG_NET_PCI=y 527CONFIG_NET_PCI=y
527# CONFIG_PCNET32 is not set 528# CONFIG_PCNET32 is not set
528CONFIG_AMD8111_ETH=y 529# CONFIG_AMD8111_ETH is not set
529# CONFIG_AMD8111E_NAPI is not set
530# CONFIG_ADAPTEC_STARFIRE is not set 530# CONFIG_ADAPTEC_STARFIRE is not set
531# CONFIG_B44 is not set 531# CONFIG_B44 is not set
532CONFIG_FORCEDETH=y 532CONFIG_FORCEDETH=y
@@ -536,7 +536,7 @@ CONFIG_FORCEDETH=y
536# CONFIG_FEALNX is not set 536# CONFIG_FEALNX is not set
537# CONFIG_NATSEMI is not set 537# CONFIG_NATSEMI is not set
538# CONFIG_NE2K_PCI is not set 538# CONFIG_NE2K_PCI is not set
539CONFIG_8139CP=m 539CONFIG_8139CP=y
540CONFIG_8139TOO=y 540CONFIG_8139TOO=y
541# CONFIG_8139TOO_PIO is not set 541# CONFIG_8139TOO_PIO is not set
542# CONFIG_8139TOO_TUNE_TWISTER is not set 542# CONFIG_8139TOO_TUNE_TWISTER is not set
@@ -671,6 +671,7 @@ CONFIG_SERIAL_8250_NR_UARTS=4
671# 671#
672CONFIG_SERIAL_CORE=y 672CONFIG_SERIAL_CORE=y
673CONFIG_SERIAL_CORE_CONSOLE=y 673CONFIG_SERIAL_CORE_CONSOLE=y
674# CONFIG_SERIAL_JSM is not set
674CONFIG_UNIX98_PTYS=y 675CONFIG_UNIX98_PTYS=y
675CONFIG_LEGACY_PTYS=y 676CONFIG_LEGACY_PTYS=y
676CONFIG_LEGACY_PTY_COUNT=256 677CONFIG_LEGACY_PTY_COUNT=256
@@ -696,6 +697,7 @@ CONFIG_RTC=y
696# 697#
697CONFIG_AGP=y 698CONFIG_AGP=y
698CONFIG_AGP_AMD64=y 699CONFIG_AGP_AMD64=y
700CONFIG_AGP_INTEL=y
699# CONFIG_DRM is not set 701# CONFIG_DRM is not set
700# CONFIG_MWAVE is not set 702# CONFIG_MWAVE is not set
701CONFIG_RAW_DRIVER=y 703CONFIG_RAW_DRIVER=y
@@ -703,7 +705,7 @@ CONFIG_HPET=y
703# CONFIG_HPET_RTC_IRQ is not set 705# CONFIG_HPET_RTC_IRQ is not set
704CONFIG_HPET_MMAP=y 706CONFIG_HPET_MMAP=y
705CONFIG_MAX_RAW_DEVS=256 707CONFIG_MAX_RAW_DEVS=256
706CONFIG_HANGCHECK_TIMER=y 708# CONFIG_HANGCHECK_TIMER is not set
707 709
708# 710#
709# TPM devices 711# TPM devices
@@ -786,6 +788,8 @@ CONFIG_SOUND_ICH=y
786# 788#
787# USB support 789# USB support
788# 790#
791CONFIG_USB_ARCH_HAS_HCD=y
792CONFIG_USB_ARCH_HAS_OHCI=y
789CONFIG_USB=y 793CONFIG_USB=y
790# CONFIG_USB_DEBUG is not set 794# CONFIG_USB_DEBUG is not set
791 795
@@ -797,8 +801,6 @@ CONFIG_USB_DEVICEFS=y
797# CONFIG_USB_DYNAMIC_MINORS is not set 801# CONFIG_USB_DYNAMIC_MINORS is not set
798# CONFIG_USB_SUSPEND is not set 802# CONFIG_USB_SUSPEND is not set
799# CONFIG_USB_OTG is not set 803# CONFIG_USB_OTG is not set
800CONFIG_USB_ARCH_HAS_HCD=y
801CONFIG_USB_ARCH_HAS_OHCI=y
802 804
803# 805#
804# USB Host Controller Drivers 806# USB Host Controller Drivers
@@ -826,7 +828,6 @@ CONFIG_USB_PRINTER=y
826# 828#
827CONFIG_USB_STORAGE=y 829CONFIG_USB_STORAGE=y
828# CONFIG_USB_STORAGE_DEBUG is not set 830# CONFIG_USB_STORAGE_DEBUG is not set
829# CONFIG_USB_STORAGE_RW_DETECT is not set
830# CONFIG_USB_STORAGE_DATAFAB is not set 831# CONFIG_USB_STORAGE_DATAFAB is not set
831# CONFIG_USB_STORAGE_FREECOM is not set 832# CONFIG_USB_STORAGE_FREECOM is not set
832# CONFIG_USB_STORAGE_ISD200 is not set 833# CONFIG_USB_STORAGE_ISD200 is not set
@@ -965,7 +966,7 @@ CONFIG_AUTOFS_FS=y
965# CD-ROM/DVD Filesystems 966# CD-ROM/DVD Filesystems
966# 967#
967CONFIG_ISO9660_FS=y 968CONFIG_ISO9660_FS=y
968# CONFIG_JOLIET is not set 969CONFIG_JOLIET=y
969# CONFIG_ZISOFS is not set 970# CONFIG_ZISOFS is not set
970# CONFIG_UDF_FS is not set 971# CONFIG_UDF_FS is not set
971 972
@@ -1092,9 +1093,10 @@ CONFIG_OPROFILE=y
1092# 1093#
1093# Kernel hacking 1094# Kernel hacking
1094# 1095#
1096# CONFIG_PRINTK_TIME is not set
1095CONFIG_DEBUG_KERNEL=y 1097CONFIG_DEBUG_KERNEL=y
1096CONFIG_MAGIC_SYSRQ=y 1098CONFIG_MAGIC_SYSRQ=y
1097# CONFIG_PRINTK_TIME is not set 1099CONFIG_LOG_BUF_SHIFT=18
1098# CONFIG_SCHEDSTATS is not set 1100# CONFIG_SCHEDSTATS is not set
1099# CONFIG_DEBUG_SLAB is not set 1101# CONFIG_DEBUG_SLAB is not set
1100# CONFIG_DEBUG_SPINLOCK is not set 1102# CONFIG_DEBUG_SPINLOCK is not set
diff --git a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile
index 0a3318e08ab6..5ca4a4598fda 100644
--- a/arch/x86_64/kernel/Makefile
+++ b/arch/x86_64/kernel/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_GART_IOMMU) += pci-gart.o aperture.o
28obj-$(CONFIG_DUMMY_IOMMU) += pci-nommu.o pci-dma.o 28obj-$(CONFIG_DUMMY_IOMMU) += pci-nommu.o pci-dma.o
29obj-$(CONFIG_SWIOTLB) += swiotlb.o 29obj-$(CONFIG_SWIOTLB) += swiotlb.o
30obj-$(CONFIG_KPROBES) += kprobes.o 30obj-$(CONFIG_KPROBES) += kprobes.o
31obj-$(CONFIG_X86_PM_TIMER) += pmtimer.o
31 32
32obj-$(CONFIG_MODULES) += module.o 33obj-$(CONFIG_MODULES) += module.o
33 34
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index 7e13545748e0..f8e6cc4fecd4 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -33,6 +33,7 @@
33#include <asm/mpspec.h> 33#include <asm/mpspec.h>
34#include <asm/pgalloc.h> 34#include <asm/pgalloc.h>
35#include <asm/mach_apic.h> 35#include <asm/mach_apic.h>
36#include <asm/nmi.h>
36 37
37int apic_verbosity; 38int apic_verbosity;
38 39
@@ -925,7 +926,7 @@ __init int oem_force_hpet_timer(void)
925 unsigned id; 926 unsigned id;
926 DECLARE_BITMAP(clustermap, NUM_APIC_CLUSTERS); 927 DECLARE_BITMAP(clustermap, NUM_APIC_CLUSTERS);
927 928
928 bitmap_empty(clustermap, NUM_APIC_CLUSTERS); 929 bitmap_zero(clustermap, NUM_APIC_CLUSTERS);
929 930
930 for (i = 0; i < NR_CPUS; i++) { 931 for (i = 0; i < NR_CPUS; i++) {
931 id = bios_cpu_apicid[i]; 932 id = bios_cpu_apicid[i];
@@ -1056,7 +1057,7 @@ int __init APIC_init_uniprocessor (void)
1056 nr_ioapics = 0; 1057 nr_ioapics = 0;
1057#endif 1058#endif
1058 setup_boot_APIC_clock(); 1059 setup_boot_APIC_clock();
1059 1060 check_nmi_watchdog();
1060 return 0; 1061 return 0;
1061} 1062}
1062 1063
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 1086b5fcac21..28817490fdc6 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -220,13 +220,18 @@ sysret_careful:
220 jmp sysret_check 220 jmp sysret_check
221 221
222 /* Handle a signal */ 222 /* Handle a signal */
223 /* edx: work flags (arg3) */
224sysret_signal: 223sysret_signal:
225 sti 224 sti
225 testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP),%edx
226 jz 1f
227
228 /* Really a signal */
229 /* edx: work flags (arg3) */
226 leaq do_notify_resume(%rip),%rax 230 leaq do_notify_resume(%rip),%rax
227 leaq -ARGOFFSET(%rsp),%rdi # &pt_regs -> arg1 231 leaq -ARGOFFSET(%rsp),%rdi # &pt_regs -> arg1
228 xorl %esi,%esi # oldset -> arg2 232 xorl %esi,%esi # oldset -> arg2
229 call ptregscall_common 233 call ptregscall_common
2341: movl $_TIF_NEED_RESCHED,%edi
230 jmp sysret_check 235 jmp sysret_check
231 236
232 /* Do syscall tracing */ 237 /* Do syscall tracing */
@@ -484,6 +489,8 @@ retint_careful:
484 jmp retint_check 489 jmp retint_check
485 490
486retint_signal: 491retint_signal:
492 testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP),%edx
493 jz retint_swapgs
487 sti 494 sti
488 SAVE_REST 495 SAVE_REST
489 movq $-1,ORIG_RAX(%rsp) 496 movq $-1,ORIG_RAX(%rsp)
@@ -492,8 +499,8 @@ retint_signal:
492 call do_notify_resume 499 call do_notify_resume
493 RESTORE_REST 500 RESTORE_REST
494 cli 501 cli
502 movl $_TIF_NEED_RESCHED,%edi
495 GET_THREAD_INFO(%rcx) 503 GET_THREAD_INFO(%rcx)
496 movl $_TIF_WORK_MASK,%edi
497 jmp retint_check 504 jmp retint_check
498 505
499#ifdef CONFIG_PREEMPT 506#ifdef CONFIG_PREEMPT
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index 60be58617eb9..80e9b498c443 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -42,6 +42,8 @@
42 42
43int sis_apic_bug; /* not actually supported, dummy for compile */ 43int sis_apic_bug; /* not actually supported, dummy for compile */
44 44
45static int no_timer_check;
46
45static DEFINE_SPINLOCK(ioapic_lock); 47static DEFINE_SPINLOCK(ioapic_lock);
46 48
47/* 49/*
@@ -1601,7 +1603,7 @@ static inline void check_timer(void)
1601 * Ok, does IRQ0 through the IOAPIC work? 1603 * Ok, does IRQ0 through the IOAPIC work?
1602 */ 1604 */
1603 unmask_IO_APIC_irq(0); 1605 unmask_IO_APIC_irq(0);
1604 if (timer_irq_works()) { 1606 if (!no_timer_check && timer_irq_works()) {
1605 nmi_watchdog_default(); 1607 nmi_watchdog_default();
1606 if (nmi_watchdog == NMI_IO_APIC) { 1608 if (nmi_watchdog == NMI_IO_APIC) {
1607 disable_8259A_irq(0); 1609 disable_8259A_irq(0);
@@ -1671,6 +1673,13 @@ static inline void check_timer(void)
1671 panic("IO-APIC + timer doesn't work! Try using the 'noapic' kernel parameter\n"); 1673 panic("IO-APIC + timer doesn't work! Try using the 'noapic' kernel parameter\n");
1672} 1674}
1673 1675
1676static int __init notimercheck(char *s)
1677{
1678 no_timer_check = 1;
1679 return 1;
1680}
1681__setup("no_timer_check", notimercheck);
1682
1674/* 1683/*
1675 * 1684 *
1676 * IRQ's that are handled by the PIC in the MPS IOAPIC case. 1685 * IRQ's that are handled by the PIC in the MPS IOAPIC case.
@@ -1804,76 +1813,6 @@ device_initcall(ioapic_init_sysfs);
1804 1813
1805#define IO_APIC_MAX_ID 0xFE 1814#define IO_APIC_MAX_ID 0xFE
1806 1815
1807int __init io_apic_get_unique_id (int ioapic, int apic_id)
1808{
1809 union IO_APIC_reg_00 reg_00;
1810 static physid_mask_t apic_id_map;
1811 unsigned long flags;
1812 int i = 0;
1813
1814 /*
1815 * The P4 platform supports up to 256 APIC IDs on two separate APIC
1816 * buses (one for LAPICs, one for IOAPICs), where predecessors only
1817 * supports up to 16 on one shared APIC bus.
1818 *
1819 * TBD: Expand LAPIC/IOAPIC support on P4-class systems to take full
1820 * advantage of new APIC bus architecture.
1821 */
1822
1823 if (physids_empty(apic_id_map))
1824 apic_id_map = phys_cpu_present_map;
1825
1826 spin_lock_irqsave(&ioapic_lock, flags);
1827 reg_00.raw = io_apic_read(ioapic, 0);
1828 spin_unlock_irqrestore(&ioapic_lock, flags);
1829
1830 if (apic_id >= IO_APIC_MAX_ID) {
1831 apic_printk(APIC_QUIET, KERN_WARNING "IOAPIC[%d]: Invalid apic_id %d, trying "
1832 "%d\n", ioapic, apic_id, reg_00.bits.ID);
1833 apic_id = reg_00.bits.ID;
1834 }
1835
1836 /*
1837 * Every APIC in a system must have a unique ID or we get lots of nice
1838 * 'stuck on smp_invalidate_needed IPI wait' messages.
1839 */
1840 if (physid_isset(apic_id, apic_id_map)) {
1841
1842 for (i = 0; i < IO_APIC_MAX_ID; i++) {
1843 if (!physid_isset(i, apic_id_map))
1844 break;
1845 }
1846
1847 if (i == IO_APIC_MAX_ID)
1848 panic("Max apic_id exceeded!\n");
1849
1850 apic_printk(APIC_VERBOSE, KERN_WARNING "IOAPIC[%d]: apic_id %d already used, "
1851 "trying %d\n", ioapic, apic_id, i);
1852
1853 apic_id = i;
1854 }
1855
1856 physid_set(apic_id, apic_id_map);
1857
1858 if (reg_00.bits.ID != apic_id) {
1859 reg_00.bits.ID = apic_id;
1860
1861 spin_lock_irqsave(&ioapic_lock, flags);
1862 io_apic_write(ioapic, 0, reg_00.raw);
1863 reg_00.raw = io_apic_read(ioapic, 0);
1864 spin_unlock_irqrestore(&ioapic_lock, flags);
1865
1866 /* Sanity check */
1867 if (reg_00.bits.ID != apic_id)
1868 panic("IOAPIC[%d]: Unable change apic_id!\n", ioapic);
1869 }
1870
1871 apic_printk(APIC_VERBOSE,KERN_INFO "IOAPIC[%d]: Assigned apic_id %d\n", ioapic, apic_id);
1872
1873 return apic_id;
1874}
1875
1876
1877int __init io_apic_get_version (int ioapic) 1816int __init io_apic_get_version (int ioapic)
1878{ 1817{
1879 union IO_APIC_reg_01 reg_01; 1818 union IO_APIC_reg_01 reg_01;
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
index 7ec031c6ca10..f86d9db94bfc 100644
--- a/arch/x86_64/kernel/mpparse.c
+++ b/arch/x86_64/kernel/mpparse.c
@@ -107,6 +107,7 @@ static int __init mpf_checksum(unsigned char *mp, int len)
107static void __init MP_processor_info (struct mpc_config_processor *m) 107static void __init MP_processor_info (struct mpc_config_processor *m)
108{ 108{
109 int ver; 109 int ver;
110 static int found_bsp=0;
110 111
111 if (!(m->mpc_cpuflag & CPU_ENABLED)) 112 if (!(m->mpc_cpuflag & CPU_ENABLED))
112 return; 113 return;
@@ -126,11 +127,6 @@ static void __init MP_processor_info (struct mpc_config_processor *m)
126 " Processor ignored.\n", NR_CPUS); 127 " Processor ignored.\n", NR_CPUS);
127 return; 128 return;
128 } 129 }
129 if (num_processors >= maxcpus) {
130 printk(KERN_WARNING "WARNING: maxcpus limit of %i reached."
131 " Processor ignored.\n", maxcpus);
132 return;
133 }
134 130
135 num_processors++; 131 num_processors++;
136 132
@@ -150,7 +146,19 @@ static void __init MP_processor_info (struct mpc_config_processor *m)
150 ver = 0x10; 146 ver = 0x10;
151 } 147 }
152 apic_version[m->mpc_apicid] = ver; 148 apic_version[m->mpc_apicid] = ver;
153 bios_cpu_apicid[num_processors - 1] = m->mpc_apicid; 149 if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
150 /*
151 * bios_cpu_apicid is required to have processors listed
152 * in same order as logical cpu numbers. Hence the first
153 * entry is BSP, and so on.
154 */
155 bios_cpu_apicid[0] = m->mpc_apicid;
156 x86_cpu_to_apicid[0] = m->mpc_apicid;
157 found_bsp = 1;
158 } else {
159 bios_cpu_apicid[num_processors - found_bsp] = m->mpc_apicid;
160 x86_cpu_to_apicid[num_processors - found_bsp] = m->mpc_apicid;
161 }
154} 162}
155 163
156static void __init MP_bus_info (struct mpc_config_bus *m) 164static void __init MP_bus_info (struct mpc_config_bus *m)
@@ -759,7 +767,7 @@ void __init mp_register_ioapic (
759 mp_ioapics[idx].mpc_apicaddr = address; 767 mp_ioapics[idx].mpc_apicaddr = address;
760 768
761 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); 769 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
762 mp_ioapics[idx].mpc_apicid = io_apic_get_unique_id(idx, id); 770 mp_ioapics[idx].mpc_apicid = id;
763 mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx); 771 mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx);
764 772
765 /* 773 /*
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 61de0b34a01e..31c0f2e6ac91 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -33,6 +33,7 @@
33#include <asm/msr.h> 33#include <asm/msr.h>
34#include <asm/proto.h> 34#include <asm/proto.h>
35#include <asm/kdebug.h> 35#include <asm/kdebug.h>
36#include <asm/local.h>
36 37
37/* 38/*
38 * lapic_nmi_owner tracks the ownership of the lapic NMI hardware: 39 * lapic_nmi_owner tracks the ownership of the lapic NMI hardware:
@@ -59,7 +60,8 @@ int panic_on_timeout;
59 60
60unsigned int nmi_watchdog = NMI_DEFAULT; 61unsigned int nmi_watchdog = NMI_DEFAULT;
61static unsigned int nmi_hz = HZ; 62static unsigned int nmi_hz = HZ;
62unsigned int nmi_perfctr_msr; /* the MSR to reset in NMI handler */ 63static unsigned int nmi_perfctr_msr; /* the MSR to reset in NMI handler */
64static unsigned int nmi_p4_cccr_val;
63 65
64/* Note that these events don't tick when the CPU idles. This means 66/* Note that these events don't tick when the CPU idles. This means
65 the frequency varies with CPU load. */ 67 the frequency varies with CPU load. */
@@ -71,61 +73,87 @@ unsigned int nmi_perfctr_msr; /* the MSR to reset in NMI handler */
71#define K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING 0x76 73#define K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING 0x76
72#define K7_NMI_EVENT K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING 74#define K7_NMI_EVENT K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING
73 75
74#define P6_EVNTSEL0_ENABLE (1 << 22) 76#define MSR_P4_MISC_ENABLE 0x1A0
75#define P6_EVNTSEL_INT (1 << 20) 77#define MSR_P4_MISC_ENABLE_PERF_AVAIL (1<<7)
76#define P6_EVNTSEL_OS (1 << 17) 78#define MSR_P4_MISC_ENABLE_PEBS_UNAVAIL (1<<12)
77#define P6_EVNTSEL_USR (1 << 16) 79#define MSR_P4_PERFCTR0 0x300
78#define P6_EVENT_CPU_CLOCKS_NOT_HALTED 0x79 80#define MSR_P4_CCCR0 0x360
79#define P6_NMI_EVENT P6_EVENT_CPU_CLOCKS_NOT_HALTED 81#define P4_ESCR_EVENT_SELECT(N) ((N)<<25)
82#define P4_ESCR_OS (1<<3)
83#define P4_ESCR_USR (1<<2)
84#define P4_CCCR_OVF_PMI0 (1<<26)
85#define P4_CCCR_OVF_PMI1 (1<<27)
86#define P4_CCCR_THRESHOLD(N) ((N)<<20)
87#define P4_CCCR_COMPLEMENT (1<<19)
88#define P4_CCCR_COMPARE (1<<18)
89#define P4_CCCR_REQUIRED (3<<16)
90#define P4_CCCR_ESCR_SELECT(N) ((N)<<13)
91#define P4_CCCR_ENABLE (1<<12)
92/* Set up IQ_COUNTER0 to behave like a clock, by having IQ_CCCR0 filter
93 CRU_ESCR0 (with any non-null event selector) through a complemented
94 max threshold. [IA32-Vol3, Section 14.9.9] */
95#define MSR_P4_IQ_COUNTER0 0x30C
96#define P4_NMI_CRU_ESCR0 (P4_ESCR_EVENT_SELECT(0x3F)|P4_ESCR_OS|P4_ESCR_USR)
97#define P4_NMI_IQ_CCCR0 \
98 (P4_CCCR_OVF_PMI0|P4_CCCR_THRESHOLD(15)|P4_CCCR_COMPLEMENT| \
99 P4_CCCR_COMPARE|P4_CCCR_REQUIRED|P4_CCCR_ESCR_SELECT(4)|P4_CCCR_ENABLE)
100
101static __init inline int nmi_known_cpu(void)
102{
103 switch (boot_cpu_data.x86_vendor) {
104 case X86_VENDOR_AMD:
105 return boot_cpu_data.x86 == 15;
106 case X86_VENDOR_INTEL:
107 return boot_cpu_data.x86 == 15;
108 }
109 return 0;
110}
80 111
81/* Run after command line and cpu_init init, but before all other checks */ 112/* Run after command line and cpu_init init, but before all other checks */
82void __init nmi_watchdog_default(void) 113void __init nmi_watchdog_default(void)
83{ 114{
84 if (nmi_watchdog != NMI_DEFAULT) 115 if (nmi_watchdog != NMI_DEFAULT)
85 return; 116 return;
86 117 if (nmi_known_cpu())
87 /* For some reason the IO APIC watchdog doesn't work on the AMD 118 nmi_watchdog = NMI_LOCAL_APIC;
88 8111 chipset. For now switch to local APIC mode using 119 else
89 perfctr0 there. On Intel CPUs we don't have code to handle
90 the perfctr and the IO-APIC seems to work, so use that. */
91
92 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {
93 nmi_watchdog = NMI_LOCAL_APIC;
94 printk(KERN_INFO
95 "Using local APIC NMI watchdog using perfctr0\n");
96 } else {
97 printk(KERN_INFO "Using IO APIC NMI watchdog\n");
98 nmi_watchdog = NMI_IO_APIC; 120 nmi_watchdog = NMI_IO_APIC;
99 }
100} 121}
101 122
102/* Why is there no CPUID flag for this? */ 123#ifdef CONFIG_SMP
103static __init int cpu_has_lapic(void) 124/* The performance counters used by NMI_LOCAL_APIC don't trigger when
125 * the CPU is idle. To make sure the NMI watchdog really ticks on all
126 * CPUs during the test make them busy.
127 */
128static __init void nmi_cpu_busy(void *data)
104{ 129{
105 switch (boot_cpu_data.x86_vendor) { 130 volatile int *endflag = data;
106 case X86_VENDOR_INTEL: 131 local_irq_enable();
107 case X86_VENDOR_AMD: 132 /* Intentionally don't use cpu_relax here. This is
108 return boot_cpu_data.x86 >= 6; 133 to make sure that the performance counter really ticks,
109 /* .... add more cpus here or find a different way to figure this out. */ 134 even if there is a simulator or similar that catches the
110 default: 135 pause instruction. On a real HT machine this is fine because
111 return 0; 136 all other CPUs are busy with "useless" delay loops and don't
112 } 137 care if they get somewhat less cycles. */
138 while (*endflag == 0)
139 barrier();
113} 140}
141#endif
114 142
115static int __init check_nmi_watchdog (void) 143int __init check_nmi_watchdog (void)
116{ 144{
117 int counts[NR_CPUS]; 145 volatile int endflag = 0;
146 int *counts;
118 int cpu; 147 int cpu;
119 148
120 if (nmi_watchdog == NMI_NONE) 149 counts = kmalloc(NR_CPUS * sizeof(int), GFP_KERNEL);
121 return 0; 150 if (!counts)
151 return -1;
122 152
123 if (nmi_watchdog == NMI_LOCAL_APIC && !cpu_has_lapic()) { 153 printk(KERN_INFO "testing NMI watchdog ... ");
124 nmi_watchdog = NMI_NONE;
125 return -1;
126 }
127 154
128 printk(KERN_INFO "Testing NMI watchdog ... "); 155 if (nmi_watchdog == NMI_LOCAL_APIC)
156 smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0);
129 157
130 for (cpu = 0; cpu < NR_CPUS; cpu++) 158 for (cpu = 0; cpu < NR_CPUS; cpu++)
131 counts[cpu] = cpu_pda[cpu].__nmi_count; 159 counts[cpu] = cpu_pda[cpu].__nmi_count;
@@ -133,15 +161,22 @@ static int __init check_nmi_watchdog (void)
133 mdelay((10*1000)/nmi_hz); // wait 10 ticks 161 mdelay((10*1000)/nmi_hz); // wait 10 ticks
134 162
135 for (cpu = 0; cpu < NR_CPUS; cpu++) { 163 for (cpu = 0; cpu < NR_CPUS; cpu++) {
164 if (!cpu_online(cpu))
165 continue;
136 if (cpu_pda[cpu].__nmi_count - counts[cpu] <= 5) { 166 if (cpu_pda[cpu].__nmi_count - counts[cpu] <= 5) {
137 printk("CPU#%d: NMI appears to be stuck (%d)!\n", 167 endflag = 1;
168 printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n",
138 cpu, 169 cpu,
170 counts[cpu],
139 cpu_pda[cpu].__nmi_count); 171 cpu_pda[cpu].__nmi_count);
140 nmi_active = 0; 172 nmi_active = 0;
141 lapic_nmi_owner &= ~LAPIC_NMI_WATCHDOG; 173 lapic_nmi_owner &= ~LAPIC_NMI_WATCHDOG;
174 nmi_perfctr_msr = 0;
175 kfree(counts);
142 return -1; 176 return -1;
143 } 177 }
144 } 178 }
179 endflag = 1;
145 printk("OK.\n"); 180 printk("OK.\n");
146 181
147 /* now that we know it works we can reduce NMI frequency to 182 /* now that we know it works we can reduce NMI frequency to
@@ -149,10 +184,9 @@ static int __init check_nmi_watchdog (void)
149 if (nmi_watchdog == NMI_LOCAL_APIC) 184 if (nmi_watchdog == NMI_LOCAL_APIC)
150 nmi_hz = 1; 185 nmi_hz = 1;
151 186
187 kfree(counts);
152 return 0; 188 return 0;
153} 189}
154/* Have this called later during boot so counters are updating */
155late_initcall(check_nmi_watchdog);
156 190
157int __init setup_nmi_watchdog(char *str) 191int __init setup_nmi_watchdog(char *str)
158{ 192{
@@ -170,7 +204,7 @@ int __init setup_nmi_watchdog(char *str)
170 204
171 if (nmi >= NMI_INVALID) 205 if (nmi >= NMI_INVALID)
172 return 0; 206 return 0;
173 nmi_watchdog = nmi; 207 nmi_watchdog = nmi;
174 return 1; 208 return 1;
175} 209}
176 210
@@ -185,7 +219,10 @@ static void disable_lapic_nmi_watchdog(void)
185 wrmsr(MSR_K7_EVNTSEL0, 0, 0); 219 wrmsr(MSR_K7_EVNTSEL0, 0, 0);
186 break; 220 break;
187 case X86_VENDOR_INTEL: 221 case X86_VENDOR_INTEL:
188 wrmsr(MSR_IA32_EVNTSEL0, 0, 0); 222 if (boot_cpu_data.x86 == 15) {
223 wrmsr(MSR_P4_IQ_CCCR0, 0, 0);
224 wrmsr(MSR_P4_CRU_ESCR0, 0, 0);
225 }
189 break; 226 break;
190 } 227 }
191 nmi_active = -1; 228 nmi_active = -1;
@@ -253,7 +290,7 @@ void enable_timer_nmi_watchdog(void)
253 290
254static int nmi_pm_active; /* nmi_active before suspend */ 291static int nmi_pm_active; /* nmi_active before suspend */
255 292
256static int lapic_nmi_suspend(struct sys_device *dev, pm_message_t state) 293static int lapic_nmi_suspend(struct sys_device *dev, u32 state)
257{ 294{
258 nmi_pm_active = nmi_active; 295 nmi_pm_active = nmi_active;
259 disable_lapic_nmi_watchdog(); 296 disable_lapic_nmi_watchdog();
@@ -300,22 +337,27 @@ late_initcall(init_lapic_nmi_sysfs);
300 * Original code written by Keith Owens. 337 * Original code written by Keith Owens.
301 */ 338 */
302 339
340static void clear_msr_range(unsigned int base, unsigned int n)
341{
342 unsigned int i;
343
344 for(i = 0; i < n; ++i)
345 wrmsr(base+i, 0, 0);
346}
347
303static void setup_k7_watchdog(void) 348static void setup_k7_watchdog(void)
304{ 349{
305 int i; 350 int i;
306 unsigned int evntsel; 351 unsigned int evntsel;
307 352
308 /* No check, so can start with slow frequency */
309 nmi_hz = 1;
310
311 /* XXX should check these in EFER */
312
313 nmi_perfctr_msr = MSR_K7_PERFCTR0; 353 nmi_perfctr_msr = MSR_K7_PERFCTR0;
314 354
315 for(i = 0; i < 4; ++i) { 355 for(i = 0; i < 4; ++i) {
316 /* Simulator may not support it */ 356 /* Simulator may not support it */
317 if (checking_wrmsrl(MSR_K7_EVNTSEL0+i, 0UL)) 357 if (checking_wrmsrl(MSR_K7_EVNTSEL0+i, 0UL)) {
358 nmi_perfctr_msr = 0;
318 return; 359 return;
360 }
319 wrmsrl(MSR_K7_PERFCTR0+i, 0UL); 361 wrmsrl(MSR_K7_PERFCTR0+i, 0UL);
320 } 362 }
321 363
@@ -325,12 +367,54 @@ static void setup_k7_watchdog(void)
325 | K7_NMI_EVENT; 367 | K7_NMI_EVENT;
326 368
327 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0); 369 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0);
328 wrmsrl(MSR_K7_PERFCTR0, -((u64)cpu_khz*1000) / nmi_hz); 370 wrmsr(MSR_K7_PERFCTR0, -(cpu_khz/nmi_hz*1000), -1);
329 apic_write(APIC_LVTPC, APIC_DM_NMI); 371 apic_write(APIC_LVTPC, APIC_DM_NMI);
330 evntsel |= K7_EVNTSEL_ENABLE; 372 evntsel |= K7_EVNTSEL_ENABLE;
331 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0); 373 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0);
332} 374}
333 375
376
377static int setup_p4_watchdog(void)
378{
379 unsigned int misc_enable, dummy;
380
381 rdmsr(MSR_P4_MISC_ENABLE, misc_enable, dummy);
382 if (!(misc_enable & MSR_P4_MISC_ENABLE_PERF_AVAIL))
383 return 0;
384
385 nmi_perfctr_msr = MSR_P4_IQ_COUNTER0;
386 nmi_p4_cccr_val = P4_NMI_IQ_CCCR0;
387#ifdef CONFIG_SMP
388 if (smp_num_siblings == 2)
389 nmi_p4_cccr_val |= P4_CCCR_OVF_PMI1;
390#endif
391
392 if (!(misc_enable & MSR_P4_MISC_ENABLE_PEBS_UNAVAIL))
393 clear_msr_range(0x3F1, 2);
394 /* MSR 0x3F0 seems to have a default value of 0xFC00, but current
395 docs doesn't fully define it, so leave it alone for now. */
396 if (boot_cpu_data.x86_model >= 0x3) {
397 /* MSR_P4_IQ_ESCR0/1 (0x3ba/0x3bb) removed */
398 clear_msr_range(0x3A0, 26);
399 clear_msr_range(0x3BC, 3);
400 } else {
401 clear_msr_range(0x3A0, 31);
402 }
403 clear_msr_range(0x3C0, 6);
404 clear_msr_range(0x3C8, 6);
405 clear_msr_range(0x3E0, 2);
406 clear_msr_range(MSR_P4_CCCR0, 18);
407 clear_msr_range(MSR_P4_PERFCTR0, 18);
408
409 wrmsr(MSR_P4_CRU_ESCR0, P4_NMI_CRU_ESCR0, 0);
410 wrmsr(MSR_P4_IQ_CCCR0, P4_NMI_IQ_CCCR0 & ~P4_CCCR_ENABLE, 0);
411 Dprintk("setting P4_IQ_COUNTER0 to 0x%08lx\n", -(cpu_khz/nmi_hz*1000));
412 wrmsr(MSR_P4_IQ_COUNTER0, -(cpu_khz/nmi_hz*1000), -1);
413 apic_write(APIC_LVTPC, APIC_DM_NMI);
414 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0);
415 return 1;
416}
417
334void setup_apic_nmi_watchdog(void) 418void setup_apic_nmi_watchdog(void)
335{ 419{
336 switch (boot_cpu_data.x86_vendor) { 420 switch (boot_cpu_data.x86_vendor) {
@@ -341,6 +425,13 @@ void setup_apic_nmi_watchdog(void)
341 return; 425 return;
342 setup_k7_watchdog(); 426 setup_k7_watchdog();
343 break; 427 break;
428 case X86_VENDOR_INTEL:
429 if (boot_cpu_data.x86 != 15)
430 return;
431 if (!setup_p4_watchdog())
432 return;
433 break;
434
344 default: 435 default:
345 return; 436 return;
346 } 437 }
@@ -355,56 +446,67 @@ void setup_apic_nmi_watchdog(void)
355 * 446 *
356 * as these watchdog NMI IRQs are generated on every CPU, we only 447 * as these watchdog NMI IRQs are generated on every CPU, we only
357 * have to check the current processor. 448 * have to check the current processor.
358 *
359 * since NMIs don't listen to _any_ locks, we have to be extremely
360 * careful not to rely on unsafe variables. The printk might lock
361 * up though, so we have to break up any console locks first ...
362 * [when there will be more tty-related locks, break them up
363 * here too!]
364 */ 449 */
365 450
366static unsigned int 451static DEFINE_PER_CPU(unsigned, last_irq_sum);
367 last_irq_sums [NR_CPUS], 452static DEFINE_PER_CPU(local_t, alert_counter);
368 alert_counter [NR_CPUS]; 453static DEFINE_PER_CPU(int, nmi_touch);
369 454
370void touch_nmi_watchdog (void) 455void touch_nmi_watchdog (void)
371{ 456{
372 int i; 457 int i;
373 458
374 /* 459 /*
375 * Just reset the alert counters, (other CPUs might be 460 * Tell other CPUs to reset their alert counters. We cannot
376 * spinning on locks we hold): 461 * do it ourselves because the alert count increase is not
462 * atomic.
377 */ 463 */
378 for (i = 0; i < NR_CPUS; i++) 464 for (i = 0; i < NR_CPUS; i++)
379 alert_counter[i] = 0; 465 per_cpu(nmi_touch, i) = 1;
380} 466}
381 467
382void nmi_watchdog_tick (struct pt_regs * regs, unsigned reason) 468void nmi_watchdog_tick (struct pt_regs * regs, unsigned reason)
383{ 469{
384 int sum, cpu; 470 int sum;
471 int touched = 0;
385 472
386 cpu = safe_smp_processor_id();
387 sum = read_pda(apic_timer_irqs); 473 sum = read_pda(apic_timer_irqs);
388 if (last_irq_sums[cpu] == sum) { 474 if (__get_cpu_var(nmi_touch)) {
475 __get_cpu_var(nmi_touch) = 0;
476 touched = 1;
477 }
478 if (!touched && __get_cpu_var(last_irq_sum) == sum) {
389 /* 479 /*
390 * Ayiee, looks like this CPU is stuck ... 480 * Ayiee, looks like this CPU is stuck ...
391 * wait a few IRQs (5 seconds) before doing the oops ... 481 * wait a few IRQs (5 seconds) before doing the oops ...
392 */ 482 */
393 alert_counter[cpu]++; 483 local_inc(&__get_cpu_var(alert_counter));
394 if (alert_counter[cpu] == 5*nmi_hz) { 484 if (local_read(&__get_cpu_var(alert_counter)) == 5*nmi_hz) {
395 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) 485 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT)
396 == NOTIFY_STOP) { 486 == NOTIFY_STOP) {
397 alert_counter[cpu] = 0; 487 local_set(&__get_cpu_var(alert_counter), 0);
398 return; 488 return;
399 } 489 }
400 die_nmi("NMI Watchdog detected LOCKUP on CPU%d", regs); 490 die_nmi("NMI Watchdog detected LOCKUP on CPU%d", regs);
401 } 491 }
402 } else { 492 } else {
403 last_irq_sums[cpu] = sum; 493 __get_cpu_var(last_irq_sum) = sum;
404 alert_counter[cpu] = 0; 494 local_set(&__get_cpu_var(alert_counter), 0);
405 } 495 }
406 if (nmi_perfctr_msr) 496 if (nmi_perfctr_msr) {
497 if (nmi_perfctr_msr == MSR_P4_IQ_COUNTER0) {
498 /*
499 * P4 quirks:
500 * - An overflown perfctr will assert its interrupt
501 * until the OVF flag in its CCCR is cleared.
502 * - LVTPC is masked on interrupt and must be
503 * unmasked by the LVTPC handler.
504 */
505 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0);
506 apic_write(APIC_LVTPC, APIC_DM_NMI);
507 }
407 wrmsr(nmi_perfctr_msr, -(cpu_khz/nmi_hz*1000), -1); 508 wrmsr(nmi_perfctr_msr, -(cpu_khz/nmi_hz*1000), -1);
509 }
408} 510}
409 511
410static int dummy_nmi_callback(struct pt_regs * regs, int cpu) 512static int dummy_nmi_callback(struct pt_regs * regs, int cpu)
diff --git a/arch/x86_64/kernel/pmtimer.c b/arch/x86_64/kernel/pmtimer.c
new file mode 100644
index 000000000000..feb5f108dd26
--- /dev/null
+++ b/arch/x86_64/kernel/pmtimer.c
@@ -0,0 +1,101 @@
1/* Ported over from i386 by AK, original copyright was:
2 *
3 * (C) Dominik Brodowski <linux@brodo.de> 2003
4 *
5 * Driver to use the Power Management Timer (PMTMR) available in some
6 * southbridges as primary timing source for the Linux kernel.
7 *
8 * Based on parts of linux/drivers/acpi/hardware/hwtimer.c, timer_pit.c,
9 * timer_hpet.c, and on Arjan van de Ven's implementation for 2.4.
10 *
11 * This file is licensed under the GPL v2.
12 *
13 * Dropped all the hardware bug workarounds for now. Hopefully they
14 * are not needed on 64bit chipsets.
15 */
16
17#include <linux/jiffies.h>
18#include <linux/kernel.h>
19#include <linux/time.h>
20#include <linux/init.h>
21#include <linux/cpumask.h>
22#include <asm/io.h>
23#include <asm/proto.h>
24#include <asm/msr.h>
25#include <asm/vsyscall.h>
26
27/* The I/O port the PMTMR resides at.
28 * The location is detected during setup_arch(),
29 * in arch/i386/kernel/acpi/boot.c */
30u32 pmtmr_ioport;
31
32/* value of the Power timer at last timer interrupt */
33static u32 offset_delay;
34static u32 last_pmtmr_tick;
35
36#define ACPI_PM_MASK 0xFFFFFF /* limit it to 24 bits */
37
38static inline u32 cyc2us(u32 cycles)
39{
40 /* The Power Management Timer ticks at 3.579545 ticks per microsecond.
41 * 1 / PM_TIMER_FREQUENCY == 0.27936511 =~ 286/1024 [error: 0.024%]
42 *
43 * Even with HZ = 100, delta is at maximum 35796 ticks, so it can
44 * easily be multiplied with 286 (=0x11E) without having to fear
45 * u32 overflows.
46 */
47 cycles *= 286;
48 return (cycles >> 10);
49}
50
51int pmtimer_mark_offset(void)
52{
53 static int first_run = 1;
54 unsigned long tsc;
55 u32 lost;
56
57 u32 tick = inl(pmtmr_ioport);
58 u32 delta;
59
60 delta = cyc2us((tick - last_pmtmr_tick) & ACPI_PM_MASK);
61
62 last_pmtmr_tick = tick;
63 monotonic_base += delta * NSEC_PER_USEC;
64
65 delta += offset_delay;
66
67 lost = delta / (USEC_PER_SEC / HZ);
68 offset_delay = delta % (USEC_PER_SEC / HZ);
69
70 rdtscll(tsc);
71 vxtime.last_tsc = tsc - offset_delay * cpu_khz;
72
73 /* don't calculate delay for first run,
74 or if we've got less then a tick */
75 if (first_run || (lost < 1)) {
76 first_run = 0;
77 offset_delay = 0;
78 }
79
80 return lost - 1;
81}
82
83unsigned int do_gettimeoffset_pm(void)
84{
85 u32 now, offset, delta = 0;
86
87 offset = last_pmtmr_tick;
88 now = inl(pmtmr_ioport);
89 delta = (now - offset) & ACPI_PM_MASK;
90
91 return offset_delay + cyc2us(delta);
92}
93
94
95static int __init nopmtimer_setup(char *s)
96{
97 pmtmr_ioport = 0;
98 return 0;
99}
100
101__setup("nopmtimer", nopmtimer_setup);
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
index e26e86bb56fe..525f6a128a27 100644
--- a/arch/x86_64/kernel/ptrace.c
+++ b/arch/x86_64/kernel/ptrace.c
@@ -257,13 +257,13 @@ 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 >> 48) == 0 || (value >> 48) == 0xffff)) 260 if (value >= TASK_SIZE)
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 >> 48) == 0 || (value >> 48) == 0xffff)) 265 if (value >= TASK_SIZE)
266 return -EIO; 266 return -EIO;
267 child->thread.gs = value; 267 child->thread.gs = value;
268 return 0; 268 return 0;
269 case offsetof(struct user_regs_struct, eflags): 269 case offsetof(struct user_regs_struct, eflags):
@@ -277,6 +277,11 @@ static int putreg(struct task_struct *child,
277 return -EIO; 277 return -EIO;
278 value &= 0xffff; 278 value &= 0xffff;
279 break; 279 break;
280 case offsetof(struct user_regs_struct, rip):
281 /* Check if the new RIP address is canonical */
282 if (value >= TASK_SIZE)
283 return -EIO;
284 break;
280 } 285 }
281 put_stack_long(child, regno - sizeof(struct pt_regs), value); 286 put_stack_long(child, regno - sizeof(struct pt_regs), value);
282 return 0; 287 return 0;
@@ -375,7 +380,7 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data
375 break; 380 break;
376 381
377 switch (addr) { 382 switch (addr) {
378 case 0 ... sizeof(struct user_regs_struct): 383 case 0 ... sizeof(struct user_regs_struct) - sizeof(long):
379 tmp = getreg(child, addr); 384 tmp = getreg(child, addr);
380 break; 385 break;
381 case offsetof(struct user, u_debugreg[0]): 386 case offsetof(struct user, u_debugreg[0]):
@@ -420,7 +425,7 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data
420 break; 425 break;
421 426
422 switch (addr) { 427 switch (addr) {
423 case 0 ... sizeof(struct user_regs_struct): 428 case 0 ... sizeof(struct user_regs_struct) - sizeof(long):
424 ret = putreg(child, addr, data); 429 ret = putreg(child, addr, data);
425 break; 430 break;
426 /* Disallows to set a breakpoint into the vsyscall */ 431 /* Disallows to set a breakpoint into the vsyscall */
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 2129cf9ba6b2..99f038ede23c 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -719,7 +719,6 @@ static void __init display_cacheinfo(struct cpuinfo_x86 *c)
719 } 719 }
720} 720}
721 721
722#ifdef CONFIG_SMP
723/* 722/*
724 * On a AMD dual core setup the lower bits of the APIC id distingush the cores. 723 * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
725 * Assumes number of cores is a power of two. 724 * Assumes number of cores is a power of two.
@@ -727,17 +726,26 @@ static void __init display_cacheinfo(struct cpuinfo_x86 *c)
727static void __init amd_detect_cmp(struct cpuinfo_x86 *c) 726static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
728{ 727{
729#ifdef CONFIG_SMP 728#ifdef CONFIG_SMP
730 int cpu = c->x86_apicid; 729 int cpu = smp_processor_id();
731 int node = 0; 730 int node = 0;
731 unsigned bits;
732 if (c->x86_num_cores == 1) 732 if (c->x86_num_cores == 1)
733 return; 733 return;
734 cpu_core_id[cpu] = cpu >> hweight32(c->x86_num_cores - 1); 734
735 bits = 0;
736 while ((1 << bits) < c->x86_num_cores)
737 bits++;
738
739 /* Low order bits define the core id (index of core in socket) */
740 cpu_core_id[cpu] = phys_proc_id[cpu] & ((1 << bits)-1);
741 /* Convert the APIC ID into the socket ID */
742 phys_proc_id[cpu] >>= bits;
735 743
736#ifdef CONFIG_NUMA 744#ifdef CONFIG_NUMA
737 /* When an ACPI SRAT table is available use the mappings from SRAT 745 /* When an ACPI SRAT table is available use the mappings from SRAT
738 instead. */ 746 instead. */
739 if (acpi_numa <= 0) { 747 if (acpi_numa <= 0) {
740 node = cpu_core_id[cpu]; 748 node = phys_proc_id[cpu];
741 if (!node_online(node)) 749 if (!node_online(node))
742 node = first_node(node_online_map); 750 node = first_node(node_online_map);
743 cpu_to_node[cpu] = node; 751 cpu_to_node[cpu] = node;
@@ -745,15 +753,11 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
745 node = cpu_to_node[cpu]; 753 node = cpu_to_node[cpu];
746 } 754 }
747#endif 755#endif
756
748 printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n", 757 printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n",
749 cpu, c->x86_num_cores, node, cpu_core_id[cpu]); 758 cpu, c->x86_num_cores, node, cpu_core_id[cpu]);
750#endif 759#endif
751} 760}
752#else
753static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
754{
755}
756#endif
757 761
758static int __init init_amd(struct cpuinfo_x86 *c) 762static int __init init_amd(struct cpuinfo_x86 *c)
759{ 763{
@@ -925,7 +929,6 @@ void __init early_identify_cpu(struct cpuinfo_x86 *c)
925 c->x86_clflush_size = 64; 929 c->x86_clflush_size = 64;
926 c->x86_cache_alignment = c->x86_clflush_size; 930 c->x86_cache_alignment = c->x86_clflush_size;
927 c->x86_num_cores = 1; 931 c->x86_num_cores = 1;
928 c->x86_apicid = c == &boot_cpu_data ? 0 : c - cpu_data;
929 c->extended_cpuid_level = 0; 932 c->extended_cpuid_level = 0;
930 memset(&c->x86_capability, 0, sizeof c->x86_capability); 933 memset(&c->x86_capability, 0, sizeof c->x86_capability);
931 934
@@ -954,11 +957,14 @@ void __init early_identify_cpu(struct cpuinfo_x86 *c)
954 } 957 }
955 if (c->x86_capability[0] & (1<<19)) 958 if (c->x86_capability[0] & (1<<19))
956 c->x86_clflush_size = ((misc >> 8) & 0xff) * 8; 959 c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
957 c->x86_apicid = misc >> 24;
958 } else { 960 } else {
959 /* Have CPUID level 0 only - unheard of */ 961 /* Have CPUID level 0 only - unheard of */
960 c->x86 = 4; 962 c->x86 = 4;
961 } 963 }
964
965#ifdef CONFIG_SMP
966 phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
967#endif
962} 968}
963 969
964/* 970/*
@@ -1088,7 +1094,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1088 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1094 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1089 1095
1090 /* Other (Linux-defined) */ 1096 /* Other (Linux-defined) */
1091 "cxmmx", NULL, "cyrix_arr", "centaur_mcr", "k8c+", 1097 "cxmmx", NULL, "cyrix_arr", "centaur_mcr", NULL,
1092 "constant_tsc", NULL, NULL, 1098 "constant_tsc", NULL, NULL,
1093 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1099 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1094 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1100 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
diff --git a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c
index d439ced150c6..3fdcdba0fec5 100644
--- a/arch/x86_64/kernel/signal.c
+++ b/arch/x86_64/kernel/signal.c
@@ -452,7 +452,9 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
452 regs->rip -= 2; 452 regs->rip -= 2;
453 } 453 }
454 if (regs->rax == (unsigned long)-ERESTART_RESTARTBLOCK) { 454 if (regs->rax == (unsigned long)-ERESTART_RESTARTBLOCK) {
455 regs->rax = __NR_restart_syscall; 455 regs->rax = test_thread_flag(TIF_IA32) ?
456 __NR_ia32_restart_syscall :
457 __NR_restart_syscall;
456 regs->rip -= 2; 458 regs->rip -= 2;
457 } 459 }
458 } 460 }
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index 73f7e8b9543a..f1ec0f345941 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -56,6 +56,7 @@
56#include <asm/kdebug.h> 56#include <asm/kdebug.h>
57#include <asm/tlbflush.h> 57#include <asm/tlbflush.h>
58#include <asm/proto.h> 58#include <asm/proto.h>
59#include <asm/nmi.h>
59 60
60/* Change for real CPU hotplug. Note other files need to be fixed 61/* Change for real CPU hotplug. Note other files need to be fixed
61 first too. */ 62 first too. */
@@ -93,6 +94,7 @@ int smp_threads_ready;
93 94
94cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned; 95cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned;
95cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned; 96cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned;
97EXPORT_SYMBOL(cpu_core_map);
96 98
97/* 99/*
98 * Trampoline 80x86 program as an array. 100 * Trampoline 80x86 program as an array.
@@ -125,96 +127,210 @@ static void __cpuinit smp_store_cpu_info(int id)
125 127
126 *c = boot_cpu_data; 128 *c = boot_cpu_data;
127 identify_cpu(c); 129 identify_cpu(c);
130 print_cpu_info(c);
128} 131}
129 132
130/* 133/*
131 * Synchronize TSCs of CPUs 134 * New Funky TSC sync algorithm borrowed from IA64.
135 * Main advantage is that it doesn't reset the TSCs fully and
136 * in general looks more robust and it works better than my earlier
137 * attempts. I believe it was written by David Mosberger. Some minor
138 * adjustments for x86-64 by me -AK
132 * 139 *
133 * This new algorithm is less accurate than the old "zero TSCs" 140 * Original comment reproduced below.
134 * one, but we cannot zero TSCs anymore in the new hotplug CPU 141 *
135 * model. 142 * Synchronize TSC of the current (slave) CPU with the TSC of the
143 * MASTER CPU (normally the time-keeper CPU). We use a closed loop to
144 * eliminate the possibility of unaccounted-for errors (such as
145 * getting a machine check in the middle of a calibration step). The
146 * basic idea is for the slave to ask the master what itc value it has
147 * and to read its own itc before and after the master responds. Each
148 * iteration gives us three timestamps:
149 *
150 * slave master
151 *
152 * t0 ---\
153 * ---\
154 * --->
155 * tm
156 * /---
157 * /---
158 * t1 <---
159 *
160 *
161 * The goal is to adjust the slave's TSC such that tm falls exactly
162 * half-way between t0 and t1. If we achieve this, the clocks are
163 * synchronized provided the interconnect between the slave and the
164 * master is symmetric. Even if the interconnect were asymmetric, we
165 * would still know that the synchronization error is smaller than the
166 * roundtrip latency (t0 - t1).
167 *
168 * When the interconnect is quiet and symmetric, this lets us
169 * synchronize the TSC to within one or two cycles. However, we can
170 * only *guarantee* that the synchronization is accurate to within a
171 * round-trip time, which is typically in the range of several hundred
172 * cycles (e.g., ~500 cycles). In practice, this means that the TSCs
173 * are usually almost perfectly synchronized, but we shouldn't assume
174 * that the accuracy is much better than half a micro second or so.
175 *
176 * [there are other errors like the latency of RDTSC and of the
177 * WRMSR. These can also account to hundreds of cycles. So it's
178 * probably worse. It claims 153 cycles error on a dual Opteron,
179 * but I suspect the numbers are actually somewhat worse -AK]
136 */ 180 */
137 181
138static atomic_t __cpuinitdata tsc_flag; 182#define MASTER 0
183#define SLAVE (SMP_CACHE_BYTES/8)
184
185/* Intentionally don't use cpu_relax() while TSC synchronization
186 because we don't want to go into funky power save modi or cause
187 hypervisors to schedule us away. Going to sleep would likely affect
188 latency and low latency is the primary objective here. -AK */
189#define no_cpu_relax() barrier()
190
139static __cpuinitdata DEFINE_SPINLOCK(tsc_sync_lock); 191static __cpuinitdata DEFINE_SPINLOCK(tsc_sync_lock);
140static unsigned long long __cpuinitdata bp_tsc, ap_tsc; 192static volatile __cpuinitdata unsigned long go[SLAVE + 1];
193static int notscsync __cpuinitdata;
194
195#undef DEBUG_TSC_SYNC
141 196
142#define NR_LOOPS 5 197#define NUM_ROUNDS 64 /* magic value */
198#define NUM_ITERS 5 /* likewise */
143 199
144static void __cpuinit sync_tsc_bp_init(int init) 200/* Callback on boot CPU */
201static __cpuinit void sync_master(void *arg)
145{ 202{
146 if (init) 203 unsigned long flags, i;
147 _raw_spin_lock(&tsc_sync_lock); 204
148 else 205 if (smp_processor_id() != boot_cpu_id)
149 _raw_spin_unlock(&tsc_sync_lock); 206 return;
150 atomic_set(&tsc_flag, 0); 207
208 go[MASTER] = 0;
209
210 local_irq_save(flags);
211 {
212 for (i = 0; i < NUM_ROUNDS*NUM_ITERS; ++i) {
213 while (!go[MASTER])
214 no_cpu_relax();
215 go[MASTER] = 0;
216 rdtscll(go[SLAVE]);
217 }
218 }
219 local_irq_restore(flags);
151} 220}
152 221
153/* 222/*
154 * Synchronize TSC on AP with BP. 223 * Return the number of cycles by which our tsc differs from the tsc
224 * on the master (time-keeper) CPU. A positive number indicates our
225 * tsc is ahead of the master, negative that it is behind.
155 */ 226 */
156static void __cpuinit __sync_tsc_ap(void) 227static inline long
228get_delta(long *rt, long *master)
157{ 229{
158 if (!cpu_has_tsc) 230 unsigned long best_t0 = 0, best_t1 = ~0UL, best_tm = 0;
159 return; 231 unsigned long tcenter, t0, t1, tm;
160 Dprintk("AP %d syncing TSC\n", smp_processor_id()); 232 int i;
161 233
162 while (atomic_read(&tsc_flag) != 0) 234 for (i = 0; i < NUM_ITERS; ++i) {
163 cpu_relax(); 235 rdtscll(t0);
164 atomic_inc(&tsc_flag); 236 go[MASTER] = 1;
165 mb(); 237 while (!(tm = go[SLAVE]))
166 _raw_spin_lock(&tsc_sync_lock); 238 no_cpu_relax();
167 wrmsrl(MSR_IA32_TSC, bp_tsc); 239 go[SLAVE] = 0;
168 _raw_spin_unlock(&tsc_sync_lock); 240 rdtscll(t1);
169 rdtscll(ap_tsc); 241
170 mb(); 242 if (t1 - t0 < best_t1 - best_t0)
171 atomic_inc(&tsc_flag); 243 best_t0 = t0, best_t1 = t1, best_tm = tm;
172 mb(); 244 }
245
246 *rt = best_t1 - best_t0;
247 *master = best_tm - best_t0;
248
249 /* average best_t0 and best_t1 without overflow: */
250 tcenter = (best_t0/2 + best_t1/2);
251 if (best_t0 % 2 + best_t1 % 2 == 2)
252 ++tcenter;
253 return tcenter - best_tm;
173} 254}
174 255
175static void __cpuinit sync_tsc_ap(void) 256static __cpuinit void sync_tsc(void)
176{ 257{
177 int i; 258 int i, done = 0;
178 for (i = 0; i < NR_LOOPS; i++) 259 long delta, adj, adjust_latency = 0;
179 __sync_tsc_ap(); 260 unsigned long flags, rt, master_time_stamp, bound;
261#if DEBUG_TSC_SYNC
262 static struct syncdebug {
263 long rt; /* roundtrip time */
264 long master; /* master's timestamp */
265 long diff; /* difference between midpoint and master's timestamp */
266 long lat; /* estimate of tsc adjustment latency */
267 } t[NUM_ROUNDS] __cpuinitdata;
268#endif
269
270 go[MASTER] = 1;
271
272 smp_call_function(sync_master, NULL, 1, 0);
273
274 while (go[MASTER]) /* wait for master to be ready */
275 no_cpu_relax();
276
277 spin_lock_irqsave(&tsc_sync_lock, flags);
278 {
279 for (i = 0; i < NUM_ROUNDS; ++i) {
280 delta = get_delta(&rt, &master_time_stamp);
281 if (delta == 0) {
282 done = 1; /* let's lock on to this... */
283 bound = rt;
284 }
285
286 if (!done) {
287 unsigned long t;
288 if (i > 0) {
289 adjust_latency += -delta;
290 adj = -delta + adjust_latency/4;
291 } else
292 adj = -delta;
293
294 rdtscll(t);
295 wrmsrl(MSR_IA32_TSC, t + adj);
296 }
297#if DEBUG_TSC_SYNC
298 t[i].rt = rt;
299 t[i].master = master_time_stamp;
300 t[i].diff = delta;
301 t[i].lat = adjust_latency/4;
302#endif
303 }
304 }
305 spin_unlock_irqrestore(&tsc_sync_lock, flags);
306
307#if DEBUG_TSC_SYNC
308 for (i = 0; i < NUM_ROUNDS; ++i)
309 printk("rt=%5ld master=%5ld diff=%5ld adjlat=%5ld\n",
310 t[i].rt, t[i].master, t[i].diff, t[i].lat);
311#endif
312
313 printk(KERN_INFO
314 "CPU %d: synchronized TSC with CPU %u (last diff %ld cycles, "
315 "maxerr %lu cycles)\n",
316 smp_processor_id(), boot_cpu_id, delta, rt);
180} 317}
181 318
182/* 319static void __cpuinit tsc_sync_wait(void)
183 * Synchronize TSC from BP to AP.
184 */
185static void __cpuinit __sync_tsc_bp(int cpu)
186{ 320{
187 if (!cpu_has_tsc) 321 if (notscsync || !cpu_has_tsc)
188 return; 322 return;
189 323 printk(KERN_INFO "CPU %d: Syncing TSC to CPU %u.\n", smp_processor_id(),
190 /* Wait for AP */ 324 boot_cpu_id);
191 while (atomic_read(&tsc_flag) == 0) 325 sync_tsc();
192 cpu_relax();
193 /* Save BPs TSC */
194 sync_core();
195 rdtscll(bp_tsc);
196 /* Don't do the sync core here to avoid too much latency. */
197 mb();
198 /* Start the AP */
199 _raw_spin_unlock(&tsc_sync_lock);
200 /* Wait for AP again */
201 while (atomic_read(&tsc_flag) < 2)
202 cpu_relax();
203 rdtscl(bp_tsc);
204 barrier();
205} 326}
206 327
207static void __cpuinit sync_tsc_bp(int cpu) 328static __init int notscsync_setup(char *s)
208{ 329{
209 int i; 330 notscsync = 1;
210 for (i = 0; i < NR_LOOPS - 1; i++) { 331 return 0;
211 __sync_tsc_bp(cpu);
212 sync_tsc_bp_init(1);
213 }
214 __sync_tsc_bp(cpu);
215 printk(KERN_INFO "Synced TSC of CPU %d difference %Ld\n",
216 cpu, ap_tsc - bp_tsc);
217} 332}
333__setup("notscsync", notscsync_setup);
218 334
219static atomic_t init_deasserted __cpuinitdata; 335static atomic_t init_deasserted __cpuinitdata;
220 336
@@ -315,11 +431,6 @@ void __cpuinit start_secondary(void)
315 cpu_init(); 431 cpu_init();
316 smp_callin(); 432 smp_callin();
317 433
318 /*
319 * Synchronize the TSC with the BP
320 */
321 sync_tsc_ap();
322
323 /* otherwise gcc will move up the smp_processor_id before the cpu_init */ 434 /* otherwise gcc will move up the smp_processor_id before the cpu_init */
324 barrier(); 435 barrier();
325 436
@@ -334,7 +445,6 @@ void __cpuinit start_secondary(void)
334 enable_8259A_irq(0); 445 enable_8259A_irq(0);
335 } 446 }
336 447
337
338 enable_APIC_timer(); 448 enable_APIC_timer();
339 449
340 /* 450 /*
@@ -343,6 +453,11 @@ void __cpuinit start_secondary(void)
343 cpu_set(smp_processor_id(), cpu_online_map); 453 cpu_set(smp_processor_id(), cpu_online_map);
344 mb(); 454 mb();
345 455
456 /* Wait for TSC sync to not schedule things before.
457 We still process interrupts, which could see an inconsistent
458 time in that window unfortunately. */
459 tsc_sync_wait();
460
346 cpu_idle(); 461 cpu_idle();
347} 462}
348 463
@@ -531,7 +646,6 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
531 printk("failed fork for CPU %d\n", cpu); 646 printk("failed fork for CPU %d\n", cpu);
532 return PTR_ERR(idle); 647 return PTR_ERR(idle);
533 } 648 }
534 x86_cpu_to_apicid[cpu] = apicid;
535 649
536 cpu_pda[cpu].pcurrent = idle; 650 cpu_pda[cpu].pcurrent = idle;
537 651
@@ -600,8 +714,6 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
600 714
601 if (cpu_isset(cpu, cpu_callin_map)) { 715 if (cpu_isset(cpu, cpu_callin_map)) {
602 /* number CPUs logically, starting from 1 (BSP is 0) */ 716 /* number CPUs logically, starting from 1 (BSP is 0) */
603 Dprintk("OK.\n");
604 print_cpu_info(&cpu_data[cpu]);
605 Dprintk("CPU has booted.\n"); 717 Dprintk("CPU has booted.\n");
606 } else { 718 } else {
607 boot_error = 1; 719 boot_error = 1;
@@ -842,7 +954,6 @@ void __cpuinit smp_prepare_cpus(unsigned int max_cpus)
842 GET_APIC_ID(apic_read(APIC_ID)), boot_cpu_id); 954 GET_APIC_ID(apic_read(APIC_ID)), boot_cpu_id);
843 /* Or can we switch back to PIC here? */ 955 /* Or can we switch back to PIC here? */
844 } 956 }
845 x86_cpu_to_apicid[0] = boot_cpu_id;
846 957
847 /* 958 /*
848 * Now start the IO-APICs 959 * Now start the IO-APICs
@@ -889,18 +1000,14 @@ int __cpuinit __cpu_up(unsigned int cpu)
889 printk("__cpu_up: bad cpu %d\n", cpu); 1000 printk("__cpu_up: bad cpu %d\n", cpu);
890 return -EINVAL; 1001 return -EINVAL;
891 } 1002 }
892 sync_tsc_bp_init(1);
893 1003
894 /* Boot it! */ 1004 /* Boot it! */
895 err = do_boot_cpu(cpu, apicid); 1005 err = do_boot_cpu(cpu, apicid);
896 if (err < 0) { 1006 if (err < 0) {
897 sync_tsc_bp_init(0);
898 Dprintk("do_boot_cpu failed %d\n", err); 1007 Dprintk("do_boot_cpu failed %d\n", err);
899 return err; 1008 return err;
900 } 1009 }
901 1010
902 sync_tsc_bp(cpu);
903
904 /* Unleash the CPU! */ 1011 /* Unleash the CPU! */
905 Dprintk("waiting for cpu %d\n", cpu); 1012 Dprintk("waiting for cpu %d\n", cpu);
906 1013
@@ -923,4 +1030,6 @@ void __cpuinit smp_cpus_done(unsigned int max_cpus)
923 1030
924 detect_siblings(); 1031 detect_siblings();
925 time_init_gtod(); 1032 time_init_gtod();
1033
1034 check_nmi_watchdog();
926} 1035}
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 0e3b60e1ac5b..735b6767c8ed 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -26,6 +26,8 @@
26#include <linux/sysdev.h> 26#include <linux/sysdev.h>
27#include <linux/bcd.h> 27#include <linux/bcd.h>
28#include <linux/kallsyms.h> 28#include <linux/kallsyms.h>
29#include <linux/acpi.h>
30#include <acpi/achware.h> /* for PM timer frequency */
29#include <asm/8253pit.h> 31#include <asm/8253pit.h>
30#include <asm/pgtable.h> 32#include <asm/pgtable.h>
31#include <asm/vsyscall.h> 33#include <asm/vsyscall.h>
@@ -396,6 +398,10 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
396 (offset - vxtime.last)*(NSEC_PER_SEC/HZ) / hpet_tick; 398 (offset - vxtime.last)*(NSEC_PER_SEC/HZ) / hpet_tick;
397 399
398 vxtime.last = offset; 400 vxtime.last = offset;
401#ifdef CONFIG_X86_PM_TIMER
402 } else if (vxtime.mode == VXTIME_PMTMR) {
403 lost = pmtimer_mark_offset();
404#endif
399 } else { 405 } else {
400 offset = (((tsc - vxtime.last_tsc) * 406 offset = (((tsc - vxtime.last_tsc) *
401 vxtime.tsc_quot) >> 32) - (USEC_PER_SEC / HZ); 407 vxtime.tsc_quot) >> 32) - (USEC_PER_SEC / HZ);
@@ -898,6 +904,13 @@ void __init time_init(void)
898 hpet_period; 904 hpet_period;
899 cpu_khz = hpet_calibrate_tsc(); 905 cpu_khz = hpet_calibrate_tsc();
900 timename = "HPET"; 906 timename = "HPET";
907#ifdef CONFIG_X86_PM_TIMER
908 } else if (pmtmr_ioport) {
909 vxtime_hz = PM_TIMER_FREQUENCY;
910 timename = "PM";
911 pit_init();
912 cpu_khz = pit_calibrate_tsc();
913#endif
901 } else { 914 } else {
902 pit_init(); 915 pit_init();
903 cpu_khz = pit_calibrate_tsc(); 916 cpu_khz = pit_calibrate_tsc();
@@ -923,35 +936,50 @@ void __init time_init(void)
923} 936}
924 937
925/* 938/*
939 * Make an educated guess if the TSC is trustworthy and synchronized
940 * over all CPUs.
941 */
942static __init int unsynchronized_tsc(void)
943{
944#ifdef CONFIG_SMP
945 if (oem_force_hpet_timer())
946 return 1;
947 /* Intel systems are normally all synchronized. Exceptions
948 are handled in the OEM check above. */
949 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
950 return 0;
951 /* All in a single socket - should be synchronized */
952 if (cpus_weight(cpu_core_map[0]) == num_online_cpus())
953 return 0;
954#endif
955 /* Assume multi socket systems are not synchronized */
956 return num_online_cpus() > 1;
957}
958
959/*
926 * Decide after all CPUs are booted what mode gettimeofday should use. 960 * Decide after all CPUs are booted what mode gettimeofday should use.
927 */ 961 */
928void __init time_init_gtod(void) 962void __init time_init_gtod(void)
929{ 963{
930 char *timetype; 964 char *timetype;
931 965
932 /* 966 if (unsynchronized_tsc())
933 * AMD systems with more than one CPU don't have fully synchronized
934 * TSCs. Always use HPET gettimeofday for these, although it is slower.
935 * Intel SMP systems usually have synchronized TSCs, so use always
936 * the TSC.
937 *
938 * Exceptions:
939 * IBM Summit2 checked by oem_force_hpet_timer().
940 * AMD dual core may also not need HPET. Check me.
941 *
942 * Can be turned off with "notsc".
943 */
944 if (num_online_cpus() > 1 &&
945 boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
946 notsc = 1;
947 /* Some systems will want to disable TSC and use HPET. */
948 if (oem_force_hpet_timer())
949 notsc = 1; 967 notsc = 1;
950 if (vxtime.hpet_address && notsc) { 968 if (vxtime.hpet_address && notsc) {
951 timetype = "HPET"; 969 timetype = "HPET";
952 vxtime.last = hpet_readl(HPET_T0_CMP) - hpet_tick; 970 vxtime.last = hpet_readl(HPET_T0_CMP) - hpet_tick;
953 vxtime.mode = VXTIME_HPET; 971 vxtime.mode = VXTIME_HPET;
954 do_gettimeoffset = do_gettimeoffset_hpet; 972 do_gettimeoffset = do_gettimeoffset_hpet;
973#ifdef CONFIG_X86_PM_TIMER
974 /* Using PM for gettimeofday is quite slow, but we have no other
975 choice because the TSC is too unreliable on some systems. */
976 } else if (pmtmr_ioport && !vxtime.hpet_address && notsc) {
977 timetype = "PM";
978 do_gettimeoffset = do_gettimeoffset_pm;
979 vxtime.mode = VXTIME_PMTMR;
980 sysctl_vsyscall = 0;
981 printk(KERN_INFO "Disabling vsyscall due to use of PM timer\n");
982#endif
955 } else { 983 } else {
956 timetype = vxtime.hpet_address ? "HPET/TSC" : "PIT/TSC"; 984 timetype = vxtime.hpet_address ? "HPET/TSC" : "PIT/TSC";
957 vxtime.mode = VXTIME_TSC; 985 vxtime.mode = VXTIME_TSC;
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index 65a37f52c56e..3dfec8fdabcd 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -332,10 +332,12 @@ void handle_BUG(struct pt_regs *regs)
332 printk(KERN_ALERT "Kernel BUG at %.50s:%d\n", f.filename, f.line); 332 printk(KERN_ALERT "Kernel BUG at %.50s:%d\n", f.filename, f.line);
333} 333}
334 334
335#ifdef CONFIG_BUG
335void out_of_line_bug(void) 336void out_of_line_bug(void)
336{ 337{
337 BUG(); 338 BUG();
338} 339}
340#endif
339 341
340static DEFINE_SPINLOCK(die_lock); 342static DEFINE_SPINLOCK(die_lock);
341static int die_owner = -1; 343static int die_owner = -1;
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
index b4b8dc59663a..2e5734425949 100644
--- a/arch/x86_64/kernel/vsyscall.c
+++ b/arch/x86_64/kernel/vsyscall.c
@@ -65,7 +65,7 @@ static force_inline void do_vgettimeofday(struct timeval * tv)
65 usec = (__xtime.tv_nsec / 1000) + 65 usec = (__xtime.tv_nsec / 1000) +
66 (__jiffies - __wall_jiffies) * (1000000 / HZ); 66 (__jiffies - __wall_jiffies) * (1000000 / HZ);
67 67
68 if (__vxtime.mode == VXTIME_TSC) { 68 if (__vxtime.mode != VXTIME_HPET) {
69 sync_core(); 69 sync_core();
70 rdtscll(t); 70 rdtscll(t);
71 if (t < __vxtime.last_tsc) 71 if (t < __vxtime.last_tsc)
@@ -217,8 +217,9 @@ static int __init vsyscall_init(void)
217 BUG_ON((unsigned long) &vtime != VSYSCALL_ADDR(__NR_vtime)); 217 BUG_ON((unsigned long) &vtime != VSYSCALL_ADDR(__NR_vtime));
218 BUG_ON((VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE))); 218 BUG_ON((VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)));
219 map_vsyscall(); 219 map_vsyscall();
220 sysctl_vsyscall = 1; 220#ifdef CONFIG_SYSCTL
221 register_sysctl_table(kernel_root_table2, 0); 221 register_sysctl_table(kernel_root_table2, 0);
222#endif
222 return 0; 223 return 0;
223} 224}
224 225
diff --git a/arch/x86_64/kernel/x8664_ksyms.c b/arch/x86_64/kernel/x8664_ksyms.c
index a43dedb58fa2..68ec03070e5a 100644
--- a/arch/x86_64/kernel/x8664_ksyms.c
+++ b/arch/x86_64/kernel/x8664_ksyms.c
@@ -193,8 +193,9 @@ EXPORT_SYMBOL(smp_num_siblings);
193extern void do_softirq_thunk(void); 193extern void do_softirq_thunk(void);
194EXPORT_SYMBOL(do_softirq_thunk); 194EXPORT_SYMBOL(do_softirq_thunk);
195 195
196void out_of_line_bug(void); 196#ifdef CONFIG_BUG
197EXPORT_SYMBOL(out_of_line_bug); 197EXPORT_SYMBOL(out_of_line_bug);
198#endif
198 199
199EXPORT_SYMBOL(init_level4_pgt); 200EXPORT_SYMBOL(init_level4_pgt);
200 201
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index e03309216764..5d6b2114cc9a 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -234,6 +234,8 @@ static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs,
234 234
235/* 235/*
236 * Handle a fault on the vmalloc or module mapping area 236 * Handle a fault on the vmalloc or module mapping area
237 *
238 * This assumes no large pages in there.
237 */ 239 */
238static int vmalloc_fault(unsigned long address) 240static int vmalloc_fault(unsigned long address)
239{ 241{
@@ -272,7 +274,10 @@ static int vmalloc_fault(unsigned long address)
272 if (!pte_present(*pte_ref)) 274 if (!pte_present(*pte_ref))
273 return -1; 275 return -1;
274 pte = pte_offset_kernel(pmd, address); 276 pte = pte_offset_kernel(pmd, address);
275 if (!pte_present(*pte) || pte_page(*pte) != pte_page(*pte_ref)) 277 /* Don't use pte_page here, because the mappings can point
278 outside mem_map, and the NUMA hash lookup cannot handle
279 that. */
280 if (!pte_present(*pte) || pte_pfn(*pte) != pte_pfn(*pte_ref))
276 BUG(); 281 BUG();
277 __flush_tlb_all(); 282 __flush_tlb_all();
278 return 0; 283 return 0;
@@ -346,7 +351,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code)
346 * protection error (error_code & 1) == 0. 351 * protection error (error_code & 1) == 0.
347 */ 352 */
348 if (unlikely(address >= TASK_SIZE)) { 353 if (unlikely(address >= TASK_SIZE)) {
349 if (!(error_code & 5)) { 354 if (!(error_code & 5) &&
355 ((address >= VMALLOC_START && address < VMALLOC_END) ||
356 (address >= MODULES_VADDR && address < MODULES_END))) {
350 if (vmalloc_fault(address) < 0) 357 if (vmalloc_fault(address) < 0)
351 goto bad_area_nosemaphore; 358 goto bad_area_nosemaphore;
352 return; 359 return;
diff --git a/arch/x86_64/mm/ioremap.c b/arch/x86_64/mm/ioremap.c
index 74ec8554b195..58aac23760ef 100644
--- a/arch/x86_64/mm/ioremap.c
+++ b/arch/x86_64/mm/ioremap.c
@@ -133,7 +133,7 @@ ioremap_change_attr(unsigned long phys_addr, unsigned long size,
133 unsigned long flags) 133 unsigned long flags)
134{ 134{
135 int err = 0; 135 int err = 0;
136 if (flags && phys_addr + size - 1 < (end_pfn_map << PAGE_SHIFT)) { 136 if (phys_addr + size - 1 < (end_pfn_map << PAGE_SHIFT)) {
137 unsigned long npages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 137 unsigned long npages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
138 unsigned long vaddr = (unsigned long) __va(phys_addr); 138 unsigned long vaddr = (unsigned long) __va(phys_addr);
139 139
@@ -214,7 +214,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
214 remove_vm_area((void *)(PAGE_MASK & (unsigned long) addr)); 214 remove_vm_area((void *)(PAGE_MASK & (unsigned long) addr));
215 return NULL; 215 return NULL;
216 } 216 }
217 if (ioremap_change_attr(phys_addr, size, flags) < 0) { 217 if (flags && ioremap_change_attr(phys_addr, size, flags) < 0) {
218 area->flags &= 0xffffff; 218 area->flags &= 0xffffff;
219 vunmap(addr); 219 vunmap(addr);
220 return NULL; 220 return NULL;
@@ -251,7 +251,7 @@ void __iomem *ioremap_nocache (unsigned long phys_addr, unsigned long size)
251 251
252void iounmap(volatile void __iomem *addr) 252void iounmap(volatile void __iomem *addr)
253{ 253{
254 struct vm_struct *p, **pprev; 254 struct vm_struct *p;
255 255
256 if (addr <= high_memory) 256 if (addr <= high_memory)
257 return; 257 return;
@@ -260,24 +260,11 @@ void iounmap(volatile void __iomem *addr)
260 return; 260 return;
261 261
262 write_lock(&vmlist_lock); 262 write_lock(&vmlist_lock);
263 for (p = vmlist, pprev = &vmlist; p != NULL; pprev = &p->next, p = *pprev) 263 p = __remove_vm_area((void *)((unsigned long)addr & PAGE_MASK));
264 if (p->addr == (void *)(PAGE_MASK & (unsigned long)addr)) 264 if (!p)
265 break; 265 printk("iounmap: bad address %p\n", addr);
266 if (!p) { 266 else if (p->flags >> 20)
267 printk("__iounmap: bad address %p\n", addr); 267 ioremap_change_attr(p->phys_addr, p->size, 0);
268 goto out_unlock;
269 }
270 *pprev = p->next;
271 unmap_vm_area(p);
272 if ((p->flags >> 20) &&
273 p->phys_addr + p->size - 1 < virt_to_phys(high_memory)) {
274 /* p->size includes the guard page, but cpa doesn't like that */
275 change_page_attr(virt_to_page(__va(p->phys_addr)),
276 p->size >> PAGE_SHIFT,
277 PAGE_KERNEL);
278 global_flush_tlb();
279 }
280out_unlock:
281 write_unlock(&vmlist_lock); 268 write_unlock(&vmlist_lock);
282 kfree(p); 269 kfree(p);
283} 270}
diff --git a/crypto/crypto_null.c b/crypto/crypto_null.c
index f691d31fa9ee..3fcf6e887e87 100644
--- a/crypto/crypto_null.c
+++ b/crypto/crypto_null.c
@@ -21,6 +21,7 @@
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <asm/scatterlist.h> 22#include <asm/scatterlist.h>
23#include <linux/crypto.h> 23#include <linux/crypto.h>
24#include <linux/string.h>
24 25
25#define NULL_KEY_SIZE 0 26#define NULL_KEY_SIZE 0
26#define NULL_BLOCK_SIZE 1 27#define NULL_BLOCK_SIZE 1
@@ -28,11 +29,13 @@
28 29
29static int null_compress(void *ctx, const u8 *src, unsigned int slen, 30static int null_compress(void *ctx, const u8 *src, unsigned int slen,
30 u8 *dst, unsigned int *dlen) 31 u8 *dst, unsigned int *dlen)
31{ return 0; } 32{
32 33 if (slen > *dlen)
33static int null_decompress(void *ctx, const u8 *src, unsigned int slen, 34 return -EINVAL;
34 u8 *dst, unsigned int *dlen) 35 memcpy(dst, src, slen);
35{ return 0; } 36 *dlen = slen;
37 return 0;
38}
36 39
37static void null_init(void *ctx) 40static void null_init(void *ctx)
38{ } 41{ }
@@ -47,11 +50,10 @@ static int null_setkey(void *ctx, const u8 *key,
47 unsigned int keylen, u32 *flags) 50 unsigned int keylen, u32 *flags)
48{ return 0; } 51{ return 0; }
49 52
50static void null_encrypt(void *ctx, u8 *dst, const u8 *src) 53static void null_crypt(void *ctx, u8 *dst, const u8 *src)
51{ } 54{
52 55 memcpy(dst, src, NULL_BLOCK_SIZE);
53static void null_decrypt(void *ctx, u8 *dst, const u8 *src) 56}
54{ }
55 57
56static struct crypto_alg compress_null = { 58static struct crypto_alg compress_null = {
57 .cra_name = "compress_null", 59 .cra_name = "compress_null",
@@ -62,7 +64,7 @@ static struct crypto_alg compress_null = {
62 .cra_list = LIST_HEAD_INIT(compress_null.cra_list), 64 .cra_list = LIST_HEAD_INIT(compress_null.cra_list),
63 .cra_u = { .compress = { 65 .cra_u = { .compress = {
64 .coa_compress = null_compress, 66 .coa_compress = null_compress,
65 .coa_decompress = null_decompress } } 67 .coa_decompress = null_compress } }
66}; 68};
67 69
68static struct crypto_alg digest_null = { 70static struct crypto_alg digest_null = {
@@ -90,8 +92,8 @@ static struct crypto_alg cipher_null = {
90 .cia_min_keysize = NULL_KEY_SIZE, 92 .cia_min_keysize = NULL_KEY_SIZE,
91 .cia_max_keysize = NULL_KEY_SIZE, 93 .cia_max_keysize = NULL_KEY_SIZE,
92 .cia_setkey = null_setkey, 94 .cia_setkey = null_setkey,
93 .cia_encrypt = null_encrypt, 95 .cia_encrypt = null_crypt,
94 .cia_decrypt = null_decrypt } } 96 .cia_decrypt = null_crypt } }
95}; 97};
96 98
97MODULE_ALIAS("compress_null"); 99MODULE_ALIAS("compress_null");
diff --git a/crypto/internal.h b/crypto/internal.h
index e68e43886d3c..964b9a60ca24 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -38,7 +38,7 @@ static inline void crypto_kunmap(void *vaddr, int out)
38 38
39static inline void crypto_yield(struct crypto_tfm *tfm) 39static inline void crypto_yield(struct crypto_tfm *tfm)
40{ 40{
41 if (!in_softirq()) 41 if (!in_atomic())
42 cond_resched(); 42 cond_resched();
43} 43}
44 44
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 0400a52d5085..670fdb5142d1 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -40,13 +40,12 @@ config ACPI
40 available at: 40 available at:
41 <http://www.acpi.info> 41 <http://www.acpi.info>
42 42
43if ACPI
44
43config ACPI_BOOT 45config ACPI_BOOT
44 bool 46 bool
45 depends on ACPI || X86_HT
46 default y 47 default y
47 48
48if ACPI
49
50config ACPI_INTERPRETER 49config ACPI_INTERPRETER
51 bool 50 bool
52 depends on !IA64_SGI_SN 51 depends on !IA64_SGI_SN
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 12b0eea63407..8093f2e00321 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -391,7 +391,6 @@ acpi_pci_irq_enable (
391 u8 pin = 0; 391 u8 pin = 0;
392 int edge_level = ACPI_LEVEL_SENSITIVE; 392 int edge_level = ACPI_LEVEL_SENSITIVE;
393 int active_high_low = ACPI_ACTIVE_LOW; 393 int active_high_low = ACPI_ACTIVE_LOW;
394 extern int via_interrupt_line_quirk;
395 char *link = NULL; 394 char *link = NULL;
396 395
397 ACPI_FUNCTION_TRACE("acpi_pci_irq_enable"); 396 ACPI_FUNCTION_TRACE("acpi_pci_irq_enable");
@@ -444,9 +443,6 @@ acpi_pci_irq_enable (
444 } 443 }
445 } 444 }
446 445
447 if (via_interrupt_line_quirk)
448 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq & 15);
449
450 dev->irq = acpi_register_gsi(irq, edge_level, active_high_low); 446 dev->irq = acpi_register_gsi(irq, edge_level, active_high_low);
451 447
452 printk(KERN_INFO PREFIX "PCI Interrupt %s[%c] -> ", 448 printk(KERN_INFO PREFIX "PCI Interrupt %s[%c] -> ",
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 6662b545e0a9..a47928a2e575 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -1,6 +1,6 @@
1# Makefile for the Linux device tree 1# Makefile for the Linux device tree
2 2
3obj-y := core.o sys.o interface.o bus.o \ 3obj-y := core.o sys.o bus.o \
4 driver.o class.o class_simple.o platform.o \ 4 driver.o class.o class_simple.o platform.o \
5 cpu.o firmware.o init.o map.o dmapool.o \ 5 cpu.o firmware.o init.o map.o dmapool.o \
6 attribute_container.o transport_class.o 6 attribute_container.o transport_class.o
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 2b3902c867da..3cb04bb04c2b 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -390,7 +390,6 @@ void device_release_driver(struct device * dev)
390 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj)); 390 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
391 sysfs_remove_link(&dev->kobj, "driver"); 391 sysfs_remove_link(&dev->kobj, "driver");
392 list_del_init(&dev->driver_list); 392 list_del_init(&dev->driver_list);
393 device_detach_shutdown(dev);
394 if (drv->remove) 393 if (drv->remove)
395 drv->remove(dev); 394 drv->remove(dev);
396 dev->driver = NULL; 395 dev->driver = NULL;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 268a9c8d168b..fbc223486f81 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -31,8 +31,6 @@ int (*platform_notify_remove)(struct device * dev) = NULL;
31#define to_dev(obj) container_of(obj, struct device, kobj) 31#define to_dev(obj) container_of(obj, struct device, kobj)
32#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) 32#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
33 33
34extern struct attribute * dev_default_attrs[];
35
36static ssize_t 34static ssize_t
37dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) 35dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
38{ 36{
@@ -89,7 +87,6 @@ static void device_release(struct kobject * kobj)
89static struct kobj_type ktype_device = { 87static struct kobj_type ktype_device = {
90 .release = device_release, 88 .release = device_release,
91 .sysfs_ops = &dev_sysfs_ops, 89 .sysfs_ops = &dev_sysfs_ops,
92 .default_attrs = dev_default_attrs,
93}; 90};
94 91
95 92
@@ -248,6 +245,7 @@ int device_add(struct device *dev)
248 245
249 if ((error = kobject_add(&dev->kobj))) 246 if ((error = kobject_add(&dev->kobj)))
250 goto Error; 247 goto Error;
248 kobject_hotplug(&dev->kobj, KOBJ_ADD);
251 if ((error = device_pm_add(dev))) 249 if ((error = device_pm_add(dev)))
252 goto PMError; 250 goto PMError;
253 if ((error = bus_add_device(dev))) 251 if ((error = bus_add_device(dev)))
@@ -260,14 +258,13 @@ int device_add(struct device *dev)
260 /* notify platform of device entry */ 258 /* notify platform of device entry */
261 if (platform_notify) 259 if (platform_notify)
262 platform_notify(dev); 260 platform_notify(dev);
263
264 kobject_hotplug(&dev->kobj, KOBJ_ADD);
265 Done: 261 Done:
266 put_device(dev); 262 put_device(dev);
267 return error; 263 return error;
268 BusError: 264 BusError:
269 device_pm_remove(dev); 265 device_pm_remove(dev);
270 PMError: 266 PMError:
267 kobject_hotplug(&dev->kobj, KOBJ_REMOVE);
271 kobject_del(&dev->kobj); 268 kobject_del(&dev->kobj);
272 Error: 269 Error:
273 if (parent) 270 if (parent)
diff --git a/drivers/base/interface.c b/drivers/base/interface.c
deleted file mode 100644
index bd515843a0cb..000000000000
--- a/drivers/base/interface.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * drivers/base/interface.c - common driverfs interface that's exported to
3 * the world for all devices.
4 *
5 * Copyright (c) 2002-3 Patrick Mochel
6 * Copyright (c) 2002-3 Open Source Development Labs
7 *
8 * This file is released under the GPLv2
9 *
10 */
11
12#include <linux/device.h>
13#include <linux/err.h>
14#include <linux/stat.h>
15#include <linux/string.h>
16
17/**
18 * detach_state - control the default power state for the device.
19 *
20 * This is the state the device enters when it's driver module is
21 * unloaded. The value is an unsigned integer, in the range of 0-4.
22 * '0' indicates 'On', so no action will be taken when the driver is
23 * unloaded. This is the default behavior.
24 * '4' indicates 'Off', meaning the driver core will call the driver's
25 * shutdown method to quiesce the device.
26 * 1-3 indicate a low-power state for the device to enter via the
27 * driver's suspend method.
28 */
29
30static ssize_t detach_show(struct device * dev, char * buf)
31{
32 return sprintf(buf, "%u\n", dev->detach_state);
33}
34
35static ssize_t detach_store(struct device * dev, const char * buf, size_t n)
36{
37 u32 state;
38 state = simple_strtoul(buf, NULL, 10);
39 if (state > 4)
40 return -EINVAL;
41 dev->detach_state = state;
42 return n;
43}
44
45static DEVICE_ATTR(detach_state, 0644, detach_show, detach_store);
46
47
48struct attribute * dev_default_attrs[] = {
49 &dev_attr_detach_state.attr,
50 NULL,
51};
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index e5eda746f2a6..2e700d795cf1 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -1,18 +1,7 @@
1
2
3enum {
4 DEVICE_PM_ON,
5 DEVICE_PM1,
6 DEVICE_PM2,
7 DEVICE_PM3,
8 DEVICE_PM_OFF,
9};
10
11/* 1/*
12 * shutdown.c 2 * shutdown.c
13 */ 3 */
14 4
15extern int device_detach_shutdown(struct device *);
16extern void device_shutdown(void); 5extern void device_shutdown(void);
17 6
18 7
diff --git a/drivers/base/power/resume.c b/drivers/base/power/resume.c
index f8f5055754d6..26468971ef5a 100644
--- a/drivers/base/power/resume.c
+++ b/drivers/base/power/resume.c
@@ -22,8 +22,17 @@ extern int sysdev_resume(void);
22 22
23int resume_device(struct device * dev) 23int resume_device(struct device * dev)
24{ 24{
25 if (dev->bus && dev->bus->resume) 25 if (dev->power.pm_parent
26 && dev->power.pm_parent->power.power_state) {
27 dev_err(dev, "PM: resume from %d, parent %s still %d\n",
28 dev->power.power_state,
29 dev->power.pm_parent->bus_id,
30 dev->power.pm_parent->power.power_state);
31 }
32 if (dev->bus && dev->bus->resume) {
33 dev_dbg(dev,"resuming\n");
26 return dev->bus->resume(dev); 34 return dev->bus->resume(dev);
35 }
27 return 0; 36 return 0;
28} 37}
29 38
diff --git a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c
index d1e023fbe169..f50a08be424b 100644
--- a/drivers/base/power/shutdown.c
+++ b/drivers/base/power/shutdown.c
@@ -19,20 +19,6 @@
19extern struct subsystem devices_subsys; 19extern struct subsystem devices_subsys;
20 20
21 21
22int device_detach_shutdown(struct device * dev)
23{
24 if (!dev->detach_state)
25 return 0;
26
27 if (dev->detach_state == DEVICE_PM_OFF) {
28 if (dev->driver && dev->driver->shutdown)
29 dev->driver->shutdown(dev);
30 return 0;
31 }
32 return dpm_runtime_suspend(dev, dev->detach_state);
33}
34
35
36/** 22/**
37 * We handle system devices differently - we suspend and shut them 23 * We handle system devices differently - we suspend and shut them
38 * down last and resume them first. That way, we don't do anything stupid like 24 * down last and resume them first. That way, we don't do anything stupid like
@@ -52,13 +38,12 @@ void device_shutdown(void)
52 struct device * dev; 38 struct device * dev;
53 39
54 down_write(&devices_subsys.rwsem); 40 down_write(&devices_subsys.rwsem);
55 list_for_each_entry_reverse(dev, &devices_subsys.kset.list, kobj.entry) { 41 list_for_each_entry_reverse(dev, &devices_subsys.kset.list,
56 pr_debug("shutting down %s: ", dev->bus_id); 42 kobj.entry) {
57 if (dev->driver && dev->driver->shutdown) { 43 if (dev->driver && dev->driver->shutdown) {
58 pr_debug("Ok\n"); 44 dev_dbg(dev, "shutdown\n");
59 dev->driver->shutdown(dev); 45 dev->driver->shutdown(dev);
60 } else 46 }
61 pr_debug("Ignored.\n");
62 } 47 }
63 up_write(&devices_subsys.rwsem); 48 up_write(&devices_subsys.rwsem);
64 49
diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c
index a0b5cf689e63..0ec44ef840be 100644
--- a/drivers/base/power/suspend.c
+++ b/drivers/base/power/suspend.c
@@ -39,12 +39,25 @@ int suspend_device(struct device * dev, pm_message_t state)
39{ 39{
40 int error = 0; 40 int error = 0;
41 41
42 dev_dbg(dev, "suspending\n"); 42 if (dev->power.power_state) {
43 dev_dbg(dev, "PM: suspend %d-->%d\n",
44 dev->power.power_state, state);
45 }
46 if (dev->power.pm_parent
47 && dev->power.pm_parent->power.power_state) {
48 dev_err(dev,
49 "PM: suspend %d->%d, parent %s already %d\n",
50 dev->power.power_state, state,
51 dev->power.pm_parent->bus_id,
52 dev->power.pm_parent->power.power_state);
53 }
43 54
44 dev->power.prev_state = dev->power.power_state; 55 dev->power.prev_state = dev->power.power_state;
45 56
46 if (dev->bus && dev->bus->suspend && !dev->power.power_state) 57 if (dev->bus && dev->bus->suspend && !dev->power.power_state) {
58 dev_dbg(dev, "suspending\n");
47 error = dev->bus->suspend(dev, state); 59 error = dev->bus->suspend(dev, state);
60 }
48 61
49 return error; 62 return error;
50} 63}
diff --git a/drivers/block/ioctl.c b/drivers/block/ioctl.c
index 5e03f5157ef9..6d7bcc9da9e7 100644
--- a/drivers/block/ioctl.c
+++ b/drivers/block/ioctl.c
@@ -237,3 +237,5 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
237 } 237 }
238 return ret; 238 return ret;
239} 239}
240
241EXPORT_SYMBOL_GPL(blkdev_ioctl);
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 1a1fa3ccb913..bc56770bcc90 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -914,8 +914,10 @@ static int pkt_handle_queue(struct pktcdvd_device *pd)
914 bio = node->bio; 914 bio = node->bio;
915 zone = ZONE(bio->bi_sector, pd); 915 zone = ZONE(bio->bi_sector, pd);
916 list_for_each_entry(p, &pd->cdrw.pkt_active_list, list) { 916 list_for_each_entry(p, &pd->cdrw.pkt_active_list, list) {
917 if (p->sector == zone) 917 if (p->sector == zone) {
918 bio = NULL;
918 goto try_next_bio; 919 goto try_next_bio;
920 }
919 } 921 }
920 break; 922 break;
921try_next_bio: 923try_next_bio:
@@ -2019,7 +2021,13 @@ static int pkt_open(struct inode *inode, struct file *file)
2019 BUG_ON(pd->refcnt < 0); 2021 BUG_ON(pd->refcnt < 0);
2020 2022
2021 pd->refcnt++; 2023 pd->refcnt++;
2022 if (pd->refcnt == 1) { 2024 if (pd->refcnt > 1) {
2025 if ((file->f_mode & FMODE_WRITE) &&
2026 !test_bit(PACKET_WRITABLE, &pd->flags)) {
2027 ret = -EBUSY;
2028 goto out_dec;
2029 }
2030 } else {
2023 if (pkt_open_dev(pd, file->f_mode & FMODE_WRITE)) { 2031 if (pkt_open_dev(pd, file->f_mode & FMODE_WRITE)) {
2024 ret = -EIO; 2032 ret = -EIO;
2025 goto out_dec; 2033 goto out_dec;
@@ -2406,7 +2414,7 @@ static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
2406 case CDROM_LAST_WRITTEN: 2414 case CDROM_LAST_WRITTEN:
2407 case CDROM_SEND_PACKET: 2415 case CDROM_SEND_PACKET:
2408 case SCSI_IOCTL_SEND_COMMAND: 2416 case SCSI_IOCTL_SEND_COMMAND:
2409 return ioctl_by_bdev(pd->bdev, cmd, arg); 2417 return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg);
2410 2418
2411 case CDROMEJECT: 2419 case CDROMEJECT:
2412 /* 2420 /*
@@ -2414,7 +2422,7 @@ static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
2414 * have to unlock it or else the eject command fails. 2422 * have to unlock it or else the eject command fails.
2415 */ 2423 */
2416 pkt_lock_door(pd, 0); 2424 pkt_lock_door(pd, 0);
2417 return ioctl_by_bdev(pd->bdev, cmd, arg); 2425 return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg);
2418 2426
2419 default: 2427 default:
2420 printk("pktcdvd: Unknown ioctl for %s (%x)\n", pd->name, cmd); 2428 printk("pktcdvd: Unknown ioctl for %s (%x)\n", pd->name, cmd);
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 49d67f5384a2..6dc765dc5413 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -44,6 +44,7 @@
44#include <linux/ipmi.h> 44#include <linux/ipmi.h>
45#include <asm/semaphore.h> 45#include <asm/semaphore.h>
46#include <linux/init.h> 46#include <linux/init.h>
47#include <linux/device.h>
47 48
48#define IPMI_DEVINTF_VERSION "v33" 49#define IPMI_DEVINTF_VERSION "v33"
49 50
@@ -519,15 +520,21 @@ MODULE_PARM_DESC(ipmi_major, "Sets the major number of the IPMI device. By"
519 " interface. Other values will set the major device number" 520 " interface. Other values will set the major device number"
520 " to that value."); 521 " to that value.");
521 522
523static struct class_simple *ipmi_class;
524
522static void ipmi_new_smi(int if_num) 525static void ipmi_new_smi(int if_num)
523{ 526{
524 devfs_mk_cdev(MKDEV(ipmi_major, if_num), 527 dev_t dev = MKDEV(ipmi_major, if_num);
525 S_IFCHR | S_IRUSR | S_IWUSR, 528
529 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
526 "ipmidev/%d", if_num); 530 "ipmidev/%d", if_num);
531
532 class_simple_device_add(ipmi_class, dev, NULL, "ipmi%d", if_num);
527} 533}
528 534
529static void ipmi_smi_gone(int if_num) 535static void ipmi_smi_gone(int if_num)
530{ 536{
537 class_simple_device_remove(MKDEV(ipmi_major, if_num));
531 devfs_remove("ipmidev/%d", if_num); 538 devfs_remove("ipmidev/%d", if_num);
532} 539}
533 540
@@ -548,8 +555,15 @@ static __init int init_ipmi_devintf(void)
548 printk(KERN_INFO "ipmi device interface version " 555 printk(KERN_INFO "ipmi device interface version "
549 IPMI_DEVINTF_VERSION "\n"); 556 IPMI_DEVINTF_VERSION "\n");
550 557
558 ipmi_class = class_simple_create(THIS_MODULE, "ipmi");
559 if (IS_ERR(ipmi_class)) {
560 printk(KERN_ERR "ipmi: can't register device class\n");
561 return PTR_ERR(ipmi_class);
562 }
563
551 rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops); 564 rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops);
552 if (rv < 0) { 565 if (rv < 0) {
566 class_simple_destroy(ipmi_class);
553 printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major); 567 printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major);
554 return rv; 568 return rv;
555 } 569 }
@@ -563,6 +577,7 @@ static __init int init_ipmi_devintf(void)
563 rv = ipmi_smi_watcher_register(&smi_watcher); 577 rv = ipmi_smi_watcher_register(&smi_watcher);
564 if (rv) { 578 if (rv) {
565 unregister_chrdev(ipmi_major, DEVICE_NAME); 579 unregister_chrdev(ipmi_major, DEVICE_NAME);
580 class_simple_destroy(ipmi_class);
566 printk(KERN_WARNING "ipmi: can't register smi watcher\n"); 581 printk(KERN_WARNING "ipmi: can't register smi watcher\n");
567 return rv; 582 return rv;
568 } 583 }
@@ -573,6 +588,7 @@ module_init(init_ipmi_devintf);
573 588
574static __exit void cleanup_ipmi(void) 589static __exit void cleanup_ipmi(void)
575{ 590{
591 class_simple_destroy(ipmi_class);
576 ipmi_smi_watcher_unregister(&smi_watcher); 592 ipmi_smi_watcher_unregister(&smi_watcher);
577 devfs_remove(DEVICE_NAME); 593 devfs_remove(DEVICE_NAME);
578 unregister_chrdev(ipmi_major, DEVICE_NAME); 594 unregister_chrdev(ipmi_major, DEVICE_NAME);
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index a2e33ec79615..ca5f42bcaad9 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -122,7 +122,7 @@ raw_ioctl(struct inode *inode, struct file *filp,
122{ 122{
123 struct block_device *bdev = filp->private_data; 123 struct block_device *bdev = filp->private_data;
124 124
125 return ioctl_by_bdev(bdev, command, arg); 125 return blkdev_ioctl(bdev->bd_inode, NULL, command, arg);
126} 126}
127 127
128static void bind_device(struct raw_config_request *rq) 128static void bind_device(struct raw_config_request *rq)
diff --git a/drivers/char/watchdog/i8xx_tco.c b/drivers/char/watchdog/i8xx_tco.c
index c337978dc966..b14d642439ed 100644
--- a/drivers/char/watchdog/i8xx_tco.c
+++ b/drivers/char/watchdog/i8xx_tco.c
@@ -382,6 +382,7 @@ static struct pci_device_id i8xx_tco_pci_tbl[] = {
382 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_2, PCI_ANY_ID, PCI_ANY_ID, }, 382 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_2, PCI_ANY_ID, PCI_ANY_ID, },
383 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, PCI_ANY_ID, PCI_ANY_ID, }, 383 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, PCI_ANY_ID, PCI_ANY_ID, },
384 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, PCI_ANY_ID, PCI_ANY_ID, }, 384 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, PCI_ANY_ID, PCI_ANY_ID, },
385 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, PCI_ANY_ID, PCI_ANY_ID, },
385 { 0, }, /* End of list */ 386 { 0, }, /* End of list */
386}; 387};
387MODULE_DEVICE_TABLE (pci, i8xx_tco_pci_tbl); 388MODULE_DEVICE_TABLE (pci, i8xx_tco_pci_tbl);
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c
index dd0d4c463146..867d443e7133 100644
--- a/drivers/i2c/busses/i2c-keywest.c
+++ b/drivers/i2c/busses/i2c-keywest.c
@@ -516,6 +516,11 @@ create_iface(struct device_node *np, struct device *dev)
516 u32 *psteps, *prate; 516 u32 *psteps, *prate;
517 int rc; 517 int rc;
518 518
519 if (np->n_intrs < 1 || np->n_addrs < 1) {
520 printk(KERN_ERR "%s: Missing interrupt or address !\n",
521 np->full_name);
522 return -ENODEV;
523 }
519 if (pmac_low_i2c_lock(np)) 524 if (pmac_low_i2c_lock(np))
520 return -ENODEV; 525 return -ENODEV;
521 526
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 33a020faeabd..78e3e7b24d7d 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1932,6 +1932,9 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1932 1932
1933 /* 1933 /*
1934 * check if dma is safe 1934 * check if dma is safe
1935 *
1936 * NOTE! The "len" and "addr" checks should possibly have
1937 * separate masks.
1935 */ 1938 */
1936 if ((rq->data_len & mask) || (addr & mask)) 1939 if ((rq->data_len & mask) || (addr & mask))
1937 info->dma = 0; 1940 info->dma = 0;
@@ -3255,16 +3258,12 @@ sector_t ide_cdrom_capacity (ide_drive_t *drive)
3255 return capacity * sectors_per_frame; 3258 return capacity * sectors_per_frame;
3256} 3259}
3257 3260
3258static 3261static int ide_cd_remove(struct device *dev)
3259int ide_cdrom_cleanup(ide_drive_t *drive)
3260{ 3262{
3263 ide_drive_t *drive = to_ide_device(dev);
3261 struct cdrom_info *info = drive->driver_data; 3264 struct cdrom_info *info = drive->driver_data;
3262 3265
3263 if (ide_unregister_subdriver(drive)) { 3266 ide_unregister_subdriver(drive, info->driver);
3264 printk(KERN_ERR "%s: %s: failed to ide_unregister_subdriver\n",
3265 __FUNCTION__, drive->name);
3266 return 1;
3267 }
3268 3267
3269 del_gendisk(info->disk); 3268 del_gendisk(info->disk);
3270 3269
@@ -3297,7 +3296,7 @@ static void ide_cd_release(struct kref *kref)
3297 kfree(info); 3296 kfree(info);
3298} 3297}
3299 3298
3300static int ide_cdrom_attach (ide_drive_t *drive); 3299static int ide_cd_probe(struct device *);
3301 3300
3302#ifdef CONFIG_PROC_FS 3301#ifdef CONFIG_PROC_FS
3303static int proc_idecd_read_capacity 3302static int proc_idecd_read_capacity
@@ -3320,19 +3319,20 @@ static ide_proc_entry_t idecd_proc[] = {
3320 3319
3321static ide_driver_t ide_cdrom_driver = { 3320static ide_driver_t ide_cdrom_driver = {
3322 .owner = THIS_MODULE, 3321 .owner = THIS_MODULE,
3323 .name = "ide-cdrom", 3322 .gen_driver = {
3323 .name = "ide-cdrom",
3324 .bus = &ide_bus_type,
3325 .probe = ide_cd_probe,
3326 .remove = ide_cd_remove,
3327 },
3324 .version = IDECD_VERSION, 3328 .version = IDECD_VERSION,
3325 .media = ide_cdrom, 3329 .media = ide_cdrom,
3326 .busy = 0,
3327 .supports_dsc_overlap = 1, 3330 .supports_dsc_overlap = 1,
3328 .cleanup = ide_cdrom_cleanup,
3329 .do_request = ide_do_rw_cdrom, 3331 .do_request = ide_do_rw_cdrom,
3330 .end_request = ide_end_request, 3332 .end_request = ide_end_request,
3331 .error = __ide_error, 3333 .error = __ide_error,
3332 .abort = __ide_abort, 3334 .abort = __ide_abort,
3333 .proc = idecd_proc, 3335 .proc = idecd_proc,
3334 .attach = ide_cdrom_attach,
3335 .drives = LIST_HEAD_INIT(ide_cdrom_driver.drives),
3336}; 3336};
3337 3337
3338static int idecd_open(struct inode * inode, struct file * file) 3338static int idecd_open(struct inode * inode, struct file * file)
@@ -3418,8 +3418,9 @@ static char *ignore = NULL;
3418module_param(ignore, charp, 0400); 3418module_param(ignore, charp, 0400);
3419MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); 3419MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
3420 3420
3421static int ide_cdrom_attach (ide_drive_t *drive) 3421static int ide_cd_probe(struct device *dev)
3422{ 3422{
3423 ide_drive_t *drive = to_ide_device(dev);
3423 struct cdrom_info *info; 3424 struct cdrom_info *info;
3424 struct gendisk *g; 3425 struct gendisk *g;
3425 struct request_sense sense; 3426 struct request_sense sense;
@@ -3453,11 +3454,8 @@ static int ide_cdrom_attach (ide_drive_t *drive)
3453 3454
3454 ide_init_disk(g, drive); 3455 ide_init_disk(g, drive);
3455 3456
3456 if (ide_register_subdriver(drive, &ide_cdrom_driver)) { 3457 ide_register_subdriver(drive, &ide_cdrom_driver);
3457 printk(KERN_ERR "%s: Failed to register the driver with ide.c\n", 3458
3458 drive->name);
3459 goto out_put_disk;
3460 }
3461 memset(info, 0, sizeof (struct cdrom_info)); 3459 memset(info, 0, sizeof (struct cdrom_info));
3462 3460
3463 kref_init(&info->kref); 3461 kref_init(&info->kref);
@@ -3470,7 +3468,6 @@ static int ide_cdrom_attach (ide_drive_t *drive)
3470 3468
3471 drive->driver_data = info; 3469 drive->driver_data = info;
3472 3470
3473 DRIVER(drive)->busy++;
3474 g->minors = 1; 3471 g->minors = 1;
3475 snprintf(g->devfs_name, sizeof(g->devfs_name), 3472 snprintf(g->devfs_name, sizeof(g->devfs_name),
3476 "%s/cd", drive->devfs_name); 3473 "%s/cd", drive->devfs_name);
@@ -3478,8 +3475,7 @@ static int ide_cdrom_attach (ide_drive_t *drive)
3478 g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE; 3475 g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE;
3479 if (ide_cdrom_setup(drive)) { 3476 if (ide_cdrom_setup(drive)) {
3480 struct cdrom_device_info *devinfo = &info->devinfo; 3477 struct cdrom_device_info *devinfo = &info->devinfo;
3481 DRIVER(drive)->busy--; 3478 ide_unregister_subdriver(drive, &ide_cdrom_driver);
3482 ide_unregister_subdriver(drive);
3483 if (info->buffer != NULL) 3479 if (info->buffer != NULL)
3484 kfree(info->buffer); 3480 kfree(info->buffer);
3485 if (info->toc != NULL) 3481 if (info->toc != NULL)
@@ -3492,7 +3488,6 @@ static int ide_cdrom_attach (ide_drive_t *drive)
3492 drive->driver_data = NULL; 3488 drive->driver_data = NULL;
3493 goto failed; 3489 goto failed;
3494 } 3490 }
3495 DRIVER(drive)->busy--;
3496 3491
3497 cdrom_read_toc(drive, &sense); 3492 cdrom_read_toc(drive, &sense);
3498 g->fops = &idecd_ops; 3493 g->fops = &idecd_ops;
@@ -3500,23 +3495,20 @@ static int ide_cdrom_attach (ide_drive_t *drive)
3500 add_disk(g); 3495 add_disk(g);
3501 return 0; 3496 return 0;
3502 3497
3503out_put_disk:
3504 put_disk(g);
3505out_free_cd: 3498out_free_cd:
3506 kfree(info); 3499 kfree(info);
3507failed: 3500failed:
3508 return 1; 3501 return -ENODEV;
3509} 3502}
3510 3503
3511static void __exit ide_cdrom_exit(void) 3504static void __exit ide_cdrom_exit(void)
3512{ 3505{
3513 ide_unregister_driver(&ide_cdrom_driver); 3506 driver_unregister(&ide_cdrom_driver.gen_driver);
3514} 3507}
3515 3508
3516static int ide_cdrom_init(void) 3509static int ide_cdrom_init(void)
3517{ 3510{
3518 ide_register_driver(&ide_cdrom_driver); 3511 return driver_register(&ide_cdrom_driver.gen_driver);
3519 return 0;
3520} 3512}
3521 3513
3522module_init(ide_cdrom_init); 3514module_init(ide_cdrom_init);
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 5d54f7756100..3302cd8eab4c 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1024,14 +1024,16 @@ static void ide_cacheflush_p(ide_drive_t *drive)
1024 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); 1024 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name);
1025} 1025}
1026 1026
1027static int idedisk_cleanup (ide_drive_t *drive) 1027static int ide_disk_remove(struct device *dev)
1028{ 1028{
1029 ide_drive_t *drive = to_ide_device(dev);
1029 struct ide_disk_obj *idkp = drive->driver_data; 1030 struct ide_disk_obj *idkp = drive->driver_data;
1030 struct gendisk *g = idkp->disk; 1031 struct gendisk *g = idkp->disk;
1031 1032
1032 ide_cacheflush_p(drive); 1033 ide_cacheflush_p(drive);
1033 if (ide_unregister_subdriver(drive)) 1034
1034 return 1; 1035 ide_unregister_subdriver(drive, idkp->driver);
1036
1035 del_gendisk(g); 1037 del_gendisk(g);
1036 1038
1037 ide_disk_put(idkp); 1039 ide_disk_put(idkp);
@@ -1052,7 +1054,7 @@ static void ide_disk_release(struct kref *kref)
1052 kfree(idkp); 1054 kfree(idkp);
1053} 1055}
1054 1056
1055static int idedisk_attach(ide_drive_t *drive); 1057static int ide_disk_probe(struct device *dev);
1056 1058
1057static void ide_device_shutdown(struct device *dev) 1059static void ide_device_shutdown(struct device *dev)
1058{ 1060{
@@ -1082,27 +1084,23 @@ static void ide_device_shutdown(struct device *dev)
1082 dev->bus->suspend(dev, PMSG_SUSPEND); 1084 dev->bus->suspend(dev, PMSG_SUSPEND);
1083} 1085}
1084 1086
1085/*
1086 * IDE subdriver functions, registered with ide.c
1087 */
1088static ide_driver_t idedisk_driver = { 1087static ide_driver_t idedisk_driver = {
1089 .owner = THIS_MODULE, 1088 .owner = THIS_MODULE,
1090 .gen_driver = { 1089 .gen_driver = {
1090 .name = "ide-disk",
1091 .bus = &ide_bus_type,
1092 .probe = ide_disk_probe,
1093 .remove = ide_disk_remove,
1091 .shutdown = ide_device_shutdown, 1094 .shutdown = ide_device_shutdown,
1092 }, 1095 },
1093 .name = "ide-disk",
1094 .version = IDEDISK_VERSION, 1096 .version = IDEDISK_VERSION,
1095 .media = ide_disk, 1097 .media = ide_disk,
1096 .busy = 0,
1097 .supports_dsc_overlap = 0, 1098 .supports_dsc_overlap = 0,
1098 .cleanup = idedisk_cleanup,
1099 .do_request = ide_do_rw_disk, 1099 .do_request = ide_do_rw_disk,
1100 .end_request = ide_end_request, 1100 .end_request = ide_end_request,
1101 .error = __ide_error, 1101 .error = __ide_error,
1102 .abort = __ide_abort, 1102 .abort = __ide_abort,
1103 .proc = idedisk_proc, 1103 .proc = idedisk_proc,
1104 .attach = idedisk_attach,
1105 .drives = LIST_HEAD_INIT(idedisk_driver.drives),
1106}; 1104};
1107 1105
1108static int idedisk_open(struct inode *inode, struct file *filp) 1106static int idedisk_open(struct inode *inode, struct file *filp)
@@ -1199,8 +1197,9 @@ static struct block_device_operations idedisk_ops = {
1199 1197
1200MODULE_DESCRIPTION("ATA DISK Driver"); 1198MODULE_DESCRIPTION("ATA DISK Driver");
1201 1199
1202static int idedisk_attach(ide_drive_t *drive) 1200static int ide_disk_probe(struct device *dev)
1203{ 1201{
1202 ide_drive_t *drive = to_ide_device(dev);
1204 struct ide_disk_obj *idkp; 1203 struct ide_disk_obj *idkp;
1205 struct gendisk *g; 1204 struct gendisk *g;
1206 1205
@@ -1222,10 +1221,7 @@ static int idedisk_attach(ide_drive_t *drive)
1222 1221
1223 ide_init_disk(g, drive); 1222 ide_init_disk(g, drive);
1224 1223
1225 if (ide_register_subdriver(drive, &idedisk_driver)) { 1224 ide_register_subdriver(drive, &idedisk_driver);
1226 printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name);
1227 goto out_put_disk;
1228 }
1229 1225
1230 memset(idkp, 0, sizeof(*idkp)); 1226 memset(idkp, 0, sizeof(*idkp));
1231 1227
@@ -1239,7 +1235,6 @@ static int idedisk_attach(ide_drive_t *drive)
1239 1235
1240 drive->driver_data = idkp; 1236 drive->driver_data = idkp;
1241 1237
1242 DRIVER(drive)->busy++;
1243 idedisk_setup(drive); 1238 idedisk_setup(drive);
1244 if ((!drive->head || drive->head > 16) && !drive->select.b.lba) { 1239 if ((!drive->head || drive->head > 16) && !drive->select.b.lba) {
1245 printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", 1240 printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n",
@@ -1247,7 +1242,7 @@ static int idedisk_attach(ide_drive_t *drive)
1247 drive->attach = 0; 1242 drive->attach = 0;
1248 } else 1243 } else
1249 drive->attach = 1; 1244 drive->attach = 1;
1250 DRIVER(drive)->busy--; 1245
1251 g->minors = 1 << PARTN_BITS; 1246 g->minors = 1 << PARTN_BITS;
1252 strcpy(g->devfs_name, drive->devfs_name); 1247 strcpy(g->devfs_name, drive->devfs_name);
1253 g->driverfs_dev = &drive->gendev; 1248 g->driverfs_dev = &drive->gendev;
@@ -1257,22 +1252,20 @@ static int idedisk_attach(ide_drive_t *drive)
1257 add_disk(g); 1252 add_disk(g);
1258 return 0; 1253 return 0;
1259 1254
1260out_put_disk:
1261 put_disk(g);
1262out_free_idkp: 1255out_free_idkp:
1263 kfree(idkp); 1256 kfree(idkp);
1264failed: 1257failed:
1265 return 1; 1258 return -ENODEV;
1266} 1259}
1267 1260
1268static void __exit idedisk_exit (void) 1261static void __exit idedisk_exit (void)
1269{ 1262{
1270 ide_unregister_driver(&idedisk_driver); 1263 driver_unregister(&idedisk_driver.gen_driver);
1271} 1264}
1272 1265
1273static int idedisk_init (void) 1266static int idedisk_init (void)
1274{ 1267{
1275 return ide_register_driver(&idedisk_driver); 1268 return driver_register(&idedisk_driver.gen_driver);
1276} 1269}
1277 1270
1278module_init(idedisk_init); 1271module_init(idedisk_init);
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 36c0b74a4e45..c949e98df4b6 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1865,13 +1865,13 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
1865 idefloppy_add_settings(drive); 1865 idefloppy_add_settings(drive);
1866} 1866}
1867 1867
1868static int idefloppy_cleanup (ide_drive_t *drive) 1868static int ide_floppy_remove(struct device *dev)
1869{ 1869{
1870 ide_drive_t *drive = to_ide_device(dev);
1870 idefloppy_floppy_t *floppy = drive->driver_data; 1871 idefloppy_floppy_t *floppy = drive->driver_data;
1871 struct gendisk *g = floppy->disk; 1872 struct gendisk *g = floppy->disk;
1872 1873
1873 if (ide_unregister_subdriver(drive)) 1874 ide_unregister_subdriver(drive, floppy->driver);
1874 return 1;
1875 1875
1876 del_gendisk(g); 1876 del_gendisk(g);
1877 1877
@@ -1916,26 +1916,24 @@ static ide_proc_entry_t idefloppy_proc[] = {
1916 1916
1917#endif /* CONFIG_PROC_FS */ 1917#endif /* CONFIG_PROC_FS */
1918 1918
1919static int idefloppy_attach(ide_drive_t *drive); 1919static int ide_floppy_probe(struct device *);
1920 1920
1921/*
1922 * IDE subdriver functions, registered with ide.c
1923 */
1924static ide_driver_t idefloppy_driver = { 1921static ide_driver_t idefloppy_driver = {
1925 .owner = THIS_MODULE, 1922 .owner = THIS_MODULE,
1926 .name = "ide-floppy", 1923 .gen_driver = {
1924 .name = "ide-floppy",
1925 .bus = &ide_bus_type,
1926 .probe = ide_floppy_probe,
1927 .remove = ide_floppy_remove,
1928 },
1927 .version = IDEFLOPPY_VERSION, 1929 .version = IDEFLOPPY_VERSION,
1928 .media = ide_floppy, 1930 .media = ide_floppy,
1929 .busy = 0,
1930 .supports_dsc_overlap = 0, 1931 .supports_dsc_overlap = 0,
1931 .cleanup = idefloppy_cleanup,
1932 .do_request = idefloppy_do_request, 1932 .do_request = idefloppy_do_request,
1933 .end_request = idefloppy_do_end_request, 1933 .end_request = idefloppy_do_end_request,
1934 .error = __ide_error, 1934 .error = __ide_error,
1935 .abort = __ide_abort, 1935 .abort = __ide_abort,
1936 .proc = idefloppy_proc, 1936 .proc = idefloppy_proc,
1937 .attach = idefloppy_attach,
1938 .drives = LIST_HEAD_INIT(idefloppy_driver.drives),
1939}; 1937};
1940 1938
1941static int idefloppy_open(struct inode *inode, struct file *filp) 1939static int idefloppy_open(struct inode *inode, struct file *filp)
@@ -2122,8 +2120,9 @@ static struct block_device_operations idefloppy_ops = {
2122 .revalidate_disk= idefloppy_revalidate_disk 2120 .revalidate_disk= idefloppy_revalidate_disk
2123}; 2121};
2124 2122
2125static int idefloppy_attach (ide_drive_t *drive) 2123static int ide_floppy_probe(struct device *dev)
2126{ 2124{
2125 ide_drive_t *drive = to_ide_device(dev);
2127 idefloppy_floppy_t *floppy; 2126 idefloppy_floppy_t *floppy;
2128 struct gendisk *g; 2127 struct gendisk *g;
2129 2128
@@ -2152,10 +2151,7 @@ static int idefloppy_attach (ide_drive_t *drive)
2152 2151
2153 ide_init_disk(g, drive); 2152 ide_init_disk(g, drive);
2154 2153
2155 if (ide_register_subdriver(drive, &idefloppy_driver)) { 2154 ide_register_subdriver(drive, &idefloppy_driver);
2156 printk (KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name);
2157 goto out_put_disk;
2158 }
2159 2155
2160 memset(floppy, 0, sizeof(*floppy)); 2156 memset(floppy, 0, sizeof(*floppy));
2161 2157
@@ -2169,9 +2165,8 @@ static int idefloppy_attach (ide_drive_t *drive)
2169 2165
2170 drive->driver_data = floppy; 2166 drive->driver_data = floppy;
2171 2167
2172 DRIVER(drive)->busy++;
2173 idefloppy_setup (drive, floppy); 2168 idefloppy_setup (drive, floppy);
2174 DRIVER(drive)->busy--; 2169
2175 g->minors = 1 << PARTN_BITS; 2170 g->minors = 1 << PARTN_BITS;
2176 g->driverfs_dev = &drive->gendev; 2171 g->driverfs_dev = &drive->gendev;
2177 strcpy(g->devfs_name, drive->devfs_name); 2172 strcpy(g->devfs_name, drive->devfs_name);
@@ -2181,19 +2176,17 @@ static int idefloppy_attach (ide_drive_t *drive)
2181 add_disk(g); 2176 add_disk(g);
2182 return 0; 2177 return 0;
2183 2178
2184out_put_disk:
2185 put_disk(g);
2186out_free_floppy: 2179out_free_floppy:
2187 kfree(floppy); 2180 kfree(floppy);
2188failed: 2181failed:
2189 return 1; 2182 return -ENODEV;
2190} 2183}
2191 2184
2192MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); 2185MODULE_DESCRIPTION("ATAPI FLOPPY Driver");
2193 2186
2194static void __exit idefloppy_exit (void) 2187static void __exit idefloppy_exit (void)
2195{ 2188{
2196 ide_unregister_driver(&idefloppy_driver); 2189 driver_unregister(&idefloppy_driver.gen_driver);
2197} 2190}
2198 2191
2199/* 2192/*
@@ -2202,8 +2195,7 @@ static void __exit idefloppy_exit (void)
2202static int idefloppy_init (void) 2195static int idefloppy_init (void)
2203{ 2196{
2204 printk("ide-floppy driver " IDEFLOPPY_VERSION "\n"); 2197 printk("ide-floppy driver " IDEFLOPPY_VERSION "\n");
2205 ide_register_driver(&idefloppy_driver); 2198 return driver_register(&idefloppy_driver.gen_driver);
2206 return 0;
2207} 2199}
2208 2200
2209module_init(idefloppy_init); 2201module_init(idefloppy_init);
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 554473a95cf7..5d876f53c697 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -47,6 +47,7 @@
47#include <linux/slab.h> 47#include <linux/slab.h>
48#include <linux/delay.h> 48#include <linux/delay.h>
49#include <linux/ide.h> 49#include <linux/ide.h>
50#include <linux/devfs_fs_kernel.h>
50#include <linux/spinlock.h> 51#include <linux/spinlock.h>
51#include <linux/kmod.h> 52#include <linux/kmod.h>
52#include <linux/pci.h> 53#include <linux/pci.h>
@@ -696,13 +697,13 @@ static int wait_hwif_ready(ide_hwif_t *hwif)
696 SELECT_DRIVE(&hwif->drives[0]); 697 SELECT_DRIVE(&hwif->drives[0]);
697 hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]); 698 hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]);
698 mdelay(2); 699 mdelay(2);
699 rc = ide_wait_not_busy(hwif, 10000); 700 rc = ide_wait_not_busy(hwif, 35000);
700 if (rc) 701 if (rc)
701 return rc; 702 return rc;
702 SELECT_DRIVE(&hwif->drives[1]); 703 SELECT_DRIVE(&hwif->drives[1]);
703 hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]); 704 hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]);
704 mdelay(2); 705 mdelay(2);
705 rc = ide_wait_not_busy(hwif, 10000); 706 rc = ide_wait_not_busy(hwif, 35000);
706 707
707 /* Exit function with master reselected (let's be sane) */ 708 /* Exit function with master reselected (let's be sane) */
708 SELECT_DRIVE(&hwif->drives[0]); 709 SELECT_DRIVE(&hwif->drives[0]);
@@ -918,7 +919,7 @@ int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)
918 want them on default or a new "empty" class 919 want them on default or a new "empty" class
919 for hotplug reprobing ? */ 920 for hotplug reprobing ? */
920 if (drive->present) { 921 if (drive->present) {
921 ata_attach(drive); 922 device_register(&drive->gendev);
922 } 923 }
923 } 924 }
924 } 925 }
@@ -1279,10 +1280,51 @@ void ide_init_disk(struct gendisk *disk, ide_drive_t *drive)
1279 1280
1280EXPORT_SYMBOL_GPL(ide_init_disk); 1281EXPORT_SYMBOL_GPL(ide_init_disk);
1281 1282
1283static void ide_remove_drive_from_hwgroup(ide_drive_t *drive)
1284{
1285 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup;
1286
1287 if (drive == drive->next) {
1288 /* special case: last drive from hwgroup. */
1289 BUG_ON(hwgroup->drive != drive);
1290 hwgroup->drive = NULL;
1291 } else {
1292 ide_drive_t *walk;
1293
1294 walk = hwgroup->drive;
1295 while (walk->next != drive)
1296 walk = walk->next;
1297 walk->next = drive->next;
1298 if (hwgroup->drive == drive) {
1299 hwgroup->drive = drive->next;
1300 hwgroup->hwif = hwgroup->drive->hwif;
1301 }
1302 }
1303 BUG_ON(hwgroup->drive == drive);
1304}
1305
1282static void drive_release_dev (struct device *dev) 1306static void drive_release_dev (struct device *dev)
1283{ 1307{
1284 ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); 1308 ide_drive_t *drive = container_of(dev, ide_drive_t, gendev);
1285 1309
1310 spin_lock_irq(&ide_lock);
1311 if (drive->devfs_name[0] != '\0') {
1312 devfs_remove(drive->devfs_name);
1313 drive->devfs_name[0] = '\0';
1314 }
1315 ide_remove_drive_from_hwgroup(drive);
1316 if (drive->id != NULL) {
1317 kfree(drive->id);
1318 drive->id = NULL;
1319 }
1320 drive->present = 0;
1321 /* Messed up locking ... */
1322 spin_unlock_irq(&ide_lock);
1323 blk_cleanup_queue(drive->queue);
1324 spin_lock_irq(&ide_lock);
1325 drive->queue = NULL;
1326 spin_unlock_irq(&ide_lock);
1327
1286 up(&drive->gendev_rel_sem); 1328 up(&drive->gendev_rel_sem);
1287} 1329}
1288 1330
@@ -1306,7 +1348,6 @@ static void init_gendisk (ide_hwif_t *hwif)
1306 drive->gendev.driver_data = drive; 1348 drive->gendev.driver_data = drive;
1307 drive->gendev.release = drive_release_dev; 1349 drive->gendev.release = drive_release_dev;
1308 if (drive->present) { 1350 if (drive->present) {
1309 device_register(&drive->gendev);
1310 sprintf(drive->devfs_name, "ide/host%d/bus%d/target%d/lun%d", 1351 sprintf(drive->devfs_name, "ide/host%d/bus%d/target%d/lun%d",
1311 (hwif->channel && hwif->mate) ? 1352 (hwif->channel && hwif->mate) ?
1312 hwif->mate->index : hwif->index, 1353 hwif->mate->index : hwif->index,
@@ -1412,7 +1453,7 @@ int ideprobe_init (void)
1412 hwif->chipset = ide_generic; 1453 hwif->chipset = ide_generic;
1413 for (unit = 0; unit < MAX_DRIVES; ++unit) 1454 for (unit = 0; unit < MAX_DRIVES; ++unit)
1414 if (hwif->drives[unit].present) 1455 if (hwif->drives[unit].present)
1415 ata_attach(&hwif->drives[unit]); 1456 device_register(&hwif->drives[unit].gendev);
1416 } 1457 }
1417 } 1458 }
1418 return 0; 1459 return 0;
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index bdff5ac58053..4063d2c34e3d 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -307,17 +307,41 @@ static int proc_ide_read_driver
307 (char *page, char **start, off_t off, int count, int *eof, void *data) 307 (char *page, char **start, off_t off, int count, int *eof, void *data)
308{ 308{
309 ide_drive_t *drive = (ide_drive_t *) data; 309 ide_drive_t *drive = (ide_drive_t *) data;
310 ide_driver_t *driver = drive->driver; 310 struct device *dev = &drive->gendev;
311 ide_driver_t *ide_drv;
311 int len; 312 int len;
312 313
313 if (driver) { 314 down_read(&dev->bus->subsys.rwsem);
315 if (dev->driver) {
316 ide_drv = container_of(dev->driver, ide_driver_t, gen_driver);
314 len = sprintf(page, "%s version %s\n", 317 len = sprintf(page, "%s version %s\n",
315 driver->name, driver->version); 318 dev->driver->name, ide_drv->version);
316 } else 319 } else
317 len = sprintf(page, "ide-default version 0.9.newide\n"); 320 len = sprintf(page, "ide-default version 0.9.newide\n");
321 up_read(&dev->bus->subsys.rwsem);
318 PROC_IDE_READ_RETURN(page,start,off,count,eof,len); 322 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
319} 323}
320 324
325static int ide_replace_subdriver(ide_drive_t *drive, const char *driver)
326{
327 struct device *dev = &drive->gendev;
328 int ret = 1;
329
330 down_write(&dev->bus->subsys.rwsem);
331 device_release_driver(dev);
332 /* FIXME: device can still be in use by previous driver */
333 strlcpy(drive->driver_req, driver, sizeof(drive->driver_req));
334 device_attach(dev);
335 drive->driver_req[0] = 0;
336 if (dev->driver == NULL)
337 device_attach(dev);
338 if (dev->driver && !strcmp(dev->driver->name, driver))
339 ret = 0;
340 up_write(&dev->bus->subsys.rwsem);
341
342 return ret;
343}
344
321static int proc_ide_write_driver 345static int proc_ide_write_driver
322 (struct file *file, const char __user *buffer, unsigned long count, void *data) 346 (struct file *file, const char __user *buffer, unsigned long count, void *data)
323{ 347{
@@ -488,16 +512,32 @@ void destroy_proc_ide_interface(ide_hwif_t *hwif)
488 } 512 }
489} 513}
490 514
491extern struct seq_operations ide_drivers_op; 515static int proc_print_driver(struct device_driver *drv, void *data)
516{
517 ide_driver_t *ide_drv = container_of(drv, ide_driver_t, gen_driver);
518 struct seq_file *s = data;
519
520 seq_printf(s, "%s version %s\n", drv->name, ide_drv->version);
521
522 return 0;
523}
524
525static int ide_drivers_show(struct seq_file *s, void *p)
526{
527 bus_for_each_drv(&ide_bus_type, NULL, s, proc_print_driver);
528 return 0;
529}
530
492static int ide_drivers_open(struct inode *inode, struct file *file) 531static int ide_drivers_open(struct inode *inode, struct file *file)
493{ 532{
494 return seq_open(file, &ide_drivers_op); 533 return single_open(file, &ide_drivers_show, NULL);
495} 534}
535
496static struct file_operations ide_drivers_operations = { 536static struct file_operations ide_drivers_operations = {
497 .open = ide_drivers_open, 537 .open = ide_drivers_open,
498 .read = seq_read, 538 .read = seq_read,
499 .llseek = seq_lseek, 539 .llseek = seq_lseek,
500 .release = seq_release, 540 .release = single_release,
501}; 541};
502 542
503void proc_ide_create(void) 543void proc_ide_create(void)
@@ -516,6 +556,6 @@ void proc_ide_create(void)
516 556
517void proc_ide_destroy(void) 557void proc_ide_destroy(void)
518{ 558{
519 remove_proc_entry("ide/drivers", proc_ide_root); 559 remove_proc_entry("drivers", proc_ide_root);
520 remove_proc_entry("ide", NULL); 560 remove_proc_entry("ide", NULL);
521} 561}
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 482544854985..5a3dc46008e6 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4681,21 +4681,12 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor)
4681 idetape_add_settings(drive); 4681 idetape_add_settings(drive);
4682} 4682}
4683 4683
4684static int idetape_cleanup (ide_drive_t *drive) 4684static int ide_tape_remove(struct device *dev)
4685{ 4685{
4686 ide_drive_t *drive = to_ide_device(dev);
4686 idetape_tape_t *tape = drive->driver_data; 4687 idetape_tape_t *tape = drive->driver_data;
4687 unsigned long flags;
4688
4689 spin_lock_irqsave(&ide_lock, flags);
4690 if (test_bit(IDETAPE_BUSY, &tape->flags) || drive->usage ||
4691 tape->first_stage != NULL || tape->merge_stage_size) {
4692 spin_unlock_irqrestore(&ide_lock, flags);
4693 return 1;
4694 }
4695 4688
4696 spin_unlock_irqrestore(&ide_lock, flags); 4689 ide_unregister_subdriver(drive, tape->driver);
4697 DRIVER(drive)->busy = 0;
4698 (void) ide_unregister_subdriver(drive);
4699 4690
4700 ide_unregister_region(tape->disk); 4691 ide_unregister_region(tape->disk);
4701 4692
@@ -4710,6 +4701,8 @@ static void ide_tape_release(struct kref *kref)
4710 ide_drive_t *drive = tape->drive; 4701 ide_drive_t *drive = tape->drive;
4711 struct gendisk *g = tape->disk; 4702 struct gendisk *g = tape->disk;
4712 4703
4704 BUG_ON(tape->first_stage != NULL || tape->merge_stage_size);
4705
4713 drive->dsc_overlap = 0; 4706 drive->dsc_overlap = 0;
4714 drive->driver_data = NULL; 4707 drive->driver_data = NULL;
4715 devfs_remove("%s/mt", drive->devfs_name); 4708 devfs_remove("%s/mt", drive->devfs_name);
@@ -4747,26 +4740,24 @@ static ide_proc_entry_t idetape_proc[] = {
4747 4740
4748#endif 4741#endif
4749 4742
4750static int idetape_attach(ide_drive_t *drive); 4743static int ide_tape_probe(struct device *);
4751 4744
4752/*
4753 * IDE subdriver functions, registered with ide.c
4754 */
4755static ide_driver_t idetape_driver = { 4745static ide_driver_t idetape_driver = {
4756 .owner = THIS_MODULE, 4746 .owner = THIS_MODULE,
4757 .name = "ide-tape", 4747 .gen_driver = {
4748 .name = "ide-tape",
4749 .bus = &ide_bus_type,
4750 .probe = ide_tape_probe,
4751 .remove = ide_tape_remove,
4752 },
4758 .version = IDETAPE_VERSION, 4753 .version = IDETAPE_VERSION,
4759 .media = ide_tape, 4754 .media = ide_tape,
4760 .busy = 1,
4761 .supports_dsc_overlap = 1, 4755 .supports_dsc_overlap = 1,
4762 .cleanup = idetape_cleanup,
4763 .do_request = idetape_do_request, 4756 .do_request = idetape_do_request,
4764 .end_request = idetape_end_request, 4757 .end_request = idetape_end_request,
4765 .error = __ide_error, 4758 .error = __ide_error,
4766 .abort = __ide_abort, 4759 .abort = __ide_abort,
4767 .proc = idetape_proc, 4760 .proc = idetape_proc,
4768 .attach = idetape_attach,
4769 .drives = LIST_HEAD_INIT(idetape_driver.drives),
4770}; 4761};
4771 4762
4772/* 4763/*
@@ -4829,8 +4820,9 @@ static struct block_device_operations idetape_block_ops = {
4829 .ioctl = idetape_ioctl, 4820 .ioctl = idetape_ioctl,
4830}; 4821};
4831 4822
4832static int idetape_attach (ide_drive_t *drive) 4823static int ide_tape_probe(struct device *dev)
4833{ 4824{
4825 ide_drive_t *drive = to_ide_device(dev);
4834 idetape_tape_t *tape; 4826 idetape_tape_t *tape;
4835 struct gendisk *g; 4827 struct gendisk *g;
4836 int minor; 4828 int minor;
@@ -4865,10 +4857,7 @@ static int idetape_attach (ide_drive_t *drive)
4865 4857
4866 ide_init_disk(g, drive); 4858 ide_init_disk(g, drive);
4867 4859
4868 if (ide_register_subdriver(drive, &idetape_driver)) { 4860 ide_register_subdriver(drive, &idetape_driver);
4869 printk(KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name);
4870 goto out_put_disk;
4871 }
4872 4861
4873 memset(tape, 0, sizeof(*tape)); 4862 memset(tape, 0, sizeof(*tape));
4874 4863
@@ -4902,12 +4891,11 @@ static int idetape_attach (ide_drive_t *drive)
4902 ide_register_region(g); 4891 ide_register_region(g);
4903 4892
4904 return 0; 4893 return 0;
4905out_put_disk: 4894
4906 put_disk(g);
4907out_free_tape: 4895out_free_tape:
4908 kfree(tape); 4896 kfree(tape);
4909failed: 4897failed:
4910 return 1; 4898 return -ENODEV;
4911} 4899}
4912 4900
4913MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver"); 4901MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver");
@@ -4915,7 +4903,7 @@ MODULE_LICENSE("GPL");
4915 4903
4916static void __exit idetape_exit (void) 4904static void __exit idetape_exit (void)
4917{ 4905{
4918 ide_unregister_driver(&idetape_driver); 4906 driver_unregister(&idetape_driver.gen_driver);
4919 unregister_chrdev(IDETAPE_MAJOR, "ht"); 4907 unregister_chrdev(IDETAPE_MAJOR, "ht");
4920} 4908}
4921 4909
@@ -4928,8 +4916,7 @@ static int idetape_init (void)
4928 printk(KERN_ERR "ide-tape: Failed to register character device interface\n"); 4916 printk(KERN_ERR "ide-tape: Failed to register character device interface\n");
4929 return -EBUSY; 4917 return -EBUSY;
4930 } 4918 }
4931 ide_register_driver(&idetape_driver); 4919 return driver_register(&idetape_driver.gen_driver);
4932 return 0;
4933} 4920}
4934 4921
4935module_init(idetape_init); 4922module_init(idetape_init);
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 973dec799b5c..dae1bd5b8c3e 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -196,8 +196,6 @@ ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */
196 196
197EXPORT_SYMBOL(ide_hwifs); 197EXPORT_SYMBOL(ide_hwifs);
198 198
199static struct list_head ide_drives = LIST_HEAD_INIT(ide_drives);
200
201/* 199/*
202 * Do not even *think* about calling this! 200 * Do not even *think* about calling this!
203 */ 201 */
@@ -358,54 +356,6 @@ static int ide_system_bus_speed(void)
358 return system_bus_speed; 356 return system_bus_speed;
359} 357}
360 358
361/*
362 * drives_lock protects the list of drives, drivers_lock the
363 * list of drivers. Currently nobody takes both at once.
364 */
365
366static DEFINE_SPINLOCK(drives_lock);
367static DEFINE_SPINLOCK(drivers_lock);
368static LIST_HEAD(drivers);
369
370/* Iterator for the driver list. */
371
372static void *m_start(struct seq_file *m, loff_t *pos)
373{
374 struct list_head *p;
375 loff_t l = *pos;
376 spin_lock(&drivers_lock);
377 list_for_each(p, &drivers)
378 if (!l--)
379 return list_entry(p, ide_driver_t, drivers);
380 return NULL;
381}
382
383static void *m_next(struct seq_file *m, void *v, loff_t *pos)
384{
385 struct list_head *p = ((ide_driver_t *)v)->drivers.next;
386 (*pos)++;
387 return p==&drivers ? NULL : list_entry(p, ide_driver_t, drivers);
388}
389
390static void m_stop(struct seq_file *m, void *v)
391{
392 spin_unlock(&drivers_lock);
393}
394
395static int show_driver(struct seq_file *m, void *v)
396{
397 ide_driver_t *driver = v;
398 seq_printf(m, "%s version %s\n", driver->name, driver->version);
399 return 0;
400}
401
402struct seq_operations ide_drivers_op = {
403 .start = m_start,
404 .next = m_next,
405 .stop = m_stop,
406 .show = show_driver
407};
408
409#ifdef CONFIG_PROC_FS 359#ifdef CONFIG_PROC_FS
410struct proc_dir_entry *proc_ide_root; 360struct proc_dir_entry *proc_ide_root;
411#endif 361#endif
@@ -630,7 +580,7 @@ void ide_unregister(unsigned int index)
630 ide_hwif_t *hwif, *g; 580 ide_hwif_t *hwif, *g;
631 static ide_hwif_t tmp_hwif; /* protected by ide_cfg_sem */ 581 static ide_hwif_t tmp_hwif; /* protected by ide_cfg_sem */
632 ide_hwgroup_t *hwgroup; 582 ide_hwgroup_t *hwgroup;
633 int irq_count = 0, unit, i; 583 int irq_count = 0, unit;
634 584
635 BUG_ON(index >= MAX_HWIFS); 585 BUG_ON(index >= MAX_HWIFS);
636 586
@@ -643,23 +593,22 @@ void ide_unregister(unsigned int index)
643 goto abort; 593 goto abort;
644 for (unit = 0; unit < MAX_DRIVES; ++unit) { 594 for (unit = 0; unit < MAX_DRIVES; ++unit) {
645 drive = &hwif->drives[unit]; 595 drive = &hwif->drives[unit];
646 if (!drive->present) 596 if (!drive->present) {
597 if (drive->devfs_name[0] != '\0') {
598 devfs_remove(drive->devfs_name);
599 drive->devfs_name[0] = '\0';
600 }
647 continue; 601 continue;
648 if (drive->usage || DRIVER(drive)->busy) 602 }
649 goto abort; 603 spin_unlock_irq(&ide_lock);
650 drive->dead = 1; 604 device_unregister(&drive->gendev);
605 down(&drive->gendev_rel_sem);
606 spin_lock_irq(&ide_lock);
651 } 607 }
652 hwif->present = 0; 608 hwif->present = 0;
653 609
654 spin_unlock_irq(&ide_lock); 610 spin_unlock_irq(&ide_lock);
655 611
656 for (unit = 0; unit < MAX_DRIVES; ++unit) {
657 drive = &hwif->drives[unit];
658 if (!drive->present)
659 continue;
660 DRIVER(drive)->cleanup(drive);
661 }
662
663 destroy_proc_ide_interface(hwif); 612 destroy_proc_ide_interface(hwif);
664 613
665 hwgroup = hwif->hwgroup; 614 hwgroup = hwif->hwgroup;
@@ -687,44 +636,6 @@ void ide_unregister(unsigned int index)
687 * Remove us from the hwgroup, and free 636 * Remove us from the hwgroup, and free
688 * the hwgroup if we were the only member 637 * the hwgroup if we were the only member
689 */ 638 */
690 for (i = 0; i < MAX_DRIVES; ++i) {
691 drive = &hwif->drives[i];
692 if (drive->devfs_name[0] != '\0') {
693 devfs_remove(drive->devfs_name);
694 drive->devfs_name[0] = '\0';
695 }
696 if (!drive->present)
697 continue;
698 if (drive == drive->next) {
699 /* special case: last drive from hwgroup. */
700 BUG_ON(hwgroup->drive != drive);
701 hwgroup->drive = NULL;
702 } else {
703 ide_drive_t *walk;
704
705 walk = hwgroup->drive;
706 while (walk->next != drive)
707 walk = walk->next;
708 walk->next = drive->next;
709 if (hwgroup->drive == drive) {
710 hwgroup->drive = drive->next;
711 hwgroup->hwif = HWIF(hwgroup->drive);
712 }
713 }
714 BUG_ON(hwgroup->drive == drive);
715 if (drive->id != NULL) {
716 kfree(drive->id);
717 drive->id = NULL;
718 }
719 drive->present = 0;
720 /* Messed up locking ... */
721 spin_unlock_irq(&ide_lock);
722 blk_cleanup_queue(drive->queue);
723 device_unregister(&drive->gendev);
724 down(&drive->gendev_rel_sem);
725 spin_lock_irq(&ide_lock);
726 drive->queue = NULL;
727 }
728 if (hwif->next == hwif) { 639 if (hwif->next == hwif) {
729 BUG_ON(hwgroup->hwif != hwif); 640 BUG_ON(hwgroup->hwif != hwif);
730 kfree(hwgroup); 641 kfree(hwgroup);
@@ -1304,73 +1215,6 @@ int system_bus_clock (void)
1304 1215
1305EXPORT_SYMBOL(system_bus_clock); 1216EXPORT_SYMBOL(system_bus_clock);
1306 1217
1307/*
1308 * Locking is badly broken here - since way back. That sucker is
1309 * root-only, but that's not an excuse... The real question is what
1310 * exclusion rules do we want here.
1311 */
1312int ide_replace_subdriver (ide_drive_t *drive, const char *driver)
1313{
1314 if (!drive->present || drive->usage || drive->dead)
1315 goto abort;
1316 if (DRIVER(drive)->cleanup(drive))
1317 goto abort;
1318 strlcpy(drive->driver_req, driver, sizeof(drive->driver_req));
1319 if (ata_attach(drive)) {
1320 spin_lock(&drives_lock);
1321 list_del_init(&drive->list);
1322 spin_unlock(&drives_lock);
1323 drive->driver_req[0] = 0;
1324 ata_attach(drive);
1325 } else {
1326 drive->driver_req[0] = 0;
1327 }
1328 if (drive->driver && !strcmp(drive->driver->name, driver))
1329 return 0;
1330abort:
1331 return 1;
1332}
1333
1334/**
1335 * ata_attach - attach an ATA/ATAPI device
1336 * @drive: drive to attach
1337 *
1338 * Takes a drive that is as yet not assigned to any midlayer IDE
1339 * driver (or is assigned to the default driver) and figures out
1340 * which driver would like to own it. If nobody claims the drive
1341 * then it is automatically attached to the default driver used for
1342 * unclaimed objects.
1343 *
1344 * A return of zero indicates attachment to a driver, of one
1345 * attachment to the default driver.
1346 *
1347 * Takes drivers_lock.
1348 */
1349
1350int ata_attach(ide_drive_t *drive)
1351{
1352 struct list_head *p;
1353 spin_lock(&drivers_lock);
1354 list_for_each(p, &drivers) {
1355 ide_driver_t *driver = list_entry(p, ide_driver_t, drivers);
1356 if (!try_module_get(driver->owner))
1357 continue;
1358 spin_unlock(&drivers_lock);
1359 if (driver->attach(drive) == 0) {
1360 module_put(driver->owner);
1361 drive->gendev.driver = &driver->gen_driver;
1362 return 0;
1363 }
1364 spin_lock(&drivers_lock);
1365 module_put(driver->owner);
1366 }
1367 drive->gendev.driver = NULL;
1368 spin_unlock(&drivers_lock);
1369 if (ide_register_subdriver(drive, NULL))
1370 panic("ide: default attach failed");
1371 return 1;
1372}
1373
1374static int generic_ide_suspend(struct device *dev, pm_message_t state) 1218static int generic_ide_suspend(struct device *dev, pm_message_t state)
1375{ 1219{
1376 ide_drive_t *drive = dev->driver_data; 1220 ide_drive_t *drive = dev->driver_data;
@@ -2013,27 +1857,11 @@ static void __init probe_for_hwifs (void)
2013#endif 1857#endif
2014} 1858}
2015 1859
2016int ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver) 1860void ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver)
2017{ 1861{
2018 unsigned long flags;
2019
2020 spin_lock_irqsave(&ide_lock, flags);
2021 if (!drive->present || drive->driver != NULL ||
2022 drive->usage || drive->dead) {
2023 spin_unlock_irqrestore(&ide_lock, flags);
2024 return 1;
2025 }
2026 drive->driver = driver;
2027 spin_unlock_irqrestore(&ide_lock, flags);
2028 spin_lock(&drives_lock);
2029 list_add_tail(&drive->list, driver ? &driver->drives : &ide_drives);
2030 spin_unlock(&drives_lock);
2031// printk(KERN_INFO "%s: attached %s driver.\n", drive->name, driver->name);
2032#ifdef CONFIG_PROC_FS 1862#ifdef CONFIG_PROC_FS
2033 if (driver) 1863 ide_add_proc_entries(drive->proc, driver->proc, drive);
2034 ide_add_proc_entries(drive->proc, driver->proc, drive);
2035#endif 1864#endif
2036 return 0;
2037} 1865}
2038 1866
2039EXPORT_SYMBOL(ide_register_subdriver); 1867EXPORT_SYMBOL(ide_register_subdriver);
@@ -2041,136 +1869,51 @@ EXPORT_SYMBOL(ide_register_subdriver);
2041/** 1869/**
2042 * ide_unregister_subdriver - disconnect drive from driver 1870 * ide_unregister_subdriver - disconnect drive from driver
2043 * @drive: drive to unplug 1871 * @drive: drive to unplug
1872 * @driver: driver
2044 * 1873 *
2045 * Disconnect a drive from the driver it was attached to and then 1874 * Disconnect a drive from the driver it was attached to and then
2046 * clean up the various proc files and other objects attached to it. 1875 * clean up the various proc files and other objects attached to it.
2047 * 1876 *
2048 * Takes ide_setting_sem, ide_lock and drives_lock. 1877 * Takes ide_setting_sem and ide_lock.
2049 * Caller must hold none of the locks. 1878 * Caller must hold none of the locks.
2050 *
2051 * No locking versus subdriver unload because we are moving to the
2052 * default driver anyway. Wants double checking.
2053 */ 1879 */
2054 1880
2055int ide_unregister_subdriver (ide_drive_t *drive) 1881void ide_unregister_subdriver(ide_drive_t *drive, ide_driver_t *driver)
2056{ 1882{
2057 unsigned long flags; 1883 unsigned long flags;
2058 1884
2059 down(&ide_setting_sem); 1885 down(&ide_setting_sem);
2060 spin_lock_irqsave(&ide_lock, flags); 1886 spin_lock_irqsave(&ide_lock, flags);
2061 if (drive->usage || drive->driver == NULL || DRIVER(drive)->busy) {
2062 spin_unlock_irqrestore(&ide_lock, flags);
2063 up(&ide_setting_sem);
2064 return 1;
2065 }
2066#ifdef CONFIG_PROC_FS 1887#ifdef CONFIG_PROC_FS
2067 ide_remove_proc_entries(drive->proc, DRIVER(drive)->proc); 1888 ide_remove_proc_entries(drive->proc, driver->proc);
2068#endif 1889#endif
2069 auto_remove_settings(drive); 1890 auto_remove_settings(drive);
2070 drive->driver = NULL;
2071 spin_unlock_irqrestore(&ide_lock, flags); 1891 spin_unlock_irqrestore(&ide_lock, flags);
2072 up(&ide_setting_sem); 1892 up(&ide_setting_sem);
2073 spin_lock(&drives_lock);
2074 list_del_init(&drive->list);
2075 spin_unlock(&drives_lock);
2076 /* drive will be added to &ide_drives in ata_attach() */
2077 return 0;
2078} 1893}
2079 1894
2080EXPORT_SYMBOL(ide_unregister_subdriver); 1895EXPORT_SYMBOL(ide_unregister_subdriver);
2081 1896
2082static int ide_drive_remove(struct device * dev)
2083{
2084 ide_drive_t * drive = container_of(dev,ide_drive_t,gendev);
2085 DRIVER(drive)->cleanup(drive);
2086 return 0;
2087}
2088
2089/**
2090 * ide_register_driver - register IDE device driver
2091 * @driver: the IDE device driver
2092 *
2093 * Register a new device driver and then scan the devices
2094 * on the IDE bus in case any should be attached to the
2095 * driver we have just registered. If so attach them.
2096 *
2097 * Takes drivers_lock and drives_lock.
2098 */
2099
2100int ide_register_driver(ide_driver_t *driver)
2101{
2102 struct list_head list;
2103 struct list_head *list_loop;
2104 struct list_head *tmp_storage;
2105
2106 spin_lock(&drivers_lock);
2107 list_add(&driver->drivers, &drivers);
2108 spin_unlock(&drivers_lock);
2109
2110 INIT_LIST_HEAD(&list);
2111 spin_lock(&drives_lock);
2112 list_splice_init(&ide_drives, &list);
2113 spin_unlock(&drives_lock);
2114
2115 list_for_each_safe(list_loop, tmp_storage, &list) {
2116 ide_drive_t *drive = container_of(list_loop, ide_drive_t, list);
2117 list_del_init(&drive->list);
2118 if (drive->present)
2119 ata_attach(drive);
2120 }
2121 driver->gen_driver.name = (char *) driver->name;
2122 driver->gen_driver.bus = &ide_bus_type;
2123 driver->gen_driver.remove = ide_drive_remove;
2124 return driver_register(&driver->gen_driver);
2125}
2126
2127EXPORT_SYMBOL(ide_register_driver);
2128
2129/**
2130 * ide_unregister_driver - unregister IDE device driver
2131 * @driver: the IDE device driver
2132 *
2133 * Called when a driver module is being unloaded. We reattach any
2134 * devices to whatever driver claims them next (typically the default
2135 * driver).
2136 *
2137 * Takes drivers_lock and called functions will take ide_setting_sem.
2138 */
2139
2140void ide_unregister_driver(ide_driver_t *driver)
2141{
2142 ide_drive_t *drive;
2143
2144 spin_lock(&drivers_lock);
2145 list_del(&driver->drivers);
2146 spin_unlock(&drivers_lock);
2147
2148 driver_unregister(&driver->gen_driver);
2149
2150 while(!list_empty(&driver->drives)) {
2151 drive = list_entry(driver->drives.next, ide_drive_t, list);
2152 if (driver->cleanup(drive)) {
2153 printk(KERN_ERR "%s: cleanup_module() called while still busy\n", drive->name);
2154 BUG();
2155 }
2156 ata_attach(drive);
2157 }
2158}
2159
2160EXPORT_SYMBOL(ide_unregister_driver);
2161
2162/* 1897/*
2163 * Probe module 1898 * Probe module
2164 */ 1899 */
2165 1900
2166EXPORT_SYMBOL(ide_lock); 1901EXPORT_SYMBOL(ide_lock);
2167 1902
1903static int ide_bus_match(struct device *dev, struct device_driver *drv)
1904{
1905 return 1;
1906}
1907
2168struct bus_type ide_bus_type = { 1908struct bus_type ide_bus_type = {
2169 .name = "ide", 1909 .name = "ide",
1910 .match = ide_bus_match,
2170 .suspend = generic_ide_suspend, 1911 .suspend = generic_ide_suspend,
2171 .resume = generic_ide_resume, 1912 .resume = generic_ide_resume,
2172}; 1913};
2173 1914
1915EXPORT_SYMBOL_GPL(ide_bus_type);
1916
2174/* 1917/*
2175 * This is gets invoked once during initialization, to set *everything* up 1918 * This is gets invoked once during initialization, to set *everything* up
2176 */ 1919 */
diff --git a/drivers/ieee1394/Kconfig b/drivers/ieee1394/Kconfig
index 78b201fb5e8a..7d58af1ae306 100644
--- a/drivers/ieee1394/Kconfig
+++ b/drivers/ieee1394/Kconfig
@@ -84,11 +84,6 @@ config IEEE1394_PCILYNX
84 To compile this driver as a module, say M here: the 84 To compile this driver as a module, say M here: the
85 module will be called pcilynx. 85 module will be called pcilynx.
86 86
87# Non-maintained pcilynx options
88# if [ "$CONFIG_IEEE1394_PCILYNX" != "n" ]; then
89# bool ' Use PCILynx local RAM' CONFIG_IEEE1394_PCILYNX_LOCALRAM
90# bool ' Support for non-IEEE1394 local ports' CONFIG_IEEE1394_PCILYNX_PORTS
91# fi
92config IEEE1394_OHCI1394 87config IEEE1394_OHCI1394
93 tristate "OHCI-1394 support" 88 tristate "OHCI-1394 support"
94 depends on PCI && IEEE1394 89 depends on PCI && IEEE1394
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index 1c5845f7e4ab..a294e45c77cd 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -520,7 +520,7 @@ int hpsb_send_packet(struct hpsb_packet *packet)
520 520
521 if (!packet->no_waiter || packet->expect_response) { 521 if (!packet->no_waiter || packet->expect_response) {
522 atomic_inc(&packet->refcnt); 522 atomic_inc(&packet->refcnt);
523 packet->sendtime = jiffies; 523 packet->sendtime = jiffies + 10 * HZ;
524 skb_queue_tail(&host->pending_packet_queue, packet->skb); 524 skb_queue_tail(&host->pending_packet_queue, packet->skb);
525 } 525 }
526 526
@@ -1248,7 +1248,6 @@ EXPORT_SYMBOL(hpsb_make_phypacket);
1248EXPORT_SYMBOL(hpsb_make_isopacket); 1248EXPORT_SYMBOL(hpsb_make_isopacket);
1249EXPORT_SYMBOL(hpsb_read); 1249EXPORT_SYMBOL(hpsb_read);
1250EXPORT_SYMBOL(hpsb_write); 1250EXPORT_SYMBOL(hpsb_write);
1251EXPORT_SYMBOL(hpsb_lock);
1252EXPORT_SYMBOL(hpsb_packet_success); 1251EXPORT_SYMBOL(hpsb_packet_success);
1253 1252
1254/** highlevel.c **/ 1253/** highlevel.c **/
diff --git a/drivers/ieee1394/ieee1394_transactions.c b/drivers/ieee1394/ieee1394_transactions.c
index 09908b9564d8..0aa876360f9b 100644
--- a/drivers/ieee1394/ieee1394_transactions.c
+++ b/drivers/ieee1394/ieee1394_transactions.c
@@ -535,6 +535,7 @@ hpsb_write_fail:
535 return retval; 535 return retval;
536} 536}
537 537
538#if 0
538 539
539int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation, 540int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation,
540 u64 addr, int extcode, quadlet_t *data, quadlet_t arg) 541 u64 addr, int extcode, quadlet_t *data, quadlet_t arg)
@@ -599,3 +600,5 @@ int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation,
599 600
600 return retval; 601 return retval;
601} 602}
603
604#endif /* 0 */
diff --git a/drivers/ieee1394/ieee1394_transactions.h b/drivers/ieee1394/ieee1394_transactions.h
index 526a43ceb496..45ba784fe6da 100644
--- a/drivers/ieee1394/ieee1394_transactions.h
+++ b/drivers/ieee1394/ieee1394_transactions.h
@@ -53,12 +53,5 @@ int hpsb_read(struct hpsb_host *host, nodeid_t node, unsigned int generation,
53 u64 addr, quadlet_t *buffer, size_t length); 53 u64 addr, quadlet_t *buffer, size_t length);
54int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation, 54int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation,
55 u64 addr, quadlet_t *buffer, size_t length); 55 u64 addr, quadlet_t *buffer, size_t length);
56int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation,
57 u64 addr, int extcode, quadlet_t *data, quadlet_t arg);
58int hpsb_lock64(struct hpsb_host *host, nodeid_t node, unsigned int generation,
59 u64 addr, int extcode, octlet_t *data, octlet_t arg);
60int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation,
61 quadlet_t *buffer, size_t length, u32 specifier_id,
62 unsigned int version);
63 56
64#endif /* _IEEE1394_TRANSACTIONS_H */ 57#endif /* _IEEE1394_TRANSACTIONS_H */
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index a1e30a66297b..83e66ed97ab5 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -1005,8 +1005,7 @@ static struct unit_directory *nodemgr_process_unit_directory
1005 return ud; 1005 return ud;
1006 1006
1007unit_directory_error: 1007unit_directory_error:
1008 if (ud != NULL) 1008 kfree(ud);
1009 kfree(ud);
1010 return NULL; 1009 return NULL;
1011} 1010}
1012 1011
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index 6cb0b586c297..36e25ac823dc 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -2931,7 +2931,7 @@ static void free_dma_rcv_ctx(struct dma_rcv_ctx *d)
2931 kfree(d->prg_cpu); 2931 kfree(d->prg_cpu);
2932 kfree(d->prg_bus); 2932 kfree(d->prg_bus);
2933 } 2933 }
2934 if (d->spb) kfree(d->spb); 2934 kfree(d->spb);
2935 2935
2936 /* Mark this context as freed. */ 2936 /* Mark this context as freed. */
2937 d->ohci = NULL; 2937 d->ohci = NULL;
diff --git a/drivers/ieee1394/ohci1394.h b/drivers/ieee1394/ohci1394.h
index d1758d409610..cc66c1cae250 100644
--- a/drivers/ieee1394/ohci1394.h
+++ b/drivers/ieee1394/ohci1394.h
@@ -236,6 +236,9 @@ struct ti_ohci {
236 236
237static inline int cross_bound(unsigned long addr, unsigned int size) 237static inline int cross_bound(unsigned long addr, unsigned int size)
238{ 238{
239 if (size == 0)
240 return 0;
241
239 if (size > PAGE_SIZE) 242 if (size > PAGE_SIZE)
240 return 1; 243 return 1;
241 244
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
index a261d2b0e5ac..bdb3a85cafa6 100644
--- a/drivers/ieee1394/pcilynx.c
+++ b/drivers/ieee1394/pcilynx.c
@@ -43,6 +43,7 @@
43#include <linux/fs.h> 43#include <linux/fs.h>
44#include <linux/poll.h> 44#include <linux/poll.h>
45#include <linux/kdev_t.h> 45#include <linux/kdev_t.h>
46#include <linux/dma-mapping.h>
46#include <asm/byteorder.h> 47#include <asm/byteorder.h>
47#include <asm/atomic.h> 48#include <asm/atomic.h>
48#include <asm/io.h> 49#include <asm/io.h>
@@ -834,327 +835,6 @@ static int lynx_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
834 * IEEE-1394 functionality section END * 835 * IEEE-1394 functionality section END *
835 ***************************************/ 836 ***************************************/
836 837
837#ifdef CONFIG_IEEE1394_PCILYNX_PORTS
838/* VFS functions for local bus / aux device access. Access to those
839 * is implemented as a character device instead of block devices
840 * because buffers are not wanted for this. Therefore llseek (from
841 * VFS) can be used for these char devices with obvious effects.
842 */
843static int mem_open(struct inode*, struct file*);
844static int mem_release(struct inode*, struct file*);
845static unsigned int aux_poll(struct file*, struct poll_table_struct*);
846static loff_t mem_llseek(struct file*, loff_t, int);
847static ssize_t mem_read (struct file*, char*, size_t, loff_t*);
848static ssize_t mem_write(struct file*, const char*, size_t, loff_t*);
849
850
851static struct file_operations aux_ops = {
852 .owner = THIS_MODULE,
853 .read = mem_read,
854 .write = mem_write,
855 .poll = aux_poll,
856 .llseek = mem_llseek,
857 .open = mem_open,
858 .release = mem_release,
859};
860
861
862static void aux_setup_pcls(struct ti_lynx *lynx)
863{
864 struct ti_pcl pcl;
865
866 pcl.next = PCL_NEXT_INVALID;
867 pcl.user_data = pcl_bus(lynx, lynx->dmem_pcl);
868 put_pcl(lynx, lynx->dmem_pcl, &pcl);
869}
870
871static int mem_open(struct inode *inode, struct file *file)
872{
873 int cid = iminor(inode);
874 enum { t_rom, t_aux, t_ram } type;
875 struct memdata *md;
876
877 if (cid < PCILYNX_MINOR_AUX_START) {
878 /* just for completeness */
879 return -ENXIO;
880 } else if (cid < PCILYNX_MINOR_ROM_START) {
881 cid -= PCILYNX_MINOR_AUX_START;
882 if (cid >= num_of_cards || !cards[cid].aux_port)
883 return -ENXIO;
884 type = t_aux;
885 } else if (cid < PCILYNX_MINOR_RAM_START) {
886 cid -= PCILYNX_MINOR_ROM_START;
887 if (cid >= num_of_cards || !cards[cid].local_rom)
888 return -ENXIO;
889 type = t_rom;
890 } else {
891 /* WARNING: Know what you are doing when opening RAM.
892 * It is currently used inside the driver! */
893 cid -= PCILYNX_MINOR_RAM_START;
894 if (cid >= num_of_cards || !cards[cid].local_ram)
895 return -ENXIO;
896 type = t_ram;
897 }
898
899 md = (struct memdata *)kmalloc(sizeof(struct memdata), SLAB_KERNEL);
900 if (md == NULL)
901 return -ENOMEM;
902
903 md->lynx = &cards[cid];
904 md->cid = cid;
905
906 switch (type) {
907 case t_rom:
908 md->type = rom;
909 break;
910 case t_ram:
911 md->type = ram;
912 break;
913 case t_aux:
914 atomic_set(&md->aux_intr_last_seen,
915 atomic_read(&cards[cid].aux_intr_seen));
916 md->type = aux;
917 break;
918 }
919
920 file->private_data = md;
921
922 return 0;
923}
924
925static int mem_release(struct inode *inode, struct file *file)
926{
927 kfree(file->private_data);
928 return 0;
929}
930
931static unsigned int aux_poll(struct file *file, poll_table *pt)
932{
933 struct memdata *md = (struct memdata *)file->private_data;
934 int cid = md->cid;
935 unsigned int mask;
936
937 /* reading and writing is always allowed */
938 mask = POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM;
939
940 if (md->type == aux) {
941 poll_wait(file, &cards[cid].aux_intr_wait, pt);
942
943 if (atomic_read(&md->aux_intr_last_seen)
944 != atomic_read(&cards[cid].aux_intr_seen)) {
945 mask |= POLLPRI;
946 atomic_inc(&md->aux_intr_last_seen);
947 }
948 }
949
950 return mask;
951}
952
953loff_t mem_llseek(struct file *file, loff_t offs, int orig)
954{
955 loff_t newoffs;
956
957 switch (orig) {
958 case 0:
959 newoffs = offs;
960 break;
961 case 1:
962 newoffs = offs + file->f_pos;
963 break;
964 case 2:
965 newoffs = PCILYNX_MAX_MEMORY + 1 + offs;
966 break;
967 default:
968 return -EINVAL;
969 }
970
971 if (newoffs < 0 || newoffs > PCILYNX_MAX_MEMORY + 1) return -EINVAL;
972
973 file->f_pos = newoffs;
974 return newoffs;
975}
976
977/*
978 * do not DMA if count is too small because this will have a serious impact
979 * on performance - the value 2400 was found by experiment and may not work
980 * everywhere as good as here - use mem_mindma option for modules to change
981 */
982static short mem_mindma = 2400;
983module_param(mem_mindma, short, 0444);
984MODULE_PARM_DESC(mem_mindma, "Minimum amount of data required to use DMA");
985
986static ssize_t mem_dmaread(struct memdata *md, u32 physbuf, ssize_t count,
987 int offset)
988{
989 pcltmp_t pcltmp;
990 struct ti_pcl *pcl;
991 size_t retval;
992 int i;
993 DECLARE_WAITQUEUE(wait, current);
994
995 count &= ~3;
996 count = min(count, 53196);
997 retval = count;
998
999 if (reg_read(md->lynx, DMA_CHAN_CTRL(CHANNEL_LOCALBUS))
1000 & DMA_CHAN_CTRL_BUSY) {
1001 PRINT(KERN_WARNING, md->lynx->id, "DMA ALREADY ACTIVE!");
1002 }
1003
1004 reg_write(md->lynx, LBUS_ADDR, md->type | offset);
1005
1006 pcl = edit_pcl(md->lynx, md->lynx->dmem_pcl, &pcltmp);
1007 pcl->buffer[0].control = PCL_CMD_LBUS_TO_PCI | min(count, 4092);
1008 pcl->buffer[0].pointer = physbuf;
1009 count -= 4092;
1010
1011 i = 0;
1012 while (count > 0) {
1013 i++;
1014 pcl->buffer[i].control = min(count, 4092);
1015 pcl->buffer[i].pointer = physbuf + i * 4092;
1016 count -= 4092;
1017 }
1018 pcl->buffer[i].control |= PCL_LAST_BUFF;
1019 commit_pcl(md->lynx, md->lynx->dmem_pcl, &pcltmp);
1020
1021 set_current_state(TASK_INTERRUPTIBLE);
1022 add_wait_queue(&md->lynx->mem_dma_intr_wait, &wait);
1023 run_sub_pcl(md->lynx, md->lynx->dmem_pcl, 2, CHANNEL_LOCALBUS);
1024
1025 schedule();
1026 while (reg_read(md->lynx, DMA_CHAN_CTRL(CHANNEL_LOCALBUS))
1027 & DMA_CHAN_CTRL_BUSY) {
1028 if (signal_pending(current)) {
1029 retval = -EINTR;
1030 break;
1031 }
1032 schedule();
1033 }
1034
1035 reg_write(md->lynx, DMA_CHAN_CTRL(CHANNEL_LOCALBUS), 0);
1036 remove_wait_queue(&md->lynx->mem_dma_intr_wait, &wait);
1037
1038 if (reg_read(md->lynx, DMA_CHAN_CTRL(CHANNEL_LOCALBUS))
1039 & DMA_CHAN_CTRL_BUSY) {
1040 PRINT(KERN_ERR, md->lynx->id, "DMA STILL ACTIVE!");
1041 }
1042
1043 return retval;
1044}
1045
1046static ssize_t mem_read(struct file *file, char *buffer, size_t count,
1047 loff_t *offset)
1048{
1049 struct memdata *md = (struct memdata *)file->private_data;
1050 ssize_t bcount;
1051 size_t alignfix;
1052 loff_t off = *offset; /* avoid useless 64bit-arithmetic */
1053 ssize_t retval;
1054 void *membase;
1055
1056 if ((off + count) > PCILYNX_MAX_MEMORY+1) {
1057 count = PCILYNX_MAX_MEMORY+1 - off;
1058 }
1059 if (count == 0 || off > PCILYNX_MAX_MEMORY) {
1060 return -ENOSPC;
1061 }
1062
1063 switch (md->type) {
1064 case rom:
1065 membase = md->lynx->local_rom;
1066 break;
1067 case ram:
1068 membase = md->lynx->local_ram;
1069 break;
1070 case aux:
1071 membase = md->lynx->aux_port;
1072 break;
1073 default:
1074 panic("pcilynx%d: unsupported md->type %d in %s",
1075 md->lynx->id, md->type, __FUNCTION__);
1076 }
1077
1078 down(&md->lynx->mem_dma_mutex);
1079
1080 if (count < mem_mindma) {
1081 memcpy_fromio(md->lynx->mem_dma_buffer, membase+off, count);
1082 goto out;
1083 }
1084
1085 bcount = count;
1086 alignfix = 4 - (off % 4);
1087 if (alignfix != 4) {
1088 if (bcount < alignfix) {
1089 alignfix = bcount;
1090 }
1091 memcpy_fromio(md->lynx->mem_dma_buffer, membase+off,
1092 alignfix);
1093 if (bcount == alignfix) {
1094 goto out;
1095 }
1096 bcount -= alignfix;
1097 off += alignfix;
1098 }
1099
1100 while (bcount >= 4) {
1101 retval = mem_dmaread(md, md->lynx->mem_dma_buffer_dma
1102 + count - bcount, bcount, off);
1103 if (retval < 0) return retval;
1104
1105 bcount -= retval;
1106 off += retval;
1107 }
1108
1109 if (bcount) {
1110 memcpy_fromio(md->lynx->mem_dma_buffer + count - bcount,
1111 membase+off, bcount);
1112 }
1113
1114 out:
1115 retval = copy_to_user(buffer, md->lynx->mem_dma_buffer, count);
1116 up(&md->lynx->mem_dma_mutex);
1117
1118 if (retval) return -EFAULT;
1119 *offset += count;
1120 return count;
1121}
1122
1123
1124static ssize_t mem_write(struct file *file, const char *buffer, size_t count,
1125 loff_t *offset)
1126{
1127 struct memdata *md = (struct memdata *)file->private_data;
1128
1129 if (((*offset) + count) > PCILYNX_MAX_MEMORY+1) {
1130 count = PCILYNX_MAX_MEMORY+1 - *offset;
1131 }
1132 if (count == 0 || *offset > PCILYNX_MAX_MEMORY) {
1133 return -ENOSPC;
1134 }
1135
1136 /* FIXME: dereferencing pointers to PCI mem doesn't work everywhere */
1137 switch (md->type) {
1138 case aux:
1139 if (copy_from_user(md->lynx->aux_port+(*offset), buffer, count))
1140 return -EFAULT;
1141 break;
1142 case ram:
1143 if (copy_from_user(md->lynx->local_ram+(*offset), buffer, count))
1144 return -EFAULT;
1145 break;
1146 case rom:
1147 /* the ROM may be writeable */
1148 if (copy_from_user(md->lynx->local_rom+(*offset), buffer, count))
1149 return -EFAULT;
1150 break;
1151 }
1152
1153 file->f_pos += count;
1154 return count;
1155}
1156#endif /* CONFIG_IEEE1394_PCILYNX_PORTS */
1157
1158 838
1159/******************************************************** 839/********************************************************
1160 * Global stuff (interrupt handler, init/shutdown code) * 840 * Global stuff (interrupt handler, init/shutdown code) *
@@ -1181,18 +861,6 @@ static irqreturn_t lynx_irq_handler(int irq, void *dev_id,
1181 reg_write(lynx, LINK_INT_STATUS, linkint); 861 reg_write(lynx, LINK_INT_STATUS, linkint);
1182 reg_write(lynx, PCI_INT_STATUS, intmask); 862 reg_write(lynx, PCI_INT_STATUS, intmask);
1183 863
1184#ifdef CONFIG_IEEE1394_PCILYNX_PORTS
1185 if (intmask & PCI_INT_AUX_INT) {
1186 atomic_inc(&lynx->aux_intr_seen);
1187 wake_up_interruptible(&lynx->aux_intr_wait);
1188 }
1189
1190 if (intmask & PCI_INT_DMA_HLT(CHANNEL_LOCALBUS)) {
1191 wake_up_interruptible(&lynx->mem_dma_intr_wait);
1192 }
1193#endif
1194
1195
1196 if (intmask & PCI_INT_1394) { 864 if (intmask & PCI_INT_1394) {
1197 if (linkint & LINK_INT_PHY_TIMEOUT) { 865 if (linkint & LINK_INT_PHY_TIMEOUT) {
1198 PRINT(KERN_INFO, lynx->id, "PHY timeout occurred"); 866 PRINT(KERN_INFO, lynx->id, "PHY timeout occurred");
@@ -1484,15 +1152,9 @@ static void remove_card(struct pci_dev *dev)
1484 pci_free_consistent(lynx->dev, PAGE_SIZE, lynx->rcv_page, 1152 pci_free_consistent(lynx->dev, PAGE_SIZE, lynx->rcv_page,
1485 lynx->rcv_page_dma); 1153 lynx->rcv_page_dma);
1486 case have_aux_buf: 1154 case have_aux_buf:
1487#ifdef CONFIG_IEEE1394_PCILYNX_PORTS
1488 pci_free_consistent(lynx->dev, 65536, lynx->mem_dma_buffer,
1489 lynx->mem_dma_buffer_dma);
1490#endif
1491 case have_pcl_mem: 1155 case have_pcl_mem:
1492#ifndef CONFIG_IEEE1394_PCILYNX_LOCALRAM
1493 pci_free_consistent(lynx->dev, LOCALRAM_SIZE, lynx->pcl_mem, 1156 pci_free_consistent(lynx->dev, LOCALRAM_SIZE, lynx->pcl_mem,
1494 lynx->pcl_mem_dma); 1157 lynx->pcl_mem_dma);
1495#endif
1496 case clear: 1158 case clear:
1497 /* do nothing - already freed */ 1159 /* do nothing - already freed */
1498 ; 1160 ;
@@ -1524,7 +1186,7 @@ static int __devinit add_card(struct pci_dev *dev,
1524 1186
1525 error = -ENXIO; 1187 error = -ENXIO;
1526 1188
1527 if (pci_set_dma_mask(dev, 0xffffffff)) 1189 if (pci_set_dma_mask(dev, DMA_32BIT_MASK))
1528 FAIL("DMA address limits not supported for PCILynx hardware"); 1190 FAIL("DMA address limits not supported for PCILynx hardware");
1529 if (pci_enable_device(dev)) 1191 if (pci_enable_device(dev))
1530 FAIL("failed to enable PCILynx hardware"); 1192 FAIL("failed to enable PCILynx hardware");
@@ -1546,7 +1208,6 @@ static int __devinit add_card(struct pci_dev *dev,
1546 spin_lock_init(&lynx->lock); 1208 spin_lock_init(&lynx->lock);
1547 spin_lock_init(&lynx->phy_reg_lock); 1209 spin_lock_init(&lynx->phy_reg_lock);
1548 1210
1549#ifndef CONFIG_IEEE1394_PCILYNX_LOCALRAM
1550 lynx->pcl_mem = pci_alloc_consistent(dev, LOCALRAM_SIZE, 1211 lynx->pcl_mem = pci_alloc_consistent(dev, LOCALRAM_SIZE,
1551 &lynx->pcl_mem_dma); 1212 &lynx->pcl_mem_dma);
1552 1213
@@ -1558,16 +1219,6 @@ static int __devinit add_card(struct pci_dev *dev,
1558 } else { 1219 } else {
1559 FAIL("failed to allocate PCL memory area"); 1220 FAIL("failed to allocate PCL memory area");
1560 } 1221 }
1561#endif
1562
1563#ifdef CONFIG_IEEE1394_PCILYNX_PORTS
1564 lynx->mem_dma_buffer = pci_alloc_consistent(dev, 65536,
1565 &lynx->mem_dma_buffer_dma);
1566 if (lynx->mem_dma_buffer == NULL) {
1567 FAIL("failed to allocate DMA buffer for aux");
1568 }
1569 lynx->state = have_aux_buf;
1570#endif
1571 1222
1572 lynx->rcv_page = pci_alloc_consistent(dev, PAGE_SIZE, 1223 lynx->rcv_page = pci_alloc_consistent(dev, PAGE_SIZE,
1573 &lynx->rcv_page_dma); 1224 &lynx->rcv_page_dma);
@@ -1597,13 +1248,6 @@ static int __devinit add_card(struct pci_dev *dev,
1597 FAIL("failed to remap registers - card not accessible"); 1248 FAIL("failed to remap registers - card not accessible");
1598 } 1249 }
1599 1250
1600#ifdef CONFIG_IEEE1394_PCILYNX_LOCALRAM
1601 if (lynx->local_ram == NULL) {
1602 FAIL("failed to remap local RAM which is required for "
1603 "operation");
1604 }
1605#endif
1606
1607 reg_set_bits(lynx, MISC_CONTROL, MISC_CONTROL_SWRESET); 1251 reg_set_bits(lynx, MISC_CONTROL, MISC_CONTROL_SWRESET);
1608 /* Fix buggy cards with autoboot pin not tied low: */ 1252 /* Fix buggy cards with autoboot pin not tied low: */
1609 reg_write(lynx, DMA0_CHAN_CTRL, 0); 1253 reg_write(lynx, DMA0_CHAN_CTRL, 0);
@@ -1624,13 +1268,6 @@ static int __devinit add_card(struct pci_dev *dev,
1624 1268
1625 /* alloc_pcl return values are not checked, it is expected that the 1269 /* alloc_pcl return values are not checked, it is expected that the
1626 * provided PCL space is sufficient for the initial allocations */ 1270 * provided PCL space is sufficient for the initial allocations */
1627#ifdef CONFIG_IEEE1394_PCILYNX_PORTS
1628 if (lynx->aux_port != NULL) {
1629 lynx->dmem_pcl = alloc_pcl(lynx);
1630 aux_setup_pcls(lynx);
1631 sema_init(&lynx->mem_dma_mutex, 1);
1632 }
1633#endif
1634 lynx->rcv_pcl = alloc_pcl(lynx); 1271 lynx->rcv_pcl = alloc_pcl(lynx);
1635 lynx->rcv_pcl_start = alloc_pcl(lynx); 1272 lynx->rcv_pcl_start = alloc_pcl(lynx);
1636 lynx->async.pcl = alloc_pcl(lynx); 1273 lynx->async.pcl = alloc_pcl(lynx);
@@ -1647,12 +1284,6 @@ static int __devinit add_card(struct pci_dev *dev,
1647 1284
1648 reg_write(lynx, PCI_INT_ENABLE, PCI_INT_DMA_ALL); 1285 reg_write(lynx, PCI_INT_ENABLE, PCI_INT_DMA_ALL);
1649 1286
1650#ifdef CONFIG_IEEE1394_PCILYNX_PORTS
1651 reg_set_bits(lynx, PCI_INT_ENABLE, PCI_INT_AUX_INT);
1652 init_waitqueue_head(&lynx->mem_dma_intr_wait);
1653 init_waitqueue_head(&lynx->aux_intr_wait);
1654#endif
1655
1656 tasklet_init(&lynx->iso_rcv.tq, (void (*)(unsigned long))iso_rcv_bh, 1287 tasklet_init(&lynx->iso_rcv.tq, (void (*)(unsigned long))iso_rcv_bh,
1657 (unsigned long)lynx); 1288 (unsigned long)lynx);
1658 1289
@@ -1944,37 +1575,18 @@ static int __init pcilynx_init(void)
1944{ 1575{
1945 int ret; 1576 int ret;
1946 1577
1947#ifdef CONFIG_IEEE1394_PCILYNX_PORTS
1948 if (register_chrdev(PCILYNX_MAJOR, PCILYNX_DRIVER_NAME, &aux_ops)) {
1949 PRINT_G(KERN_ERR, "allocation of char major number %d failed",
1950 PCILYNX_MAJOR);
1951 return -EBUSY;
1952 }
1953#endif
1954
1955 ret = pci_register_driver(&lynx_pci_driver); 1578 ret = pci_register_driver(&lynx_pci_driver);
1956 if (ret < 0) { 1579 if (ret < 0) {
1957 PRINT_G(KERN_ERR, "PCI module init failed"); 1580 PRINT_G(KERN_ERR, "PCI module init failed");
1958 goto free_char_dev; 1581 return ret;
1959 } 1582 }
1960 1583
1961 return 0; 1584 return 0;
1962
1963 free_char_dev:
1964#ifdef CONFIG_IEEE1394_PCILYNX_PORTS
1965 unregister_chrdev(PCILYNX_MAJOR, PCILYNX_DRIVER_NAME);
1966#endif
1967
1968 return ret;
1969} 1585}
1970 1586
1971static void __exit pcilynx_cleanup(void) 1587static void __exit pcilynx_cleanup(void)
1972{ 1588{
1973 pci_unregister_driver(&lynx_pci_driver); 1589 pci_unregister_driver(&lynx_pci_driver);
1974
1975#ifdef CONFIG_IEEE1394_PCILYNX_PORTS
1976 unregister_chrdev(PCILYNX_MAJOR, PCILYNX_DRIVER_NAME);
1977#endif
1978} 1590}
1979 1591
1980 1592
diff --git a/drivers/ieee1394/pcilynx.h b/drivers/ieee1394/pcilynx.h
index 644ec55d3d46..d631aa8383ad 100644
--- a/drivers/ieee1394/pcilynx.h
+++ b/drivers/ieee1394/pcilynx.h
@@ -55,16 +55,6 @@ struct ti_lynx {
55 void __iomem *aux_port; 55 void __iomem *aux_port;
56 quadlet_t bus_info_block[5]; 56 quadlet_t bus_info_block[5];
57 57
58#ifdef CONFIG_IEEE1394_PCILYNX_PORTS
59 atomic_t aux_intr_seen;
60 wait_queue_head_t aux_intr_wait;
61
62 void *mem_dma_buffer;
63 dma_addr_t mem_dma_buffer_dma;
64 struct semaphore mem_dma_mutex;
65 wait_queue_head_t mem_dma_intr_wait;
66#endif
67
68 /* 58 /*
69 * use local RAM of LOCALRAM_SIZE bytes for PCLs, which allows for 59 * use local RAM of LOCALRAM_SIZE bytes for PCLs, which allows for
70 * LOCALRAM_SIZE * 8 PCLs (each sized 128 bytes); 60 * LOCALRAM_SIZE * 8 PCLs (each sized 128 bytes);
@@ -72,11 +62,9 @@ struct ti_lynx {
72 */ 62 */
73 u8 pcl_bmap[LOCALRAM_SIZE / 1024]; 63 u8 pcl_bmap[LOCALRAM_SIZE / 1024];
74 64
75#ifndef CONFIG_IEEE1394_PCILYNX_LOCALRAM
76 /* point to PCLs memory area if needed */ 65 /* point to PCLs memory area if needed */
77 void *pcl_mem; 66 void *pcl_mem;
78 dma_addr_t pcl_mem_dma; 67 dma_addr_t pcl_mem_dma;
79#endif
80 68
81 /* PCLs for local mem / aux transfers */ 69 /* PCLs for local mem / aux transfers */
82 pcl_t dmem_pcl; 70 pcl_t dmem_pcl;
@@ -378,39 +366,6 @@ struct ti_pcl {
378#define pcloffs(MEMBER) (offsetof(struct ti_pcl, MEMBER)) 366#define pcloffs(MEMBER) (offsetof(struct ti_pcl, MEMBER))
379 367
380 368
381#ifdef CONFIG_IEEE1394_PCILYNX_LOCALRAM
382
383static inline void put_pcl(const struct ti_lynx *lynx, pcl_t pclid,
384 const struct ti_pcl *pcl)
385{
386 int i;
387 u32 *in = (u32 *)pcl;
388 u32 *out = (u32 *)(lynx->local_ram + pclid * sizeof(struct ti_pcl));
389
390 for (i = 0; i < 32; i++, out++, in++) {
391 writel(*in, out);
392 }
393}
394
395static inline void get_pcl(const struct ti_lynx *lynx, pcl_t pclid,
396 struct ti_pcl *pcl)
397{
398 int i;
399 u32 *out = (u32 *)pcl;
400 u32 *in = (u32 *)(lynx->local_ram + pclid * sizeof(struct ti_pcl));
401
402 for (i = 0; i < 32; i++, out++, in++) {
403 *out = readl(in);
404 }
405}
406
407static inline u32 pcl_bus(const struct ti_lynx *lynx, pcl_t pclid)
408{
409 return pci_resource_start(lynx->dev, 1) + pclid * sizeof(struct ti_pcl);
410}
411
412#else /* CONFIG_IEEE1394_PCILYNX_LOCALRAM */
413
414static inline void put_pcl(const struct ti_lynx *lynx, pcl_t pclid, 369static inline void put_pcl(const struct ti_lynx *lynx, pcl_t pclid,
415 const struct ti_pcl *pcl) 370 const struct ti_pcl *pcl)
416{ 371{
@@ -431,10 +386,8 @@ static inline u32 pcl_bus(const struct ti_lynx *lynx, pcl_t pclid)
431 return lynx->pcl_mem_dma + pclid * sizeof(struct ti_pcl); 386 return lynx->pcl_mem_dma + pclid * sizeof(struct ti_pcl);
432} 387}
433 388
434#endif /* CONFIG_IEEE1394_PCILYNX_LOCALRAM */
435
436 389
437#if defined (CONFIG_IEEE1394_PCILYNX_LOCALRAM) || defined (__BIG_ENDIAN) 390#if defined (__BIG_ENDIAN)
438typedef struct ti_pcl pcltmp_t; 391typedef struct ti_pcl pcltmp_t;
439 392
440static inline struct ti_pcl *edit_pcl(const struct ti_lynx *lynx, pcl_t pclid, 393static inline struct ti_pcl *edit_pcl(const struct ti_lynx *lynx, pcl_t pclid,
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index 4bedf7113f40..d68c4658f2fc 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -35,6 +35,11 @@
35 * 35 *
36 */ 36 */
37 37
38/* Markus Tavenrath <speedygoo@speedygoo.de> :
39 - fixed checks for valid buffer-numbers in video1394_icotl
40 - changed the ways the dma prg's are used, now it's possible to use
41 even a single dma buffer
42*/
38#include <linux/config.h> 43#include <linux/config.h>
39#include <linux/kernel.h> 44#include <linux/kernel.h>
40#include <linux/list.h> 45#include <linux/list.h>
@@ -112,6 +117,7 @@ struct dma_iso_ctx {
112 struct it_dma_prg **it_prg; 117 struct it_dma_prg **it_prg;
113 118
114 unsigned int *buffer_status; 119 unsigned int *buffer_status;
120 unsigned int *buffer_prg_assignment;
115 struct timeval *buffer_time; /* time when the buffer was received */ 121 struct timeval *buffer_time; /* time when the buffer was received */
116 unsigned int *last_used_cmd; /* For ISO Transmit with 122 unsigned int *last_used_cmd; /* For ISO Transmit with
117 variable sized packets only ! */ 123 variable sized packets only ! */
@@ -180,23 +186,14 @@ static int free_dma_iso_ctx(struct dma_iso_ctx *d)
180 kfree(d->prg_reg); 186 kfree(d->prg_reg);
181 } 187 }
182 188
183 if (d->ir_prg) 189 kfree(d->ir_prg);
184 kfree(d->ir_prg); 190 kfree(d->it_prg);
185 191 kfree(d->buffer_status);
186 if (d->it_prg) 192 kfree(d->buffer_prg_assignment);
187 kfree(d->it_prg); 193 kfree(d->buffer_time);
188 194 kfree(d->last_used_cmd);
189 if (d->buffer_status) 195 kfree(d->next_buffer);
190 kfree(d->buffer_status);
191 if (d->buffer_time)
192 kfree(d->buffer_time);
193 if (d->last_used_cmd)
194 kfree(d->last_used_cmd);
195 if (d->next_buffer)
196 kfree(d->next_buffer);
197
198 list_del(&d->link); 196 list_del(&d->link);
199
200 kfree(d); 197 kfree(d);
201 198
202 return 0; 199 return 0;
@@ -230,7 +227,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
230 /* Init the regions for easy cleanup */ 227 /* Init the regions for easy cleanup */
231 dma_region_init(&d->dma); 228 dma_region_init(&d->dma);
232 229
233 if (dma_region_alloc(&d->dma, d->num_desc * d->buf_size, ohci->dev, 230 if (dma_region_alloc(&d->dma, (d->num_desc - 1) * d->buf_size, ohci->dev,
234 PCI_DMA_BIDIRECTIONAL)) { 231 PCI_DMA_BIDIRECTIONAL)) {
235 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma buffer"); 232 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma buffer");
236 free_dma_iso_ctx(d); 233 free_dma_iso_ctx(d);
@@ -342,6 +339,8 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
342 339
343 d->buffer_status = kmalloc(d->num_desc * sizeof(unsigned int), 340 d->buffer_status = kmalloc(d->num_desc * sizeof(unsigned int),
344 GFP_KERNEL); 341 GFP_KERNEL);
342 d->buffer_prg_assignment = kmalloc(d->num_desc * sizeof(unsigned int),
343 GFP_KERNEL);
345 d->buffer_time = kmalloc(d->num_desc * sizeof(struct timeval), 344 d->buffer_time = kmalloc(d->num_desc * sizeof(struct timeval),
346 GFP_KERNEL); 345 GFP_KERNEL);
347 d->last_used_cmd = kmalloc(d->num_desc * sizeof(unsigned int), 346 d->last_used_cmd = kmalloc(d->num_desc * sizeof(unsigned int),
@@ -354,6 +353,11 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
354 free_dma_iso_ctx(d); 353 free_dma_iso_ctx(d);
355 return NULL; 354 return NULL;
356 } 355 }
356 if (d->buffer_prg_assignment == NULL) {
357 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_prg_assignment");
358 free_dma_iso_ctx(d);
359 return NULL;
360 }
357 if (d->buffer_time == NULL) { 361 if (d->buffer_time == NULL) {
358 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_time"); 362 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_time");
359 free_dma_iso_ctx(d); 363 free_dma_iso_ctx(d);
@@ -370,6 +374,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
370 return NULL; 374 return NULL;
371 } 375 }
372 memset(d->buffer_status, 0, d->num_desc * sizeof(unsigned int)); 376 memset(d->buffer_status, 0, d->num_desc * sizeof(unsigned int));
377 memset(d->buffer_prg_assignment, 0, d->num_desc * sizeof(unsigned int));
373 memset(d->buffer_time, 0, d->num_desc * sizeof(struct timeval)); 378 memset(d->buffer_time, 0, d->num_desc * sizeof(struct timeval));
374 memset(d->last_used_cmd, 0, d->num_desc * sizeof(unsigned int)); 379 memset(d->last_used_cmd, 0, d->num_desc * sizeof(unsigned int));
375 memset(d->next_buffer, -1, d->num_desc * sizeof(int)); 380 memset(d->next_buffer, -1, d->num_desc * sizeof(int));
@@ -379,7 +384,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
379 PRINT(KERN_INFO, ohci->host->id, "Iso %s DMA: %d buffers " 384 PRINT(KERN_INFO, ohci->host->id, "Iso %s DMA: %d buffers "
380 "of size %d allocated for a frame size %d, each with %d prgs", 385 "of size %d allocated for a frame size %d, each with %d prgs",
381 (type == OHCI_ISO_RECEIVE) ? "receive" : "transmit", 386 (type == OHCI_ISO_RECEIVE) ? "receive" : "transmit",
382 d->num_desc, d->buf_size, d->frame_size, d->nb_cmd); 387 d->num_desc - 1, d->buf_size, d->frame_size, d->nb_cmd);
383 388
384 return d; 389 return d;
385} 390}
@@ -394,11 +399,36 @@ static void reset_ir_status(struct dma_iso_ctx *d, int n)
394 d->ir_prg[n][i].status = cpu_to_le32(d->left_size); 399 d->ir_prg[n][i].status = cpu_to_le32(d->left_size);
395} 400}
396 401
402static void reprogram_dma_ir_prg(struct dma_iso_ctx *d, int n, int buffer, int flags)
403{
404 struct dma_cmd *ir_prg = d->ir_prg[n];
405 unsigned long buf = (unsigned long)d->dma.kvirt + buffer * d->buf_size;
406 int i;
407
408 d->buffer_prg_assignment[n] = buffer;
409
410 ir_prg[0].address = cpu_to_le32(dma_region_offset_to_bus(&d->dma, buf -
411 (unsigned long)d->dma.kvirt));
412 ir_prg[1].address = cpu_to_le32(dma_region_offset_to_bus(&d->dma,
413 (buf + 4) - (unsigned long)d->dma.kvirt));
414
415 for (i=2;i<d->nb_cmd-1;i++) {
416 ir_prg[i].address = cpu_to_le32(dma_region_offset_to_bus(&d->dma,
417 (buf+(i-1)*PAGE_SIZE) -
418 (unsigned long)d->dma.kvirt));
419 }
420
421 ir_prg[i].control = cpu_to_le32(DMA_CTL_INPUT_MORE | DMA_CTL_UPDATE |
422 DMA_CTL_IRQ | DMA_CTL_BRANCH | d->left_size);
423 ir_prg[i].address = cpu_to_le32(dma_region_offset_to_bus(&d->dma,
424 (buf+(i-1)*PAGE_SIZE) - (unsigned long)d->dma.kvirt));
425}
426
397static void initialize_dma_ir_prg(struct dma_iso_ctx *d, int n, int flags) 427static void initialize_dma_ir_prg(struct dma_iso_ctx *d, int n, int flags)
398{ 428{
399 struct dma_cmd *ir_prg = d->ir_prg[n]; 429 struct dma_cmd *ir_prg = d->ir_prg[n];
400 struct dma_prog_region *ir_reg = &d->prg_reg[n]; 430 struct dma_prog_region *ir_reg = &d->prg_reg[n];
401 unsigned long buf = (unsigned long)d->dma.kvirt + n * d->buf_size; 431 unsigned long buf = (unsigned long)d->dma.kvirt;
402 int i; 432 int i;
403 433
404 /* the first descriptor will read only 4 bytes */ 434 /* the first descriptor will read only 4 bytes */
@@ -508,7 +538,7 @@ static void wakeup_dma_ir_ctx(unsigned long l)
508 for (i = 0; i < d->num_desc; i++) { 538 for (i = 0; i < d->num_desc; i++) {
509 if (d->ir_prg[i][d->nb_cmd-1].status & cpu_to_le32(0xFFFF0000)) { 539 if (d->ir_prg[i][d->nb_cmd-1].status & cpu_to_le32(0xFFFF0000)) {
510 reset_ir_status(d, i); 540 reset_ir_status(d, i);
511 d->buffer_status[i] = VIDEO1394_BUFFER_READY; 541 d->buffer_status[d->buffer_prg_assignment[i]] = VIDEO1394_BUFFER_READY;
512 do_gettimeofday(&d->buffer_time[i]); 542 do_gettimeofday(&d->buffer_time[i]);
513 } 543 }
514 } 544 }
@@ -585,7 +615,7 @@ static void wakeup_dma_it_ctx(unsigned long l)
585 int next = d->next_buffer[i]; 615 int next = d->next_buffer[i];
586 put_timestamp(ohci, d, next); 616 put_timestamp(ohci, d, next);
587 d->it_prg[i][d->last_used_cmd[i]].end.status = 0; 617 d->it_prg[i][d->last_used_cmd[i]].end.status = 0;
588 d->buffer_status[i] = VIDEO1394_BUFFER_READY; 618 d->buffer_status[d->buffer_prg_assignment[i]] = VIDEO1394_BUFFER_READY;
589 } 619 }
590 } 620 }
591 621
@@ -595,11 +625,25 @@ static void wakeup_dma_it_ctx(unsigned long l)
595 wake_up_interruptible(&d->waitq); 625 wake_up_interruptible(&d->waitq);
596} 626}
597 627
628static void reprogram_dma_it_prg(struct dma_iso_ctx *d, int n, int buffer)
629{
630 struct it_dma_prg *it_prg = d->it_prg[n];
631 unsigned long buf = (unsigned long)d->dma.kvirt + buffer * d->buf_size;
632 int i;
633
634 d->buffer_prg_assignment[n] = buffer;
635 for (i=0;i<d->nb_cmd;i++) {
636 it_prg[i].end.address =
637 cpu_to_le32(dma_region_offset_to_bus(&d->dma,
638 (buf+i*d->packet_size) - (unsigned long)d->dma.kvirt));
639 }
640}
641
598static void initialize_dma_it_prg(struct dma_iso_ctx *d, int n, int sync_tag) 642static void initialize_dma_it_prg(struct dma_iso_ctx *d, int n, int sync_tag)
599{ 643{
600 struct it_dma_prg *it_prg = d->it_prg[n]; 644 struct it_dma_prg *it_prg = d->it_prg[n];
601 struct dma_prog_region *it_reg = &d->prg_reg[n]; 645 struct dma_prog_region *it_reg = &d->prg_reg[n];
602 unsigned long buf = (unsigned long)d->dma.kvirt + n * d->buf_size; 646 unsigned long buf = (unsigned long)d->dma.kvirt;
603 int i; 647 int i;
604 d->last_used_cmd[n] = d->nb_cmd - 1; 648 d->last_used_cmd[n] = d->nb_cmd - 1;
605 for (i=0;i<d->nb_cmd;i++) { 649 for (i=0;i<d->nb_cmd;i++) {
@@ -796,7 +840,7 @@ static int __video1394_ioctl(struct file *file,
796 840
797 if (cmd == VIDEO1394_IOC_LISTEN_CHANNEL) { 841 if (cmd == VIDEO1394_IOC_LISTEN_CHANNEL) {
798 d = alloc_dma_iso_ctx(ohci, OHCI_ISO_RECEIVE, 842 d = alloc_dma_iso_ctx(ohci, OHCI_ISO_RECEIVE,
799 v.nb_buffers, v.buf_size, 843 v.nb_buffers + 1, v.buf_size,
800 v.channel, 0); 844 v.channel, 0);
801 845
802 if (d == NULL) { 846 if (d == NULL) {
@@ -817,7 +861,7 @@ static int __video1394_ioctl(struct file *file,
817 } 861 }
818 else { 862 else {
819 d = alloc_dma_iso_ctx(ohci, OHCI_ISO_TRANSMIT, 863 d = alloc_dma_iso_ctx(ohci, OHCI_ISO_TRANSMIT,
820 v.nb_buffers, v.buf_size, 864 v.nb_buffers + 1, v.buf_size,
821 v.channel, v.packet_size); 865 v.channel, v.packet_size);
822 866
823 if (d == NULL) { 867 if (d == NULL) {
@@ -889,6 +933,7 @@ static int __video1394_ioctl(struct file *file,
889 { 933 {
890 struct video1394_wait v; 934 struct video1394_wait v;
891 struct dma_iso_ctx *d; 935 struct dma_iso_ctx *d;
936 int next_prg;
892 937
893 if (copy_from_user(&v, argp, sizeof(v))) 938 if (copy_from_user(&v, argp, sizeof(v)))
894 return -EFAULT; 939 return -EFAULT;
@@ -896,7 +941,7 @@ static int __video1394_ioctl(struct file *file,
896 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); 941 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
897 if (d == NULL) return -EFAULT; 942 if (d == NULL) return -EFAULT;
898 943
899 if ((v.buffer<0) || (v.buffer>d->num_desc)) { 944 if ((v.buffer<0) || (v.buffer>=d->num_desc - 1)) {
900 PRINT(KERN_ERR, ohci->host->id, 945 PRINT(KERN_ERR, ohci->host->id,
901 "Buffer %d out of range",v.buffer); 946 "Buffer %d out of range",v.buffer);
902 return -EINVAL; 947 return -EINVAL;
@@ -913,12 +958,14 @@ static int __video1394_ioctl(struct file *file,
913 958
914 d->buffer_status[v.buffer]=VIDEO1394_BUFFER_QUEUED; 959 d->buffer_status[v.buffer]=VIDEO1394_BUFFER_QUEUED;
915 960
961 next_prg = (d->last_buffer + 1) % d->num_desc;
916 if (d->last_buffer>=0) 962 if (d->last_buffer>=0)
917 d->ir_prg[d->last_buffer][d->nb_cmd-1].branchAddress = 963 d->ir_prg[d->last_buffer][d->nb_cmd-1].branchAddress =
918 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[v.buffer], 0) 964 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[next_prg], 0)
919 & 0xfffffff0) | 0x1); 965 & 0xfffffff0) | 0x1);
920 966
921 d->last_buffer = v.buffer; 967 d->last_buffer = next_prg;
968 reprogram_dma_ir_prg(d, d->last_buffer, v.buffer, d->flags);
922 969
923 d->ir_prg[d->last_buffer][d->nb_cmd-1].branchAddress = 0; 970 d->ir_prg[d->last_buffer][d->nb_cmd-1].branchAddress = 0;
924 971
@@ -930,7 +977,7 @@ static int __video1394_ioctl(struct file *file,
930 977
931 /* Tell the controller where the first program is */ 978 /* Tell the controller where the first program is */
932 reg_write(ohci, d->cmdPtr, 979 reg_write(ohci, d->cmdPtr,
933 dma_prog_region_offset_to_bus(&d->prg_reg[v.buffer], 0) | 0x1); 980 dma_prog_region_offset_to_bus(&d->prg_reg[d->last_buffer], 0) | 0x1);
934 981
935 /* Run IR context */ 982 /* Run IR context */
936 reg_write(ohci, d->ctrlSet, 0x8000); 983 reg_write(ohci, d->ctrlSet, 0x8000);
@@ -951,7 +998,7 @@ static int __video1394_ioctl(struct file *file,
951 { 998 {
952 struct video1394_wait v; 999 struct video1394_wait v;
953 struct dma_iso_ctx *d; 1000 struct dma_iso_ctx *d;
954 int i; 1001 int i = 0;
955 1002
956 if (copy_from_user(&v, argp, sizeof(v))) 1003 if (copy_from_user(&v, argp, sizeof(v)))
957 return -EFAULT; 1004 return -EFAULT;
@@ -959,7 +1006,7 @@ static int __video1394_ioctl(struct file *file,
959 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); 1006 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
960 if (d == NULL) return -EFAULT; 1007 if (d == NULL) return -EFAULT;
961 1008
962 if ((v.buffer<0) || (v.buffer>d->num_desc)) { 1009 if ((v.buffer<0) || (v.buffer>d->num_desc - 1)) {
963 PRINT(KERN_ERR, ohci->host->id, 1010 PRINT(KERN_ERR, ohci->host->id,
964 "Buffer %d out of range",v.buffer); 1011 "Buffer %d out of range",v.buffer);
965 return -EINVAL; 1012 return -EINVAL;
@@ -1005,9 +1052,9 @@ static int __video1394_ioctl(struct file *file,
1005 * Look ahead to see how many more buffers have been received 1052 * Look ahead to see how many more buffers have been received
1006 */ 1053 */
1007 i=0; 1054 i=0;
1008 while (d->buffer_status[(v.buffer+1)%d->num_desc]== 1055 while (d->buffer_status[(v.buffer+1)%(d->num_desc - 1)]==
1009 VIDEO1394_BUFFER_READY) { 1056 VIDEO1394_BUFFER_READY) {
1010 v.buffer=(v.buffer+1)%d->num_desc; 1057 v.buffer=(v.buffer+1)%(d->num_desc - 1);
1011 i++; 1058 i++;
1012 } 1059 }
1013 spin_unlock_irqrestore(&d->lock, flags); 1060 spin_unlock_irqrestore(&d->lock, flags);
@@ -1023,6 +1070,7 @@ static int __video1394_ioctl(struct file *file,
1023 struct video1394_wait v; 1070 struct video1394_wait v;
1024 unsigned int *psizes = NULL; 1071 unsigned int *psizes = NULL;
1025 struct dma_iso_ctx *d; 1072 struct dma_iso_ctx *d;
1073 int next_prg;
1026 1074
1027 if (copy_from_user(&v, argp, sizeof(v))) 1075 if (copy_from_user(&v, argp, sizeof(v)))
1028 return -EFAULT; 1076 return -EFAULT;
@@ -1030,7 +1078,7 @@ static int __video1394_ioctl(struct file *file,
1030 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel); 1078 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
1031 if (d == NULL) return -EFAULT; 1079 if (d == NULL) return -EFAULT;
1032 1080
1033 if ((v.buffer<0) || (v.buffer>d->num_desc)) { 1081 if ((v.buffer<0) || (v.buffer>=d->num_desc - 1)) {
1034 PRINT(KERN_ERR, ohci->host->id, 1082 PRINT(KERN_ERR, ohci->host->id,
1035 "Buffer %d out of range",v.buffer); 1083 "Buffer %d out of range",v.buffer);
1036 return -EINVAL; 1084 return -EINVAL;
@@ -1056,19 +1104,19 @@ static int __video1394_ioctl(struct file *file,
1056 1104
1057 spin_lock_irqsave(&d->lock,flags); 1105 spin_lock_irqsave(&d->lock,flags);
1058 1106
1107 // last_buffer is last_prg
1108 next_prg = (d->last_buffer + 1) % d->num_desc;
1059 if (d->buffer_status[v.buffer]!=VIDEO1394_BUFFER_FREE) { 1109 if (d->buffer_status[v.buffer]!=VIDEO1394_BUFFER_FREE) {
1060 PRINT(KERN_ERR, ohci->host->id, 1110 PRINT(KERN_ERR, ohci->host->id,
1061 "Buffer %d is already used",v.buffer); 1111 "Buffer %d is already used",v.buffer);
1062 spin_unlock_irqrestore(&d->lock,flags); 1112 spin_unlock_irqrestore(&d->lock,flags);
1063 if (psizes) 1113 kfree(psizes);
1064 kfree(psizes);
1065 return -EBUSY; 1114 return -EBUSY;
1066 } 1115 }
1067 1116
1068 if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) { 1117 if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) {
1069 initialize_dma_it_prg_var_packet_queue( 1118 initialize_dma_it_prg_var_packet_queue(
1070 d, v.buffer, psizes, 1119 d, next_prg, psizes, ohci);
1071 ohci);
1072 } 1120 }
1073 1121
1074 d->buffer_status[v.buffer]=VIDEO1394_BUFFER_QUEUED; 1122 d->buffer_status[v.buffer]=VIDEO1394_BUFFER_QUEUED;
@@ -1076,16 +1124,17 @@ static int __video1394_ioctl(struct file *file,
1076 if (d->last_buffer >= 0) { 1124 if (d->last_buffer >= 0) {
1077 d->it_prg[d->last_buffer] 1125 d->it_prg[d->last_buffer]
1078 [ d->last_used_cmd[d->last_buffer] ].end.branchAddress = 1126 [ d->last_used_cmd[d->last_buffer] ].end.branchAddress =
1079 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[v.buffer], 1127 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[next_prg],
1080 0) & 0xfffffff0) | 0x3); 1128 0) & 0xfffffff0) | 0x3);
1081 1129
1082 d->it_prg[d->last_buffer] 1130 d->it_prg[d->last_buffer]
1083 [ d->last_used_cmd[d->last_buffer] ].begin.branchAddress = 1131 [ d->last_used_cmd[d->last_buffer] ].begin.branchAddress =
1084 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[v.buffer], 1132 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[next_prg],
1085 0) & 0xfffffff0) | 0x3); 1133 0) & 0xfffffff0) | 0x3);
1086 d->next_buffer[d->last_buffer] = v.buffer; 1134 d->next_buffer[d->last_buffer] = (v.buffer + 1) % (d->num_desc - 1);
1087 } 1135 }
1088 d->last_buffer = v.buffer; 1136 d->last_buffer = next_prg;
1137 reprogram_dma_it_prg(d, d->last_buffer, v.buffer);
1089 d->next_buffer[d->last_buffer] = -1; 1138 d->next_buffer[d->last_buffer] = -1;
1090 1139
1091 d->it_prg[d->last_buffer][d->last_used_cmd[d->last_buffer]].end.branchAddress = 0; 1140 d->it_prg[d->last_buffer][d->last_used_cmd[d->last_buffer]].end.branchAddress = 0;
@@ -1100,7 +1149,7 @@ static int __video1394_ioctl(struct file *file,
1100 1149
1101 /* Tell the controller where the first program is */ 1150 /* Tell the controller where the first program is */
1102 reg_write(ohci, d->cmdPtr, 1151 reg_write(ohci, d->cmdPtr,
1103 dma_prog_region_offset_to_bus(&d->prg_reg[v.buffer], 0) | 0x3); 1152 dma_prog_region_offset_to_bus(&d->prg_reg[next_prg], 0) | 0x3);
1104 1153
1105 /* Run IT context */ 1154 /* Run IT context */
1106 reg_write(ohci, d->ctrlSet, 0x8000); 1155 reg_write(ohci, d->ctrlSet, 0x8000);
@@ -1116,9 +1165,7 @@ static int __video1394_ioctl(struct file *file,
1116 } 1165 }
1117 } 1166 }
1118 1167
1119 if (psizes) 1168 kfree(psizes);
1120 kfree(psizes);
1121
1122 return 0; 1169 return 0;
1123 1170
1124 } 1171 }
@@ -1133,7 +1180,7 @@ static int __video1394_ioctl(struct file *file,
1133 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel); 1180 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
1134 if (d == NULL) return -EFAULT; 1181 if (d == NULL) return -EFAULT;
1135 1182
1136 if ((v.buffer<0) || (v.buffer>d->num_desc)) { 1183 if ((v.buffer<0) || (v.buffer>=d->num_desc-1)) {
1137 PRINT(KERN_ERR, ohci->host->id, 1184 PRINT(KERN_ERR, ohci->host->id,
1138 "Buffer %d out of range",v.buffer); 1185 "Buffer %d out of range",v.buffer);
1139 return -EINVAL; 1186 return -EINVAL;
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index d4233ee61c35..276e1a53010d 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -587,7 +587,7 @@ int ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
587 587
588 init_mad(query->sa_query.mad, agent); 588 init_mad(query->sa_query.mad, agent);
589 589
590 query->sa_query.callback = ib_sa_path_rec_callback; 590 query->sa_query.callback = callback ? ib_sa_path_rec_callback : NULL;
591 query->sa_query.release = ib_sa_path_rec_release; 591 query->sa_query.release = ib_sa_path_rec_release;
592 query->sa_query.port = port; 592 query->sa_query.port = port;
593 query->sa_query.mad->mad_hdr.method = IB_MGMT_METHOD_GET; 593 query->sa_query.mad->mad_hdr.method = IB_MGMT_METHOD_GET;
@@ -663,7 +663,7 @@ int ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num,
663 663
664 init_mad(query->sa_query.mad, agent); 664 init_mad(query->sa_query.mad, agent);
665 665
666 query->sa_query.callback = ib_sa_mcmember_rec_callback; 666 query->sa_query.callback = callback ? ib_sa_mcmember_rec_callback : NULL;
667 query->sa_query.release = ib_sa_mcmember_rec_release; 667 query->sa_query.release = ib_sa_mcmember_rec_release;
668 query->sa_query.port = port; 668 query->sa_query.port = port;
669 query->sa_query.mad->mad_hdr.method = method; 669 query->sa_query.mad->mad_hdr.method = method;
@@ -698,20 +698,21 @@ static void send_handler(struct ib_mad_agent *agent,
698 if (!query) 698 if (!query)
699 return; 699 return;
700 700
701 switch (mad_send_wc->status) { 701 if (query->callback)
702 case IB_WC_SUCCESS: 702 switch (mad_send_wc->status) {
703 /* No callback -- already got recv */ 703 case IB_WC_SUCCESS:
704 break; 704 /* No callback -- already got recv */
705 case IB_WC_RESP_TIMEOUT_ERR: 705 break;
706 query->callback(query, -ETIMEDOUT, NULL); 706 case IB_WC_RESP_TIMEOUT_ERR:
707 break; 707 query->callback(query, -ETIMEDOUT, NULL);
708 case IB_WC_WR_FLUSH_ERR: 708 break;
709 query->callback(query, -EINTR, NULL); 709 case IB_WC_WR_FLUSH_ERR:
710 break; 710 query->callback(query, -EINTR, NULL);
711 default: 711 break;
712 query->callback(query, -EIO, NULL); 712 default:
713 break; 713 query->callback(query, -EIO, NULL);
714 } 714 break;
715 }
715 716
716 dma_unmap_single(agent->device->dma_device, 717 dma_unmap_single(agent->device->dma_device,
717 pci_unmap_addr(query, mapping), 718 pci_unmap_addr(query, mapping),
@@ -736,7 +737,7 @@ static void recv_handler(struct ib_mad_agent *mad_agent,
736 query = idr_find(&query_idr, mad_recv_wc->wc->wr_id); 737 query = idr_find(&query_idr, mad_recv_wc->wc->wr_id);
737 spin_unlock_irqrestore(&idr_lock, flags); 738 spin_unlock_irqrestore(&idr_lock, flags);
738 739
739 if (query) { 740 if (query && query->callback) {
740 if (mad_recv_wc->wc->status == IB_WC_SUCCESS) 741 if (mad_recv_wc->wc->status == IB_WC_SUCCESS)
741 query->callback(query, 742 query->callback(query,
742 mad_recv_wc->recv_buf.mad->mad_hdr.status ? 743 mad_recv_wc->recv_buf.mad->mad_hdr.status ?
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 56b9c2fa2ecc..9d912d6877ff 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -499,6 +499,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
499static int ib_umad_close(struct inode *inode, struct file *filp) 499static int ib_umad_close(struct inode *inode, struct file *filp)
500{ 500{
501 struct ib_umad_file *file = filp->private_data; 501 struct ib_umad_file *file = filp->private_data;
502 struct ib_umad_packet *packet, *tmp;
502 int i; 503 int i;
503 504
504 for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i) 505 for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i)
@@ -507,6 +508,9 @@ static int ib_umad_close(struct inode *inode, struct file *filp)
507 ib_unregister_mad_agent(file->agent[i]); 508 ib_unregister_mad_agent(file->agent[i]);
508 } 509 }
509 510
511 list_for_each_entry_safe(packet, tmp, &file->recv_list, list)
512 kfree(packet);
513
510 kfree(file); 514 kfree(file);
511 515
512 return 0; 516 return 0;
diff --git a/drivers/infiniband/include/ib_sa.h b/drivers/infiniband/include/ib_sa.h
index f4f747707b30..00222285eb9a 100644
--- a/drivers/infiniband/include/ib_sa.h
+++ b/drivers/infiniband/include/ib_sa.h
@@ -147,7 +147,7 @@ struct ib_sa_path_rec {
147 /* reserved */ 147 /* reserved */
148 u8 sl; 148 u8 sl;
149 u8 mtu_selector; 149 u8 mtu_selector;
150 enum ib_mtu mtu; 150 u8 mtu;
151 u8 rate_selector; 151 u8 rate_selector;
152 u8 rate; 152 u8 rate;
153 u8 packet_life_time_selector; 153 u8 packet_life_time_selector;
@@ -180,7 +180,7 @@ struct ib_sa_mcmember_rec {
180 u32 qkey; 180 u32 qkey;
181 u16 mlid; 181 u16 mlid;
182 u8 mtu_selector; 182 u8 mtu_selector;
183 enum ib_mtu mtu; 183 u8 mtu;
184 u8 traffic_class; 184 u8 traffic_class;
185 u16 pkey; 185 u16 pkey;
186 u8 rate_selector; 186 u8 rate_selector;
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index ff66ed4ee2cd..79c332f16fc7 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -465,8 +465,10 @@ static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int co
465 if (atkbd->softrepeat) return 0; 465 if (atkbd->softrepeat) return 0;
466 466
467 i = j = 0; 467 i = j = 0;
468 while (i < 32 && period[i] < dev->rep[REP_PERIOD]) i++; 468 while (i < 31 && period[i] < dev->rep[REP_PERIOD])
469 while (j < 4 && delay[j] < dev->rep[REP_DELAY]) j++; 469 i++;
470 while (j < 3 && delay[j] < dev->rep[REP_DELAY])
471 j++;
470 dev->rep[REP_PERIOD] = period[i]; 472 dev->rep[REP_PERIOD] = period[i];
471 dev->rep[REP_DELAY] = delay[j]; 473 dev->rep[REP_DELAY] = delay[j];
472 param[0] = i | (j << 5); 474 param[0] = i | (j << 5);
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 1f85a9718c89..42a9f7f6f8cb 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -341,6 +341,8 @@ static int alps_reconnect(struct psmouse *psmouse)
341 unsigned char param[4]; 341 unsigned char param[4];
342 int version; 342 int version;
343 343
344 psmouse_reset(psmouse);
345
344 if (!(priv->i = alps_get_model(psmouse, &version))) 346 if (!(priv->i = alps_get_model(psmouse, &version)))
345 return -1; 347 return -1;
346 348
@@ -395,7 +397,7 @@ int alps_init(struct psmouse *psmouse)
395 } 397 }
396 398
397 if (param[0] & 0x04) { 399 if (param[0] & 0x04) {
398 printk(KERN_INFO " Enabling hardware tapping\n"); 400 printk(KERN_INFO "alps.c: Enabling hardware tapping\n");
399 if (alps_tap_mode(psmouse, 1)) 401 if (alps_tap_mode(psmouse, 1))
400 printk(KERN_WARNING "alps.c: Failed to enable hardware tapping\n"); 402 printk(KERN_WARNING "alps.c: Failed to enable hardware tapping\n");
401 } 403 }
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 3313e2daeab0..0beacb77ee18 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -388,6 +388,24 @@ static ssize_t serio_show_id_extra(struct device *dev, char *buf)
388 return sprintf(buf, "%02x\n", serio->id.extra); 388 return sprintf(buf, "%02x\n", serio->id.extra);
389} 389}
390 390
391static DEVICE_ATTR(type, S_IRUGO, serio_show_id_type, NULL);
392static DEVICE_ATTR(proto, S_IRUGO, serio_show_id_proto, NULL);
393static DEVICE_ATTR(id, S_IRUGO, serio_show_id_id, NULL);
394static DEVICE_ATTR(extra, S_IRUGO, serio_show_id_extra, NULL);
395
396static struct attribute *serio_device_id_attrs[] = {
397 &dev_attr_type.attr,
398 &dev_attr_proto.attr,
399 &dev_attr_id.attr,
400 &dev_attr_extra.attr,
401 NULL
402};
403
404static struct attribute_group serio_id_attr_group = {
405 .name = "id",
406 .attrs = serio_device_id_attrs,
407};
408
391static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t count) 409static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t count)
392{ 410{
393 struct serio *serio = to_serio_port(dev); 411 struct serio *serio = to_serio_port(dev);
@@ -444,10 +462,6 @@ static ssize_t serio_set_bind_mode(struct device *dev, const char *buf, size_t c
444 462
445static struct device_attribute serio_device_attrs[] = { 463static struct device_attribute serio_device_attrs[] = {
446 __ATTR(description, S_IRUGO, serio_show_description, NULL), 464 __ATTR(description, S_IRUGO, serio_show_description, NULL),
447 __ATTR(id_type, S_IRUGO, serio_show_id_type, NULL),
448 __ATTR(id_proto, S_IRUGO, serio_show_id_proto, NULL),
449 __ATTR(id_id, S_IRUGO, serio_show_id_id, NULL),
450 __ATTR(id_extra, S_IRUGO, serio_show_id_extra, NULL),
451 __ATTR(drvctl, S_IWUSR, NULL, serio_rebind_driver), 465 __ATTR(drvctl, S_IWUSR, NULL, serio_rebind_driver),
452 __ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode), 466 __ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode),
453 __ATTR_NULL 467 __ATTR_NULL
@@ -498,6 +512,7 @@ static void serio_add_port(struct serio *serio)
498 if (serio->start) 512 if (serio->start)
499 serio->start(serio); 513 serio->start(serio);
500 device_add(&serio->dev); 514 device_add(&serio->dev);
515 sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group);
501 serio->registered = 1; 516 serio->registered = 1;
502} 517}
503 518
@@ -526,6 +541,7 @@ static void serio_destroy_port(struct serio *serio)
526 } 541 }
527 542
528 if (serio->registered) { 543 if (serio->registered) {
544 sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group);
529 device_del(&serio->dev); 545 device_del(&serio->dev);
530 list_del_init(&serio->node); 546 list_del_init(&serio->node);
531 serio->registered = 0; 547 serio->registered = 0;
@@ -779,7 +795,6 @@ static int serio_resume(struct device *dev)
779 struct serio *serio = to_serio_port(dev); 795 struct serio *serio = to_serio_port(dev);
780 796
781 if (!serio->drv || !serio->drv->reconnect || serio->drv->reconnect(serio)) { 797 if (!serio->drv || !serio->drv->reconnect || serio->drv->reconnect(serio)) {
782 serio_disconnect_port(serio);
783 /* 798 /*
784 * Driver re-probing can take a while, so better let kseriod 799 * Driver re-probing can take a while, so better let kseriod
785 * deal with it. 800 * deal with it.
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index 22f73683952b..f6b85222ba3d 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -27,11 +27,15 @@ MODULE_LICENSE("GPL");
27MODULE_ALIAS_LDISC(N_MOUSE); 27MODULE_ALIAS_LDISC(N_MOUSE);
28 28
29#define SERPORT_BUSY 1 29#define SERPORT_BUSY 1
30#define SERPORT_ACTIVE 2
31#define SERPORT_DEAD 3
30 32
31struct serport { 33struct serport {
32 struct tty_struct *tty; 34 struct tty_struct *tty;
33 wait_queue_head_t wait; 35 wait_queue_head_t wait;
34 struct serio *serio; 36 struct serio *serio;
37 struct serio_device_id id;
38 spinlock_t lock;
35 unsigned long flags; 39 unsigned long flags;
36}; 40};
37 41
@@ -45,11 +49,29 @@ static int serport_serio_write(struct serio *serio, unsigned char data)
45 return -(serport->tty->driver->write(serport->tty, &data, 1) != 1); 49 return -(serport->tty->driver->write(serport->tty, &data, 1) != 1);
46} 50}
47 51
52static int serport_serio_open(struct serio *serio)
53{
54 struct serport *serport = serio->port_data;
55 unsigned long flags;
56
57 spin_lock_irqsave(&serport->lock, flags);
58 set_bit(SERPORT_ACTIVE, &serport->flags);
59 spin_unlock_irqrestore(&serport->lock, flags);
60
61 return 0;
62}
63
64
48static void serport_serio_close(struct serio *serio) 65static void serport_serio_close(struct serio *serio)
49{ 66{
50 struct serport *serport = serio->port_data; 67 struct serport *serport = serio->port_data;
68 unsigned long flags;
69
70 spin_lock_irqsave(&serport->lock, flags);
71 clear_bit(SERPORT_ACTIVE, &serport->flags);
72 set_bit(SERPORT_DEAD, &serport->flags);
73 spin_unlock_irqrestore(&serport->lock, flags);
51 74
52 serport->serio->id.type = 0;
53 wake_up_interruptible(&serport->wait); 75 wake_up_interruptible(&serport->wait);
54} 76}
55 77
@@ -61,36 +83,21 @@ static void serport_serio_close(struct serio *serio)
61static int serport_ldisc_open(struct tty_struct *tty) 83static int serport_ldisc_open(struct tty_struct *tty)
62{ 84{
63 struct serport *serport; 85 struct serport *serport;
64 struct serio *serio;
65 char name[64];
66 86
67 if (!capable(CAP_SYS_ADMIN)) 87 if (!capable(CAP_SYS_ADMIN))
68 return -EPERM; 88 return -EPERM;
69 89
70 serport = kmalloc(sizeof(struct serport), GFP_KERNEL); 90 serport = kcalloc(1, sizeof(struct serport), GFP_KERNEL);
71 serio = kmalloc(sizeof(struct serio), GFP_KERNEL); 91 if (!serport)
72 if (unlikely(!serport || !serio)) {
73 kfree(serport);
74 kfree(serio);
75 return -ENOMEM; 92 return -ENOMEM;
76 }
77 93
78 memset(serport, 0, sizeof(struct serport));
79 serport->serio = serio;
80 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
81 serport->tty = tty; 94 serport->tty = tty;
82 tty->disc_data = serport; 95 spin_lock_init(&serport->lock);
83
84 memset(serio, 0, sizeof(struct serio));
85 strlcpy(serio->name, "Serial port", sizeof(serio->name));
86 snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", tty_name(tty, name));
87 serio->id.type = SERIO_RS232;
88 serio->write = serport_serio_write;
89 serio->close = serport_serio_close;
90 serio->port_data = serport;
91
92 init_waitqueue_head(&serport->wait); 96 init_waitqueue_head(&serport->wait);
93 97
98 tty->disc_data = serport;
99 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
100
94 return 0; 101 return 0;
95} 102}
96 103
@@ -100,7 +107,8 @@ static int serport_ldisc_open(struct tty_struct *tty)
100 107
101static void serport_ldisc_close(struct tty_struct *tty) 108static void serport_ldisc_close(struct tty_struct *tty)
102{ 109{
103 struct serport *serport = (struct serport*) tty->disc_data; 110 struct serport *serport = (struct serport *) tty->disc_data;
111
104 kfree(serport); 112 kfree(serport);
105} 113}
106 114
@@ -116,9 +124,19 @@ static void serport_ldisc_close(struct tty_struct *tty)
116static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) 124static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
117{ 125{
118 struct serport *serport = (struct serport*) tty->disc_data; 126 struct serport *serport = (struct serport*) tty->disc_data;
127 unsigned long flags;
119 int i; 128 int i;
129
130 spin_lock_irqsave(&serport->lock, flags);
131
132 if (!test_bit(SERPORT_ACTIVE, &serport->flags))
133 goto out;
134
120 for (i = 0; i < count; i++) 135 for (i = 0; i < count; i++)
121 serio_interrupt(serport->serio, cp[i], 0, NULL); 136 serio_interrupt(serport->serio, cp[i], 0, NULL);
137
138out:
139 spin_unlock_irqrestore(&serport->lock, flags);
122} 140}
123 141
124/* 142/*
@@ -141,16 +159,33 @@ static int serport_ldisc_room(struct tty_struct *tty)
141static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, unsigned char __user * buf, size_t nr) 159static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, unsigned char __user * buf, size_t nr)
142{ 160{
143 struct serport *serport = (struct serport*) tty->disc_data; 161 struct serport *serport = (struct serport*) tty->disc_data;
162 struct serio *serio;
144 char name[64]; 163 char name[64];
145 164
146 if (test_and_set_bit(SERPORT_BUSY, &serport->flags)) 165 if (test_and_set_bit(SERPORT_BUSY, &serport->flags))
147 return -EBUSY; 166 return -EBUSY;
148 167
168 serport->serio = serio = kcalloc(1, sizeof(struct serio), GFP_KERNEL);
169 if (!serio)
170 return -ENOMEM;
171
172 strlcpy(serio->name, "Serial port", sizeof(serio->name));
173 snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", tty_name(tty, name));
174 serio->id = serport->id;
175 serio->id.type = SERIO_RS232;
176 serio->write = serport_serio_write;
177 serio->open = serport_serio_open;
178 serio->close = serport_serio_close;
179 serio->port_data = serport;
180
149 serio_register_port(serport->serio); 181 serio_register_port(serport->serio);
150 printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty, name)); 182 printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty, name));
151 wait_event_interruptible(serport->wait, !serport->serio->id.type); 183
184 wait_event_interruptible(serport->wait, test_bit(SERPORT_DEAD, &serport->flags));
152 serio_unregister_port(serport->serio); 185 serio_unregister_port(serport->serio);
186 serport->serio = NULL;
153 187
188 clear_bit(SERPORT_DEAD, &serport->flags);
154 clear_bit(SERPORT_BUSY, &serport->flags); 189 clear_bit(SERPORT_BUSY, &serport->flags);
155 190
156 return 0; 191 return 0;
@@ -163,16 +198,15 @@ static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, u
163static int serport_ldisc_ioctl(struct tty_struct * tty, struct file * file, unsigned int cmd, unsigned long arg) 198static int serport_ldisc_ioctl(struct tty_struct * tty, struct file * file, unsigned int cmd, unsigned long arg)
164{ 199{
165 struct serport *serport = (struct serport*) tty->disc_data; 200 struct serport *serport = (struct serport*) tty->disc_data;
166 struct serio *serio = serport->serio;
167 unsigned long type; 201 unsigned long type;
168 202
169 if (cmd == SPIOCSTYPE) { 203 if (cmd == SPIOCSTYPE) {
170 if (get_user(type, (unsigned long __user *) arg)) 204 if (get_user(type, (unsigned long __user *) arg))
171 return -EFAULT; 205 return -EFAULT;
172 206
173 serio->id.proto = type & 0x000000ff; 207 serport->id.proto = type & 0x000000ff;
174 serio->id.id = (type & 0x0000ff00) >> 8; 208 serport->id.id = (type & 0x0000ff00) >> 8;
175 serio->id.extra = (type & 0x00ff0000) >> 16; 209 serport->id.extra = (type & 0x00ff0000) >> 16;
176 210
177 return 0; 211 return 0;
178 } 212 }
@@ -182,9 +216,13 @@ static int serport_ldisc_ioctl(struct tty_struct * tty, struct file * file, unsi
182 216
183static void serport_ldisc_write_wakeup(struct tty_struct * tty) 217static void serport_ldisc_write_wakeup(struct tty_struct * tty)
184{ 218{
185 struct serport *sp = (struct serport *) tty->disc_data; 219 struct serport *serport = (struct serport *) tty->disc_data;
220 unsigned long flags;
186 221
187 serio_drv_write_wakeup(sp->serio); 222 spin_lock_irqsave(&serport->lock, flags);
223 if (test_bit(SERPORT_ACTIVE, &serport->flags))
224 serio_drv_write_wakeup(serport->serio);
225 spin_unlock_irqrestore(&serport->lock, flags);
188} 226}
189 227
190/* 228/*
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index e0ac63effa55..d09308f30960 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -39,15 +39,16 @@
39#define MANUAL_MASK 0xe0 39#define MANUAL_MASK 0xe0
40#define AUTO_MASK 0x20 40#define AUTO_MASK 0x20
41 41
42static u8 TEMP_REG[3] = {0x26, 0x25, 0x27}; /* local, cpu, gpu */ 42static u8 TEMP_REG[3] = {0x26, 0x25, 0x27}; /* local, sensor1, sensor2 */
43static u8 LIMIT_REG[3] = {0x6b, 0x6a, 0x6c}; /* local, cpu, gpu */ 43static u8 LIMIT_REG[3] = {0x6b, 0x6a, 0x6c}; /* local, sensor1, sensor2 */
44static u8 MANUAL_MODE[2] = {0x5c, 0x5d}; 44static u8 MANUAL_MODE[2] = {0x5c, 0x5d};
45static u8 REM_CONTROL[2] = {0x00, 0x40}; 45static u8 REM_CONTROL[2] = {0x00, 0x40};
46static u8 FAN_SPEED[2] = {0x28, 0x2a}; 46static u8 FAN_SPEED[2] = {0x28, 0x2a};
47static u8 FAN_SPD_SET[2] = {0x30, 0x31}; 47static u8 FAN_SPD_SET[2] = {0x30, 0x31};
48 48
49static u8 default_limits_local[3] = {70, 50, 70}; /* local, cpu, gpu */ 49static u8 default_limits_local[3] = {70, 50, 70}; /* local, sensor1, sensor2 */
50static u8 default_limits_chip[3] = {80, 65, 80}; /* local, cpu, gpu */ 50static u8 default_limits_chip[3] = {80, 65, 80}; /* local, sensor1, sensor2 */
51static char *sensor_location[3] = {NULL, NULL, NULL};
51 52
52static int limit_adjust = 0; 53static int limit_adjust = 0;
53static int fan_speed = -1; 54static int fan_speed = -1;
@@ -58,7 +59,7 @@ MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and "
58MODULE_LICENSE("GPL"); 59MODULE_LICENSE("GPL");
59 60
60module_param(limit_adjust, int, 0644); 61module_param(limit_adjust, int, 0644);
61MODULE_PARM_DESC(limit_adjust,"Adjust maximum temperatures (50 cpu, 70 gpu) " 62MODULE_PARM_DESC(limit_adjust,"Adjust maximum temperatures (50 sensor1, 70 sensor2) "
62 "by N degrees."); 63 "by N degrees.");
63 64
64module_param(fan_speed, int, 0644); 65module_param(fan_speed, int, 0644);
@@ -213,10 +214,10 @@ static void write_fan_speed(struct thermostat *th, int speed, int fan)
213 if (th->last_speed[fan] != speed) { 214 if (th->last_speed[fan] != speed) {
214 if (speed == -1) 215 if (speed == -1)
215 printk(KERN_DEBUG "adt746x: Setting speed to automatic " 216 printk(KERN_DEBUG "adt746x: Setting speed to automatic "
216 "for %s fan.\n", fan?"GPU":"CPU"); 217 "for %s fan.\n", sensor_location[fan+1]);
217 else 218 else
218 printk(KERN_DEBUG "adt746x: Setting speed to %d " 219 printk(KERN_DEBUG "adt746x: Setting speed to %d "
219 "for %s fan.\n", speed, fan?"GPU":"CPU"); 220 "for %s fan.\n", speed, sensor_location[fan+1]);
220 } else 221 } else
221 return; 222 return;
222 223
@@ -300,11 +301,11 @@ static void update_fans_speed (struct thermostat *th)
300 printk(KERN_DEBUG "adt746x: setting fans speed to %d " 301 printk(KERN_DEBUG "adt746x: setting fans speed to %d "
301 "(limit exceeded by %d on %s) \n", 302 "(limit exceeded by %d on %s) \n",
302 new_speed, var, 303 new_speed, var,
303 fan_number?"GPU/pwr":"CPU"); 304 sensor_location[fan_number+1]);
304 write_both_fan_speed(th, new_speed); 305 write_both_fan_speed(th, new_speed);
305 th->last_var[fan_number] = var; 306 th->last_var[fan_number] = var;
306 } else if (var < -2) { 307 } else if (var < -2) {
307 /* don't stop fan if GPU/power is cold and CPU is not 308 /* don't stop fan if sensor2 is cold and sensor1 is not
308 * so cold (lastvar >= -1) */ 309 * so cold (lastvar >= -1) */
309 if (i == 2 && lastvar < -1) { 310 if (i == 2 && lastvar < -1) {
310 if (th->last_speed[fan_number] != 0) 311 if (th->last_speed[fan_number] != 0)
@@ -318,7 +319,7 @@ static void update_fans_speed (struct thermostat *th)
318 319
319 if (started) 320 if (started)
320 return; /* we don't want to re-stop the fan 321 return; /* we don't want to re-stop the fan
321 * if CPU is heating and GPU/power is not */ 322 * if sensor1 is heating and sensor2 is not */
322 } 323 }
323} 324}
324 325
@@ -353,7 +354,7 @@ static int monitor_task(void *arg)
353 354
354static void set_limit(struct thermostat *th, int i) 355static void set_limit(struct thermostat *th, int i)
355{ 356{
356 /* Set CPU limit higher to avoid powerdowns */ 357 /* Set sensor1 limit higher to avoid powerdowns */
357 th->limits[i] = default_limits_chip[i] + limit_adjust; 358 th->limits[i] = default_limits_chip[i] + limit_adjust;
358 write_reg(th, LIMIT_REG[i], th->limits[i]); 359 write_reg(th, LIMIT_REG[i], th->limits[i]);
359 360
@@ -461,6 +462,12 @@ static ssize_t show_##name(struct device *dev, char *buf) \
461 return sprintf(buf, "%d\n", data); \ 462 return sprintf(buf, "%d\n", data); \
462} 463}
463 464
465#define BUILD_SHOW_FUNC_STR(name, data) \
466static ssize_t show_##name(struct device *dev, char *buf) \
467{ \
468 return sprintf(buf, "%s\n", data); \
469}
470
464#define BUILD_SHOW_FUNC_FAN(name, data) \ 471#define BUILD_SHOW_FUNC_FAN(name, data) \
465static ssize_t show_##name(struct device *dev, char *buf) \ 472static ssize_t show_##name(struct device *dev, char *buf) \
466{ \ 473{ \
@@ -476,7 +483,7 @@ static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \
476 int val; \ 483 int val; \
477 int i; \ 484 int i; \
478 val = simple_strtol(buf, NULL, 10); \ 485 val = simple_strtol(buf, NULL, 10); \
479 printk(KERN_INFO "Adjusting limits by %d°C\n", val); \ 486 printk(KERN_INFO "Adjusting limits by %d degrees\n", val); \
480 limit_adjust = val; \ 487 limit_adjust = val; \
481 for (i=0; i < 3; i++) \ 488 for (i=0; i < 3; i++) \
482 set_limit(thermostat, i); \ 489 set_limit(thermostat, i); \
@@ -495,35 +502,41 @@ static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \
495 return n; \ 502 return n; \
496} 503}
497 504
498BUILD_SHOW_FUNC_INT(cpu_temperature, (read_reg(thermostat, TEMP_REG[1]))) 505BUILD_SHOW_FUNC_INT(sensor1_temperature, (read_reg(thermostat, TEMP_REG[1])))
499BUILD_SHOW_FUNC_INT(gpu_temperature, (read_reg(thermostat, TEMP_REG[2]))) 506BUILD_SHOW_FUNC_INT(sensor2_temperature, (read_reg(thermostat, TEMP_REG[2])))
500BUILD_SHOW_FUNC_INT(cpu_limit, thermostat->limits[1]) 507BUILD_SHOW_FUNC_INT(sensor1_limit, thermostat->limits[1])
501BUILD_SHOW_FUNC_INT(gpu_limit, thermostat->limits[2]) 508BUILD_SHOW_FUNC_INT(sensor2_limit, thermostat->limits[2])
509BUILD_SHOW_FUNC_STR(sensor1_location, sensor_location[1])
510BUILD_SHOW_FUNC_STR(sensor2_location, sensor_location[2])
502 511
503BUILD_SHOW_FUNC_INT(specified_fan_speed, fan_speed) 512BUILD_SHOW_FUNC_INT(specified_fan_speed, fan_speed)
504BUILD_SHOW_FUNC_FAN(cpu_fan_speed, 0) 513BUILD_SHOW_FUNC_FAN(sensor1_fan_speed, 0)
505BUILD_SHOW_FUNC_FAN(gpu_fan_speed, 1) 514BUILD_SHOW_FUNC_FAN(sensor2_fan_speed, 1)
506 515
507BUILD_STORE_FUNC_INT(specified_fan_speed,fan_speed) 516BUILD_STORE_FUNC_INT(specified_fan_speed,fan_speed)
508BUILD_SHOW_FUNC_INT(limit_adjust, limit_adjust) 517BUILD_SHOW_FUNC_INT(limit_adjust, limit_adjust)
509BUILD_STORE_FUNC_DEG(limit_adjust, thermostat) 518BUILD_STORE_FUNC_DEG(limit_adjust, thermostat)
510 519
511static DEVICE_ATTR(cpu_temperature, S_IRUGO, 520static DEVICE_ATTR(sensor1_temperature, S_IRUGO,
512 show_cpu_temperature,NULL); 521 show_sensor1_temperature,NULL);
513static DEVICE_ATTR(gpu_temperature, S_IRUGO, 522static DEVICE_ATTR(sensor2_temperature, S_IRUGO,
514 show_gpu_temperature,NULL); 523 show_sensor2_temperature,NULL);
515static DEVICE_ATTR(cpu_limit, S_IRUGO, 524static DEVICE_ATTR(sensor1_limit, S_IRUGO,
516 show_cpu_limit, NULL); 525 show_sensor1_limit, NULL);
517static DEVICE_ATTR(gpu_limit, S_IRUGO, 526static DEVICE_ATTR(sensor2_limit, S_IRUGO,
518 show_gpu_limit, NULL); 527 show_sensor2_limit, NULL);
528static DEVICE_ATTR(sensor1_location, S_IRUGO,
529 show_sensor1_location, NULL);
530static DEVICE_ATTR(sensor2_location, S_IRUGO,
531 show_sensor2_location, NULL);
519 532
520static DEVICE_ATTR(specified_fan_speed, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, 533static DEVICE_ATTR(specified_fan_speed, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH,
521 show_specified_fan_speed,store_specified_fan_speed); 534 show_specified_fan_speed,store_specified_fan_speed);
522 535
523static DEVICE_ATTR(cpu_fan_speed, S_IRUGO, 536static DEVICE_ATTR(sensor1_fan_speed, S_IRUGO,
524 show_cpu_fan_speed, NULL); 537 show_sensor1_fan_speed, NULL);
525static DEVICE_ATTR(gpu_fan_speed, S_IRUGO, 538static DEVICE_ATTR(sensor2_fan_speed, S_IRUGO,
526 show_gpu_fan_speed, NULL); 539 show_sensor2_fan_speed, NULL);
527 540
528static DEVICE_ATTR(limit_adjust, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, 541static DEVICE_ATTR(limit_adjust, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH,
529 show_limit_adjust, store_limit_adjust); 542 show_limit_adjust, store_limit_adjust);
@@ -534,6 +547,7 @@ thermostat_init(void)
534{ 547{
535 struct device_node* np; 548 struct device_node* np;
536 u32 *prop; 549 u32 *prop;
550 int i = 0, offset = 0;
537 551
538 np = of_find_node_by_name(NULL, "fan"); 552 np = of_find_node_by_name(NULL, "fan");
539 if (!np) 553 if (!np)
@@ -545,6 +559,12 @@ thermostat_init(void)
545 else 559 else
546 return -ENODEV; 560 return -ENODEV;
547 561
562 prop = (u32 *)get_property(np, "hwsensor-params-version", NULL);
563 printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop,
564 (*prop == 1)?"":"un");
565 if (*prop != 1)
566 return -ENODEV;
567
548 prop = (u32 *)get_property(np, "reg", NULL); 568 prop = (u32 *)get_property(np, "reg", NULL);
549 if (!prop) 569 if (!prop)
550 return -ENODEV; 570 return -ENODEV;
@@ -563,6 +583,23 @@ thermostat_init(void)
563 "limit_adjust: %d, fan_speed: %d\n", 583 "limit_adjust: %d, fan_speed: %d\n",
564 therm_bus, therm_address, limit_adjust, fan_speed); 584 therm_bus, therm_address, limit_adjust, fan_speed);
565 585
586 if (get_property(np, "hwsensor-location", NULL)) {
587 for (i = 0; i < 3; i++) {
588 sensor_location[i] = get_property(np,
589 "hwsensor-location", NULL) + offset;
590
591 if (sensor_location[i] == NULL)
592 sensor_location[i] = "";
593
594 printk(KERN_INFO "sensor %d: %s\n", i, sensor_location[i]);
595 offset += strlen(sensor_location[i]) + 1;
596 }
597 } else {
598 sensor_location[0] = "?";
599 sensor_location[1] = "?";
600 sensor_location[2] = "?";
601 }
602
566 of_dev = of_platform_device_create(np, "temperatures"); 603 of_dev = of_platform_device_create(np, "temperatures");
567 604
568 if (of_dev == NULL) { 605 if (of_dev == NULL) {
@@ -570,15 +607,17 @@ thermostat_init(void)
570 return -ENODEV; 607 return -ENODEV;
571 } 608 }
572 609
573 device_create_file(&of_dev->dev, &dev_attr_cpu_temperature); 610 device_create_file(&of_dev->dev, &dev_attr_sensor1_temperature);
574 device_create_file(&of_dev->dev, &dev_attr_gpu_temperature); 611 device_create_file(&of_dev->dev, &dev_attr_sensor2_temperature);
575 device_create_file(&of_dev->dev, &dev_attr_cpu_limit); 612 device_create_file(&of_dev->dev, &dev_attr_sensor1_limit);
576 device_create_file(&of_dev->dev, &dev_attr_gpu_limit); 613 device_create_file(&of_dev->dev, &dev_attr_sensor2_limit);
614 device_create_file(&of_dev->dev, &dev_attr_sensor1_location);
615 device_create_file(&of_dev->dev, &dev_attr_sensor2_location);
577 device_create_file(&of_dev->dev, &dev_attr_limit_adjust); 616 device_create_file(&of_dev->dev, &dev_attr_limit_adjust);
578 device_create_file(&of_dev->dev, &dev_attr_specified_fan_speed); 617 device_create_file(&of_dev->dev, &dev_attr_specified_fan_speed);
579 device_create_file(&of_dev->dev, &dev_attr_cpu_fan_speed); 618 device_create_file(&of_dev->dev, &dev_attr_sensor1_fan_speed);
580 if(therm_type == ADT7460) 619 if(therm_type == ADT7460)
581 device_create_file(&of_dev->dev, &dev_attr_gpu_fan_speed); 620 device_create_file(&of_dev->dev, &dev_attr_sensor2_fan_speed);
582 621
583#ifndef CONFIG_I2C_KEYWEST 622#ifndef CONFIG_I2C_KEYWEST
584 request_module("i2c-keywest"); 623 request_module("i2c-keywest");
@@ -591,17 +630,19 @@ static void __exit
591thermostat_exit(void) 630thermostat_exit(void)
592{ 631{
593 if (of_dev) { 632 if (of_dev) {
594 device_remove_file(&of_dev->dev, &dev_attr_cpu_temperature); 633 device_remove_file(&of_dev->dev, &dev_attr_sensor1_temperature);
595 device_remove_file(&of_dev->dev, &dev_attr_gpu_temperature); 634 device_remove_file(&of_dev->dev, &dev_attr_sensor2_temperature);
596 device_remove_file(&of_dev->dev, &dev_attr_cpu_limit); 635 device_remove_file(&of_dev->dev, &dev_attr_sensor1_limit);
597 device_remove_file(&of_dev->dev, &dev_attr_gpu_limit); 636 device_remove_file(&of_dev->dev, &dev_attr_sensor2_limit);
637 device_remove_file(&of_dev->dev, &dev_attr_sensor1_location);
638 device_remove_file(&of_dev->dev, &dev_attr_sensor2_location);
598 device_remove_file(&of_dev->dev, &dev_attr_limit_adjust); 639 device_remove_file(&of_dev->dev, &dev_attr_limit_adjust);
599 device_remove_file(&of_dev->dev, &dev_attr_specified_fan_speed); 640 device_remove_file(&of_dev->dev, &dev_attr_specified_fan_speed);
600 device_remove_file(&of_dev->dev, &dev_attr_cpu_fan_speed); 641 device_remove_file(&of_dev->dev, &dev_attr_sensor1_fan_speed);
601 642
602 if(therm_type == ADT7460) 643 if(therm_type == ADT7460)
603 device_remove_file(&of_dev->dev, 644 device_remove_file(&of_dev->dev,
604 &dev_attr_gpu_fan_speed); 645 &dev_attr_sensor2_fan_speed);
605 646
606 of_device_unregister(of_dev); 647 of_device_unregister(of_dev);
607 } 648 }
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 161e9aa87291..b1941b887f46 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -269,9 +269,8 @@ static int linear_make_request (request_queue_t *q, struct bio *bio)
269 * split it. 269 * split it.
270 */ 270 */
271 struct bio_pair *bp; 271 struct bio_pair *bp;
272 bp = bio_split(bio, bio_split_pool, 272 bp = bio_split(bio, bio_split_pool,
273 (bio->bi_sector + (bio->bi_size >> 9) - 273 ((tmp_dev->offset + tmp_dev->size)<<1) - bio->bi_sector);
274 (tmp_dev->offset + tmp_dev->size))<<1);
275 if (linear_make_request(q, &bp->bio1)) 274 if (linear_make_request(q, &bp->bio1))
276 generic_make_request(&bp->bio1); 275 generic_make_request(&bp->bio1);
277 if (linear_make_request(q, &bp->bio2)) 276 if (linear_make_request(q, &bp->bio2))
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 4e4bfde3db5d..2ae2d709cb15 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -462,10 +462,6 @@ static int multipath_run (mddev_t *mddev)
462 } 462 }
463 memset(conf->multipaths, 0, sizeof(struct multipath_info)*mddev->raid_disks); 463 memset(conf->multipaths, 0, sizeof(struct multipath_info)*mddev->raid_disks);
464 464
465 mddev->queue->unplug_fn = multipath_unplug;
466
467 mddev->queue->issue_flush_fn = multipath_issue_flush;
468
469 conf->working_disks = 0; 465 conf->working_disks = 0;
470 ITERATE_RDEV(mddev,rdev,tmp) { 466 ITERATE_RDEV(mddev,rdev,tmp) {
471 disk_idx = rdev->raid_disk; 467 disk_idx = rdev->raid_disk;
@@ -528,6 +524,10 @@ static int multipath_run (mddev_t *mddev)
528 * Ok, everything is just fine now 524 * Ok, everything is just fine now
529 */ 525 */
530 mddev->array_size = mddev->size; 526 mddev->array_size = mddev->size;
527
528 mddev->queue->unplug_fn = multipath_unplug;
529 mddev->queue->issue_flush_fn = multipath_issue_flush;
530
531 return 0; 531 return 0;
532 532
533out_free_conf: 533out_free_conf:
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 83380b5d6593..1db5de52d376 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1197,10 +1197,6 @@ static int run(mddev_t *mddev)
1197 if (!conf->r1bio_pool) 1197 if (!conf->r1bio_pool)
1198 goto out_no_mem; 1198 goto out_no_mem;
1199 1199
1200 mddev->queue->unplug_fn = raid1_unplug;
1201
1202 mddev->queue->issue_flush_fn = raid1_issue_flush;
1203
1204 ITERATE_RDEV(mddev, rdev, tmp) { 1200 ITERATE_RDEV(mddev, rdev, tmp) {
1205 disk_idx = rdev->raid_disk; 1201 disk_idx = rdev->raid_disk;
1206 if (disk_idx >= mddev->raid_disks 1202 if (disk_idx >= mddev->raid_disks
@@ -1282,6 +1278,9 @@ static int run(mddev_t *mddev)
1282 */ 1278 */
1283 mddev->array_size = mddev->size; 1279 mddev->array_size = mddev->size;
1284 1280
1281 mddev->queue->unplug_fn = raid1_unplug;
1282 mddev->queue->issue_flush_fn = raid1_issue_flush;
1283
1285 return 0; 1284 return 0;
1286 1285
1287out_no_mem: 1286out_no_mem:
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index e9dc2876a626..3c37be6423d7 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1639,9 +1639,6 @@ static int run(mddev_t *mddev)
1639 mdname(mddev)); 1639 mdname(mddev));
1640 goto out_free_conf; 1640 goto out_free_conf;
1641 } 1641 }
1642 mddev->queue->unplug_fn = raid10_unplug;
1643
1644 mddev->queue->issue_flush_fn = raid10_issue_flush;
1645 1642
1646 ITERATE_RDEV(mddev, rdev, tmp) { 1643 ITERATE_RDEV(mddev, rdev, tmp) {
1647 disk_idx = rdev->raid_disk; 1644 disk_idx = rdev->raid_disk;
@@ -1713,6 +1710,9 @@ static int run(mddev_t *mddev)
1713 mddev->array_size = size/2; 1710 mddev->array_size = size/2;
1714 mddev->resync_max_sectors = size; 1711 mddev->resync_max_sectors = size;
1715 1712
1713 mddev->queue->unplug_fn = raid10_unplug;
1714 mddev->queue->issue_flush_fn = raid10_issue_flush;
1715
1716 /* Calculate max read-ahead size. 1716 /* Calculate max read-ahead size.
1717 * We need to readahead at least twice a whole stripe.... 1717 * We need to readahead at least twice a whole stripe....
1718 * maybe... 1718 * maybe...
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index e96e2a10a9c9..3cb11ac232fa 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1620,9 +1620,6 @@ static int run (mddev_t *mddev)
1620 atomic_set(&conf->active_stripes, 0); 1620 atomic_set(&conf->active_stripes, 0);
1621 atomic_set(&conf->preread_active_stripes, 0); 1621 atomic_set(&conf->preread_active_stripes, 0);
1622 1622
1623 mddev->queue->unplug_fn = raid5_unplug_device;
1624 mddev->queue->issue_flush_fn = raid5_issue_flush;
1625
1626 PRINTK("raid5: run(%s) called.\n", mdname(mddev)); 1623 PRINTK("raid5: run(%s) called.\n", mdname(mddev));
1627 1624
1628 ITERATE_RDEV(mddev,rdev,tmp) { 1625 ITERATE_RDEV(mddev,rdev,tmp) {
@@ -1728,6 +1725,10 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
1728 } 1725 }
1729 1726
1730 /* Ok, everything is just fine now */ 1727 /* Ok, everything is just fine now */
1728
1729 mddev->queue->unplug_fn = raid5_unplug_device;
1730 mddev->queue->issue_flush_fn = raid5_issue_flush;
1731
1731 mddev->array_size = mddev->size * (mddev->raid_disks - 1); 1732 mddev->array_size = mddev->size * (mddev->raid_disks - 1);
1732 return 0; 1733 return 0;
1733abort: 1734abort:
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index 8a33f351e092..908edd78a792 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -1779,9 +1779,6 @@ static int run (mddev_t *mddev)
1779 atomic_set(&conf->active_stripes, 0); 1779 atomic_set(&conf->active_stripes, 0);
1780 atomic_set(&conf->preread_active_stripes, 0); 1780 atomic_set(&conf->preread_active_stripes, 0);
1781 1781
1782 mddev->queue->unplug_fn = raid6_unplug_device;
1783 mddev->queue->issue_flush_fn = raid6_issue_flush;
1784
1785 PRINTK("raid6: run(%s) called.\n", mdname(mddev)); 1782 PRINTK("raid6: run(%s) called.\n", mdname(mddev));
1786 1783
1787 ITERATE_RDEV(mddev,rdev,tmp) { 1784 ITERATE_RDEV(mddev,rdev,tmp) {
@@ -1895,6 +1892,9 @@ static int run (mddev_t *mddev)
1895 1892
1896 /* Ok, everything is just fine now */ 1893 /* Ok, everything is just fine now */
1897 mddev->array_size = mddev->size * (mddev->raid_disks - 2); 1894 mddev->array_size = mddev->size * (mddev->raid_disks - 2);
1895
1896 mddev->queue->unplug_fn = raid6_unplug_device;
1897 mddev->queue->issue_flush_fn = raid6_issue_flush;
1898 return 0; 1898 return 0;
1899abort: 1899abort:
1900 if (conf) { 1900 if (conf) {
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 9f6c19ac1285..50e8b8654018 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -23,9 +23,9 @@
23LIST_HEAD(saa7146_devices); 23LIST_HEAD(saa7146_devices);
24DECLARE_MUTEX(saa7146_devices_lock); 24DECLARE_MUTEX(saa7146_devices_lock);
25 25
26static int saa7146_num = 0; 26static int saa7146_num;
27 27
28unsigned int saa7146_debug = 0; 28unsigned int saa7146_debug;
29 29
30module_param(saa7146_debug, int, 0644); 30module_param(saa7146_debug, int, 0644);
31MODULE_PARM_DESC(saa7146_debug, "debug level (default: 0)"); 31MODULE_PARM_DESC(saa7146_debug, "debug level (default: 0)");
diff --git a/drivers/media/dvb/Kconfig b/drivers/media/dvb/Kconfig
index 883ec08490f4..4983e1b1bb1d 100644
--- a/drivers/media/dvb/Kconfig
+++ b/drivers/media/dvb/Kconfig
@@ -33,7 +33,7 @@ source "drivers/media/dvb/dibusb/Kconfig"
33source "drivers/media/dvb/cinergyT2/Kconfig" 33source "drivers/media/dvb/cinergyT2/Kconfig"
34 34
35comment "Supported FlexCopII (B2C2) Adapters" 35comment "Supported FlexCopII (B2C2) Adapters"
36 depends on DVB_CORE && PCI 36 depends on DVB_CORE && (PCI || USB)
37source "drivers/media/dvb/b2c2/Kconfig" 37source "drivers/media/dvb/b2c2/Kconfig"
38 38
39comment "Supported BT878 Adapters" 39comment "Supported BT878 Adapters"
diff --git a/drivers/media/dvb/b2c2/Kconfig b/drivers/media/dvb/b2c2/Kconfig
index 52596907a0be..99bd675df955 100644
--- a/drivers/media/dvb/b2c2/Kconfig
+++ b/drivers/media/dvb/b2c2/Kconfig
@@ -1,26 +1,50 @@
1config DVB_B2C2_SKYSTAR 1config DVB_B2C2_FLEXCOP
2 tristate "B2C2/Technisat Air/Sky/CableStar 2 PCI" 2 tristate "Technisat/B2C2 FlexCopII(b) and FlexCopIII adapters"
3 depends on DVB_CORE && PCI 3 depends on DVB_CORE
4 select DVB_STV0299 4 select DVB_STV0299
5 select DVB_MT352 5 select DVB_MT352
6 select DVB_MT312 6 select DVB_MT312
7 select DVB_NXT2002 7 select DVB_NXT2002
8 select DVB_STV0297
8 help 9 help
9 Support for the Skystar2 PCI DVB card by Technisat, which 10 Support for the digital TV receiver chip made by B2C2 Inc. included in
10 is equipped with the FlexCopII chipset by B2C2, and 11 Technisats PCI cards and USB boxes.
11 for the B2C2/BBTI Air2PC-ATSC card.
12 12
13 Say Y if you own such a device and want to use it. 13 Say Y if you own such a device and want to use it.
14 14
15config DVB_B2C2_USB 15config DVB_B2C2_FLEXCOP_PCI
16 tristate "B2C2/Technisat Air/Sky/Cable2PC USB" 16 tristate "Technisat/B2C2 Air/Sky/Cable2PC PCI"
17 depends on DVB_CORE && USB && EXPERIMENTAL 17 depends on DVB_B2C2_FLEXCOP && PCI
18 help
19 Support for the Air/Sky/CableStar2 PCI card (DVB/ATSC) by Technisat/B2C2.
20
21 Say Y if you own such a device and want to use it.
22
23config DVB_B2C2_FLEXCOP_USB
24 tristate "Technisat/B2C2 Air/Sky/Cable2PC USB"
25 depends on DVB_B2C2_FLEXCOP && USB
26 help
27 Support for the Air/Sky/Cable2PC USB1.1 box (DVB/ATSC) by Technisat/B2C2,
28
29 Say Y if you own such a device and want to use it.
30
31config DVB_B2C2_FLEXCOP_DEBUG
32 bool "Enable debug for the B2C2 FlexCop drivers"
33 depends on DVB_B2C2_FLEXCOP
34 help
35 Say Y if you want to enable the module option to control debug messages
36 of all B2C2 FlexCop drivers.
37
38config DVB_B2C2_SKYSTAR
39 tristate "B2C2/Technisat Air/Sky/CableStar 2 PCI"
40 depends on DVB_CORE && PCI
18 select DVB_STV0299 41 select DVB_STV0299
19 select DVB_MT352 42 select DVB_MT352
43 select DVB_MT312
44 select DVB_NXT2002
20 help 45 help
21 Support for the Air/Sky/Cable2PC USB DVB device by B2C2. Currently 46 Support for the Skystar2 PCI DVB card by Technisat, which
22 the does nothing, but providing basic function for the used usb 47 is equipped with the FlexCopII chipset by B2C2, and
23 protocol. 48 for the B2C2/BBTI Air2PC-ATSC card.
24 49
25 Say Y if you own such a device and want to use it. 50 Say Y if you own such a device and want to use it.
26
diff --git a/drivers/media/dvb/b2c2/Makefile b/drivers/media/dvb/b2c2/Makefile
index 9fb1247bfab8..7703812af34f 100644
--- a/drivers/media/dvb/b2c2/Makefile
+++ b/drivers/media/dvb/b2c2/Makefile
@@ -1,6 +1,14 @@
1obj-b2c2-usb = b2c2-usb-core.o b2c2-common.o 1b2c2-flexcop-objs = flexcop.o flexcop-fe-tuner.o flexcop-i2c.o \
2 flexcop-sram.o flexcop-eeprom.o flexcop-misc.o flexcop-hw-filter.o \
3 flexcop-dma.o
4obj-$(CONFIG_DVB_B2C2_FLEXCOP) += b2c2-flexcop.o
5
6b2c2-flexcop-pci-objs = flexcop-pci.o
7obj-$(CONFIG_DVB_B2C2_FLEXCOP_PCI) += b2c2-flexcop-pci.o
8
9b2c2-flexcop-usb-objs = flexcop-usb.o
10obj-$(CONFIG_DVB_B2C2_FLEXCOP_USB) += b2c2-flexcop-usb.o
2 11
3obj-$(CONFIG_DVB_B2C2_SKYSTAR) += skystar2.o 12obj-$(CONFIG_DVB_B2C2_SKYSTAR) += skystar2.o
4obj-$(CONFIG_DVB_B2C2_USB) + = b2c2-usb.o
5 13
6EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 14EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff --git a/drivers/media/dvb/b2c2/b2c2-common.c b/drivers/media/dvb/b2c2/b2c2-common.c
deleted file mode 100644
index 000d60c405e3..000000000000
--- a/drivers/media/dvb/b2c2/b2c2-common.c
+++ /dev/null
@@ -1,214 +0,0 @@
1/*
2 * b2c2-common.c - common methods for the B2C2/Technisat SkyStar2 PCI DVB card and
3 * for the B2C2/Technisat Sky/Cable/AirStar USB devices
4 * based on the FlexCopII/FlexCopIII by B2C2, Inc.
5 *
6 * Copyright (C) 2003 Vadim Catana, skystar@moldova.cc
7 *
8 * FIX: DISEQC Tone Burst in flexcop_diseqc_ioctl()
9 * FIX: FULL soft DiSEqC for skystar2 (FlexCopII rev 130) VP310 equipped
10 * Vincenzo Di Massa, hawk.it at tiscalinet.it
11 *
12 * Converted to Linux coding style
13 * Misc reorganization, polishing, restyling
14 * Roberto Ragusa, r.ragusa at libero.it
15 *
16 * Added hardware filtering support,
17 * Niklas Peinecke, peinecke at gdv.uni-hannover.de
18 *
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU Lesser General Public License
21 * as published by the Free Software Foundation; either version 2.1
22 * of the License, or (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU Lesser General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 *
33 */
34#include "stv0299.h"
35#include "mt352.h"
36#include "mt312.h"
37
38static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
39{
40 u8 aclk = 0;
41 u8 bclk = 0;
42
43 if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
44 else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
45 else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
46 else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
47 else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
48 else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
49
50 stv0299_writereg (fe, 0x13, aclk);
51 stv0299_writereg (fe, 0x14, bclk);
52 stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
53 stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff);
54 stv0299_writereg (fe, 0x21, (ratio ) & 0xf0);
55
56 return 0;
57}
58
59static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
60{
61 u8 buf[4];
62 u32 div;
63 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
64// struct adapter* adapter = (struct adapter*) fe->dvb->priv;
65
66 div = params->frequency / 125;
67
68 buf[0] = (div >> 8) & 0x7f;
69 buf[1] = div & 0xff;
70 buf[2] = 0x84; // 0xC4
71 buf[3] = 0x08;
72
73 if (params->frequency < 1500000) buf[3] |= 0x10;
74
75// if (i2c_transfer (&adapter->i2c_adap, &msg, 1) != 1) return -EIO;
76 return 0;
77}
78
79static u8 samsung_tbmu24112_inittab[] = {
80 0x01, 0x15,
81 0x02, 0x30,
82 0x03, 0x00,
83 0x04, 0x7D,
84 0x05, 0x35,
85 0x06, 0x02,
86 0x07, 0x00,
87 0x08, 0xC3,
88 0x0C, 0x00,
89 0x0D, 0x81,
90 0x0E, 0x23,
91 0x0F, 0x12,
92 0x10, 0x7E,
93 0x11, 0x84,
94 0x12, 0xB9,
95 0x13, 0x88,
96 0x14, 0x89,
97 0x15, 0xC9,
98 0x16, 0x00,
99 0x17, 0x5C,
100 0x18, 0x00,
101 0x19, 0x00,
102 0x1A, 0x00,
103 0x1C, 0x00,
104 0x1D, 0x00,
105 0x1E, 0x00,
106 0x1F, 0x3A,
107 0x20, 0x2E,
108 0x21, 0x80,
109 0x22, 0xFF,
110 0x23, 0xC1,
111 0x28, 0x00,
112 0x29, 0x1E,
113 0x2A, 0x14,
114 0x2B, 0x0F,
115 0x2C, 0x09,
116 0x2D, 0x05,
117 0x31, 0x1F,
118 0x32, 0x19,
119 0x33, 0xFE,
120 0x34, 0x93,
121 0xff, 0xff,
122};
123
124static struct stv0299_config samsung_tbmu24112_config = {
125 .demod_address = 0x68,
126 .inittab = samsung_tbmu24112_inittab,
127 .mclk = 88000000UL,
128 .invert = 0,
129 .enhanced_tuning = 0,
130 .skip_reinit = 0,
131 .lock_output = STV0229_LOCKOUTPUT_LK,
132 .volt13_op0_op1 = STV0299_VOLT13_OP1,
133 .min_delay_ms = 100,
134 .set_symbol_rate = samsung_tbmu24112_set_symbol_rate,
135 .pll_set = samsung_tbmu24112_pll_set,
136};
137
138
139
140
141
142static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
143{
144 static u8 mt352_clock_config [] = { 0x89, 0x10, 0x2d };
145 static u8 mt352_reset [] = { 0x50, 0x80 };
146 static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
147 static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0xa1 };
148 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
149
150 mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
151 udelay(2000);
152 mt352_write(fe, mt352_reset, sizeof(mt352_reset));
153 mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
154
155 mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
156 mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
157
158 return 0;
159}
160
161static int samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
162{
163 u32 div;
164 unsigned char bs = 0;
165
166 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
167 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
168
169 if (params->frequency >= 48000000 && params->frequency <= 154000000) bs = 0x09;
170 if (params->frequency >= 161000000 && params->frequency <= 439000000) bs = 0x0a;
171 if (params->frequency >= 447000000 && params->frequency <= 863000000) bs = 0x08;
172
173 pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address
174 pllbuf[1] = div >> 8;
175 pllbuf[2] = div & 0xff;
176 pllbuf[3] = 0xcc;
177 pllbuf[4] = bs;
178
179 return 0;
180}
181
182static struct mt352_config samsung_tdtc9251dh0_config = {
183
184 .demod_address = 0x0f,
185 .demod_init = samsung_tdtc9251dh0_demod_init,
186 .pll_set = samsung_tdtc9251dh0_pll_set,
187};
188
189static int skystar23_samsung_tbdu18132_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
190{
191 u8 buf[4];
192 u32 div;
193 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
194// struct adapter* adapter = (struct adapter*) fe->dvb->priv;
195
196 div = (params->frequency + (125/2)) / 125;
197
198 buf[0] = (div >> 8) & 0x7f;
199 buf[1] = (div >> 0) & 0xff;
200 buf[2] = 0x84 | ((div >> 10) & 0x60);
201 buf[3] = 0x80;
202
203 if (params->frequency < 1550000)
204 buf[3] |= 0x02;
205
206 //if (i2c_transfer (&adapter->i2c_adap, &msg, 1) != 1) return -EIO;
207 return 0;
208}
209
210static struct mt312_config skystar23_samsung_tbdu18132_config = {
211
212 .demod_address = 0x0e,
213 .pll_set = skystar23_samsung_tbdu18132_pll_set,
214};
diff --git a/drivers/media/dvb/b2c2/b2c2-usb-core.c b/drivers/media/dvb/b2c2/b2c2-usb-core.c
deleted file mode 100644
index 9306da046c91..000000000000
--- a/drivers/media/dvb/b2c2/b2c2-usb-core.c
+++ /dev/null
@@ -1,549 +0,0 @@
1/*
2 * Copyright (C) 2004 Patrick Boettcher <patrick.boettcher@desy.de>,
3 * Luca Bertagnolio <>,
4 *
5 * based on information provided by John Jurrius from BBTI, Inc.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, version 2.
10 *
11 */
12
13#include <linux/config.h>
14#include <linux/kernel.h>
15#include <linux/usb.h>
16#include <linux/moduleparam.h>
17#include <linux/pci.h>
18#include <linux/version.h>
19
20#include "dmxdev.h"
21#include "dvb_demux.h"
22#include "dvb_filter.h"
23#include "dvb_net.h"
24#include "dvb_frontend.h"
25
26/* debug */
27#define dprintk(level,args...) \
28 do { if ((debug & level)) { printk(args); } } while (0)
29#define debug_dump(b,l) if (debug) {\
30 int i; deb_xfer("%s: %d > ",__FUNCTION__,l); \
31 for (i = 0; i < l; i++) deb_xfer("%02x ", b[i]); \
32 deb_xfer("\n");\
33}
34
35static int debug;
36module_param(debug, int, 0644);
37MODULE_PARM_DESC(debug, "set debugging level (1=info,ts=2,ctrl=4 (or-able)).");
38
39#define deb_info(args...) dprintk(0x01,args)
40#define deb_ts(args...) dprintk(0x02,args)
41#define deb_ctrl(args...) dprintk(0x04,args)
42
43/* Version information */
44#define DRIVER_VERSION "0.0"
45#define DRIVER_DESC "Driver for B2C2/Technisat Air/Cable/Sky-2-PC USB devices"
46#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de"
47
48/* transfer parameters */
49#define B2C2_USB_FRAMES_PER_ISO 4
50#define B2C2_USB_NUM_ISO_URB 4 /* TODO check out a good value */
51
52#define B2C2_USB_CTRL_PIPE_IN usb_rcvctrlpipe(b2c2->udev,0)
53#define B2C2_USB_CTRL_PIPE_OUT usb_sndctrlpipe(b2c2->udev,0)
54#define B2C2_USB_DATA_PIPE usb_rcvisocpipe(b2c2->udev,0x81)
55
56struct usb_b2c2_usb {
57 struct usb_device *udev;
58 struct usb_interface *uintf;
59
60 u8 *iso_buffer;
61 int buffer_size;
62 dma_addr_t iso_dma_handle;
63 struct urb *iso_urb[B2C2_USB_NUM_ISO_URB];
64};
65
66
67/*
68 * USB
69 * 10 90 34 12 78 56 04 00
70 * usb_control_msg(udev, usb_sndctrlpipe(udev,0),
71 * 0x90,
72 * 0x10,
73 * 0x1234,
74 * 0x5678,
75 * buf,
76 * 4,
77 * 5*HZ);
78 *
79 * extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
80 * __u8 request,
81 * __u8 requesttype,
82 * __u16 value,
83 * __u16 index,
84 * void *data,
85 * __u16 size,
86 * int timeout);
87 *
88 */
89
90/* request types */
91typedef enum {
92
93/* something is wrong with this part
94 RTYPE_READ_DW = (1 << 6),
95 RTYPE_WRITE_DW_1 = (3 << 6),
96 RTYPE_READ_V8_MEMORY = (6 << 6),
97 RTYPE_WRITE_V8_MEMORY = (7 << 6),
98 RTYPE_WRITE_V8_FLASH = (8 << 6),
99 RTYPE_GENERIC = (9 << 6),
100*/
101 RTYPE_READ_DW = (3 << 6),
102 RTYPE_WRITE_DW_1 = (1 << 6),
103
104 RTYPE_READ_V8_MEMORY = (6 << 6),
105 RTYPE_WRITE_V8_MEMORY = (7 << 6),
106 RTYPE_WRITE_V8_FLASH = (8 << 6),
107 RTYPE_GENERIC = (9 << 6),
108} b2c2_usb_request_type_t;
109
110/* request */
111typedef enum {
112 B2C2_USB_WRITE_V8_MEM = 0x04,
113 B2C2_USB_READ_V8_MEM = 0x05,
114 B2C2_USB_READ_REG = 0x08,
115 B2C2_USB_WRITE_REG = 0x0A,
116/* B2C2_USB_WRITEREGLO = 0x0A, */
117 B2C2_USB_WRITEREGHI = 0x0B,
118 B2C2_USB_FLASH_BLOCK = 0x10,
119 B2C2_USB_I2C_REQUEST = 0x11,
120 B2C2_USB_UTILITY = 0x12,
121} b2c2_usb_request_t;
122
123/* function definition for I2C_REQUEST */
124typedef enum {
125 USB_FUNC_I2C_WRITE = 0x01,
126 USB_FUNC_I2C_MULTIWRITE = 0x02,
127 USB_FUNC_I2C_READ = 0x03,
128 USB_FUNC_I2C_REPEATWRITE = 0x04,
129 USB_FUNC_GET_DESCRIPTOR = 0x05,
130 USB_FUNC_I2C_REPEATREAD = 0x06,
131/* DKT 020208 - add this to support special case of DiSEqC */
132 USB_FUNC_I2C_CHECKWRITE = 0x07,
133 USB_FUNC_I2C_CHECKRESULT = 0x08,
134} b2c2_usb_i2c_function_t;
135
136/*
137 * function definition for UTILITY request 0x12
138 * DKT 020304 - new utility function
139 */
140typedef enum {
141 UTILITY_SET_FILTER = 0x01,
142 UTILITY_DATA_ENABLE = 0x02,
143 UTILITY_FLEX_MULTIWRITE = 0x03,
144 UTILITY_SET_BUFFER_SIZE = 0x04,
145 UTILITY_FLEX_OPERATOR = 0x05,
146 UTILITY_FLEX_RESET300_START = 0x06,
147 UTILITY_FLEX_RESET300_STOP = 0x07,
148 UTILITY_FLEX_RESET300 = 0x08,
149 UTILITY_SET_ISO_SIZE = 0x09,
150 UTILITY_DATA_RESET = 0x0A,
151 UTILITY_GET_DATA_STATUS = 0x10,
152 UTILITY_GET_V8_REG = 0x11,
153/* DKT 020326 - add function for v1.14 */
154 UTILITY_SRAM_WRITE = 0x12,
155 UTILITY_SRAM_READ = 0x13,
156 UTILITY_SRAM_TESTFILL = 0x14,
157 UTILITY_SRAM_TESTSET = 0x15,
158 UTILITY_SRAM_TESTVERIFY = 0x16,
159} b2c2_usb_utility_function_t;
160
161#define B2C2_WAIT_FOR_OPERATION_RW 1 // 1 s
162#define B2C2_WAIT_FOR_OPERATION_RDW 3 // 3 s
163#define B2C2_WAIT_FOR_OPERATION_WDW 1 // 1 s
164
165#define B2C2_WAIT_FOR_OPERATION_V8READ 3 // 3 s
166#define B2C2_WAIT_FOR_OPERATION_V8WRITE 3 // 3 s
167#define B2C2_WAIT_FOR_OPERATION_V8FLASH 3 // 3 s
168
169/* JLP 111700: we will include the 1 bit gap between the upper and lower 3 bits
170 * in the IBI address, to make the V8 code simpler.
171 * PCI ADDRESS FORMAT: 0x71C -> 0000 0111 0001 1100 (these are the six bits used)
172 * in general: 0000 0HHH 000L LL00
173 * IBI ADDRESS FORMAT: RHHH BLLL
174 *
175 * where R is the read(1)/write(0) bit, B is the busy bit
176 * and HHH and LLL are the two sets of three bits from the PCI address.
177 */
178#define B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(usPCI) (u8) (((usPCI >> 2) & 0x07) + ((usPCI >> 4) & 0x70))
179#define B2C2_FLEX_INTERNALADDR_TO_PCIOFFSET(ucAddr) (u16) (((ucAddr & 0x07) << 2) + ((ucAddr & 0x70) << 4))
180
181/*
182 * DKT 020228 - forget about this VENDOR_BUFFER_SIZE, read and write register
183 * deal with DWORD or 4 bytes, that should be should from now on
184 */
185static u32 b2c2_usb_read_dw(struct usb_b2c2_usb *b2c2, u16 wRegOffsPCI)
186{
187 u32 val;
188 u16 wAddress = B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(wRegOffsPCI) | 0x0080;
189 int len = usb_control_msg(b2c2->udev,
190 B2C2_USB_CTRL_PIPE_IN,
191 B2C2_USB_READ_REG,
192 RTYPE_READ_DW,
193 wAddress,
194 0,
195 &val,
196 sizeof(u32),
197 B2C2_WAIT_FOR_OPERATION_RDW * 1000);
198
199 if (len != sizeof(u32)) {
200 err("error while reading dword from %d (%d).",wAddress,wRegOffsPCI);
201 return -EIO;
202 } else
203 return val;
204}
205
206/*
207 * DKT 020228 - from now on, we don't support anything older than firm 1.00
208 * I eliminated the write register as a 2 trip of writing hi word and lo word
209 * and force this to write only 4 bytes at a time.
210 * NOTE: this should work with all the firmware from 1.00 and newer
211 */
212static int b2c2_usb_write_dw(struct usb_b2c2_usb *b2c2, u16 wRegOffsPCI, u32 val)
213{
214 u16 wAddress = B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(wRegOffsPCI);
215 int len = usb_control_msg(b2c2->udev,
216 B2C2_USB_CTRL_PIPE_OUT,
217 B2C2_USB_WRITE_REG,
218 RTYPE_WRITE_DW_1,
219 wAddress,
220 0,
221 &val,
222 sizeof(u32),
223 B2C2_WAIT_FOR_OPERATION_RDW * 1000);
224
225 if (len != sizeof(u32)) {
226 err("error while reading dword from %d (%d).",wAddress,wRegOffsPCI);
227 return -EIO;
228 } else
229 return 0;
230}
231
232/*
233 * DKT 010817 - add support for V8 memory read/write and flash update
234 */
235static int b2c2_usb_v8_memory_req(struct usb_b2c2_usb *b2c2,
236 b2c2_usb_request_t req, u8 page, u16 wAddress,
237 u16 buflen, u8 *pbBuffer)
238{
239 u8 dwRequestType;
240 u16 wIndex;
241 int nWaitTime,pipe,len;
242
243 wIndex = page << 8;
244
245 switch (req) {
246 case B2C2_USB_READ_V8_MEM:
247 nWaitTime = B2C2_WAIT_FOR_OPERATION_V8READ;
248 dwRequestType = (u8) RTYPE_READ_V8_MEMORY;
249 pipe = B2C2_USB_CTRL_PIPE_IN;
250 break;
251 case B2C2_USB_WRITE_V8_MEM:
252 wIndex |= pbBuffer[0];
253 nWaitTime = B2C2_WAIT_FOR_OPERATION_V8WRITE;
254 dwRequestType = (u8) RTYPE_WRITE_V8_MEMORY;
255 pipe = B2C2_USB_CTRL_PIPE_OUT;
256 break;
257 case B2C2_USB_FLASH_BLOCK:
258 nWaitTime = B2C2_WAIT_FOR_OPERATION_V8FLASH;
259 dwRequestType = (u8) RTYPE_WRITE_V8_FLASH;
260 pipe = B2C2_USB_CTRL_PIPE_OUT;
261 break;
262 default:
263 deb_info("unsupported request for v8_mem_req %x.\n",req);
264 return -EINVAL;
265 }
266 len = usb_control_msg(b2c2->udev,pipe,
267 req,
268 dwRequestType,
269 wAddress,
270 wIndex,
271 pbBuffer,
272 buflen,
273 nWaitTime * 1000);
274 return len == buflen ? 0 : -EIO;
275}
276
277static int b2c2_usb_i2c_req(struct usb_b2c2_usb *b2c2,
278 b2c2_usb_request_t req, b2c2_usb_i2c_function_t func,
279 u8 port, u8 chipaddr, u8 addr, u8 buflen, u8 *buf)
280{
281 u16 wValue, wIndex;
282 int nWaitTime,pipe,len;
283 u8 dwRequestType;
284
285 switch (func) {
286 case USB_FUNC_I2C_WRITE:
287 case USB_FUNC_I2C_MULTIWRITE:
288 case USB_FUNC_I2C_REPEATWRITE:
289 /* DKT 020208 - add this to support special case of DiSEqC */
290 case USB_FUNC_I2C_CHECKWRITE:
291 pipe = B2C2_USB_CTRL_PIPE_OUT;
292 nWaitTime = 2;
293 dwRequestType = (u8) RTYPE_GENERIC;
294 break;
295 case USB_FUNC_I2C_READ:
296 case USB_FUNC_I2C_REPEATREAD:
297 pipe = B2C2_USB_CTRL_PIPE_IN;
298 nWaitTime = 2;
299 dwRequestType = (u8) RTYPE_GENERIC;
300 break;
301 default:
302 deb_info("unsupported function for i2c_req %x\n",func);
303 return -EINVAL;
304 }
305 wValue = (func << 8 ) | port;
306 wIndex = (chipaddr << 8 ) | addr;
307
308 len = usb_control_msg(b2c2->udev,pipe,
309 req,
310 dwRequestType,
311 addr,
312 wIndex,
313 buf,
314 buflen,
315 nWaitTime * 1000);
316 return len == buflen ? 0 : -EIO;
317}
318
319int static b2c2_usb_utility_req(struct usb_b2c2_usb *b2c2, int set,
320 b2c2_usb_utility_function_t func, u8 extra, u16 wIndex,
321 u16 buflen, u8 *pvBuffer)
322{
323 u16 wValue;
324 int nWaitTime = 2,
325 pipe = set ? B2C2_USB_CTRL_PIPE_OUT : B2C2_USB_CTRL_PIPE_IN,
326 len;
327
328 wValue = (func << 8) | extra;
329
330 len = usb_control_msg(b2c2->udev,pipe,
331 B2C2_USB_UTILITY,
332 (u8) RTYPE_GENERIC,
333 wValue,
334 wIndex,
335 pvBuffer,
336 buflen,
337 nWaitTime * 1000);
338 return len == buflen ? 0 : -EIO;
339}
340
341
342
343static void b2c2_dumpfourreg(struct usb_b2c2_usb *b2c2, u16 offs)
344{
345 u32 r0,r1,r2,r3;
346 r0 = r1 = r2 = r3 = 0;
347 r0 = b2c2_usb_read_dw(b2c2,offs);
348 r1 = b2c2_usb_read_dw(b2c2,offs + 0x04);
349 r2 = b2c2_usb_read_dw(b2c2,offs + 0x08);
350 r3 = b2c2_usb_read_dw(b2c2,offs + 0x0c);
351 deb_ctrl("dump: offset: %03x, %08x, %08x, %08x, %08x\n",offs,r0,r1,r2,r3);
352}
353
354static void b2c2_urb_complete(struct urb *urb, struct pt_regs *ptregs)
355{
356 struct usb_b2c2_usb *b2c2 = urb->context;
357 deb_ts("urb completed, bufsize: %d\n",urb->transfer_buffer_length);
358
359// urb_submit_urb(urb,GFP_ATOMIC); enable for real action
360}
361
362static void b2c2_exit_usb(struct usb_b2c2_usb *b2c2)
363{
364 int i;
365 for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++)
366 if (b2c2->iso_urb[i] != NULL) { /* not sure about unlink_urb and iso-urbs TODO */
367 deb_info("unlinking/killing urb no. %d\n",i);
368#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,7)
369 usb_unlink_urb(b2c2->iso_urb[i]);
370#else
371 usb_kill_urb(b2c2->iso_urb[i]);
372#endif
373 usb_free_urb(b2c2->iso_urb[i]);
374 }
375
376 if (b2c2->iso_buffer != NULL)
377 pci_free_consistent(NULL,b2c2->buffer_size, b2c2->iso_buffer, b2c2->iso_dma_handle);
378
379}
380
381static int b2c2_init_usb(struct usb_b2c2_usb *b2c2)
382{
383 u16 frame_size = le16_to_cpu(b2c2->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize);
384 int bufsize = B2C2_USB_NUM_ISO_URB * B2C2_USB_FRAMES_PER_ISO * frame_size,i,j,ret;
385 int buffer_offset = 0;
386
387 deb_info("creating %d iso-urbs with %d frames each of %d bytes size = %d.\n",
388 B2C2_USB_NUM_ISO_URB, B2C2_USB_FRAMES_PER_ISO, frame_size,bufsize);
389
390 b2c2->iso_buffer = pci_alloc_consistent(NULL,bufsize,&b2c2->iso_dma_handle);
391 if (b2c2->iso_buffer == NULL)
392 return -ENOMEM;
393 memset(b2c2->iso_buffer, 0, bufsize);
394 b2c2->buffer_size = bufsize;
395
396 /* creating iso urbs */
397 for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++)
398 if (!(b2c2->iso_urb[i] = usb_alloc_urb(B2C2_USB_FRAMES_PER_ISO,GFP_ATOMIC))) {
399 ret = -ENOMEM;
400 goto urb_error;
401 }
402 /* initialising and submitting iso urbs */
403 for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++) {
404 int frame_offset = 0;
405 struct urb *urb = b2c2->iso_urb[i];
406 deb_info("initializing and submitting urb no. %d (buf_offset: %d).\n",i,buffer_offset);
407
408 urb->dev = b2c2->udev;
409 urb->context = b2c2;
410 urb->complete = b2c2_urb_complete;
411 urb->pipe = B2C2_USB_DATA_PIPE;
412 urb->transfer_flags = URB_ISO_ASAP;
413 urb->interval = 1;
414 urb->number_of_packets = B2C2_USB_FRAMES_PER_ISO;
415 urb->transfer_buffer_length = frame_size * B2C2_USB_FRAMES_PER_ISO;
416 urb->transfer_buffer = b2c2->iso_buffer + buffer_offset;
417
418 buffer_offset += frame_size * B2C2_USB_FRAMES_PER_ISO;
419 for (j = 0; j < B2C2_USB_FRAMES_PER_ISO; j++) {
420 deb_info("urb no: %d, frame: %d, frame_offset: %d\n",i,j,frame_offset);
421 urb->iso_frame_desc[j].offset = frame_offset;
422 urb->iso_frame_desc[j].length = frame_size;
423 frame_offset += frame_size;
424 }
425
426 if ((ret = usb_submit_urb(b2c2->iso_urb[i],GFP_ATOMIC))) {
427 err("submitting urb %d failed with %d.",i,ret);
428 goto urb_error;
429 }
430 deb_info("submitted urb no. %d.\n",i);
431 }
432
433 ret = 0;
434 goto success;
435urb_error:
436 b2c2_exit_usb(b2c2);
437success:
438 return ret;
439}
440
441static int b2c2_usb_probe(struct usb_interface *intf,
442 const struct usb_device_id *id)
443{
444 struct usb_device *udev = interface_to_usbdev(intf);
445 struct usb_b2c2_usb *b2c2 = NULL;
446 int ret;
447
448 b2c2 = kmalloc(sizeof(struct usb_b2c2_usb),GFP_KERNEL);
449 if (b2c2 == NULL) {
450 err("no memory");
451 return -ENOMEM;
452 }
453 b2c2->udev = udev;
454 b2c2->uintf = intf;
455
456 /* use the alternate setting with the larges buffer */
457 usb_set_interface(udev,0,1);
458
459 if ((ret = b2c2_init_usb(b2c2)))
460 goto usb_init_error;
461
462 usb_set_intfdata(intf,b2c2);
463
464 switch (udev->speed) {
465 case USB_SPEED_LOW:
466 err("cannot handle USB speed because it is to sLOW.");
467 break;
468 case USB_SPEED_FULL:
469 info("running at FULL speed.");
470 break;
471 case USB_SPEED_HIGH:
472 info("running at HIGH speed.");
473 break;
474 case USB_SPEED_UNKNOWN: /* fall through */
475 default:
476 err("cannot handle USB speed because it is unkown.");
477 break;
478 }
479
480 b2c2_dumpfourreg(b2c2,0x200);
481 b2c2_dumpfourreg(b2c2,0x300);
482 b2c2_dumpfourreg(b2c2,0x400);
483 b2c2_dumpfourreg(b2c2,0x700);
484
485
486 if (ret == 0)
487 info("%s successfully initialized and connected.",DRIVER_DESC);
488 else
489 info("%s error while loading driver (%d)",DRIVER_DESC,ret);
490
491 ret = 0;
492 goto success;
493
494usb_init_error:
495 kfree(b2c2);
496success:
497 return ret;
498}
499
500static void b2c2_usb_disconnect(struct usb_interface *intf)
501{
502 struct usb_b2c2_usb *b2c2 = usb_get_intfdata(intf);
503 usb_set_intfdata(intf,NULL);
504 if (b2c2 != NULL) {
505 b2c2_exit_usb(b2c2);
506 kfree(b2c2);
507 }
508 info("%s successfully deinitialized and disconnected.",DRIVER_DESC);
509
510}
511
512static struct usb_device_id b2c2_usb_table [] = {
513 { USB_DEVICE(0x0af7, 0x0101) }
514};
515
516/* usb specific object needed to register this driver with the usb subsystem */
517static struct usb_driver b2c2_usb_driver = {
518 .owner = THIS_MODULE,
519 .name = "dvb_b2c2_usb",
520 .probe = b2c2_usb_probe,
521 .disconnect = b2c2_usb_disconnect,
522 .id_table = b2c2_usb_table,
523};
524
525/* module stuff */
526static int __init b2c2_usb_init(void)
527{
528 int result;
529 if ((result = usb_register(&b2c2_usb_driver))) {
530 err("usb_register failed. Error number %d",result);
531 return result;
532 }
533
534 return 0;
535}
536
537static void __exit b2c2_usb_exit(void)
538{
539 /* deregister this driver from the USB subsystem */
540 usb_deregister(&b2c2_usb_driver);
541}
542
543module_init (b2c2_usb_init);
544module_exit (b2c2_usb_exit);
545
546MODULE_AUTHOR(DRIVER_AUTHOR);
547MODULE_DESCRIPTION(DRIVER_DESC);
548MODULE_LICENSE("GPL");
549MODULE_DEVICE_TABLE(usb, b2c2_usb_table);
diff --git a/drivers/media/dvb/b2c2/flexcop-common.h b/drivers/media/dvb/b2c2/flexcop-common.h
new file mode 100644
index 000000000000..773d158032df
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-common.h
@@ -0,0 +1,164 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-common.h - common header file for device-specific source files also.
5 *
6 * see flexcop.c for copyright information.
7 */
8#ifndef __FLEXCOP_COMMON_H__
9#define __FLEXCOP_COMMON_H__
10
11#include <linux/config.h>
12#include <linux/pci.h>
13
14#include "flexcop-reg.h"
15
16#include "dmxdev.h"
17#include "dvb_demux.h"
18#include "dvb_filter.h"
19#include "dvb_net.h"
20#include "dvb_frontend.h"
21
22#define FC_MAX_FEED 256
23
24#ifndef FC_LOG_PREFIX
25#warning please define a log prefix for your file, using a default one
26#define FC_LOG_PREFIX "b2c2-undef"
27#endif
28
29/* Steal from usb.h */
30#undef err
31#define err(format, arg...) printk(KERN_ERR FC_LOG_PREFIX ": " format "\n" , ## arg)
32#undef info
33#define info(format, arg...) printk(KERN_INFO FC_LOG_PREFIX ": " format "\n" , ## arg)
34#undef warn
35#define warn(format, arg...) printk(KERN_WARNING FC_LOG_PREFIX ": " format "\n" , ## arg)
36
37struct flexcop_dma {
38 struct pci_dev *pdev;
39
40 u8 *cpu_addr0;
41 dma_addr_t dma_addr0;
42 u8 *cpu_addr1;
43 dma_addr_t dma_addr1;
44 u32 size; /* size of each address in bytes */
45};
46
47/* Control structure for data definitions that are common to
48 * the B2C2-based PCI and USB devices.
49 */
50struct flexcop_device {
51 /* general */
52 struct device *dev; /* for firmware_class */
53
54#define FC_STATE_DVB_INIT 0x01
55#define FC_STATE_I2C_INIT 0x02
56#define FC_STATE_FE_INIT 0x04
57 int init_state;
58
59 /* device information */
60 int has_32_hw_pid_filter;
61 flexcop_revision_t rev;
62 flexcop_device_type_t dev_type;
63 flexcop_bus_t bus_type;
64
65 /* dvb stuff */
66 struct dvb_adapter dvb_adapter;
67 struct dvb_frontend *fe;
68 struct dvb_net dvbnet;
69 struct dvb_demux demux;
70 struct dmxdev dmxdev;
71 struct dmx_frontend hw_frontend;
72 struct dmx_frontend mem_frontend;
73 int (*fe_sleep) (struct dvb_frontend *);
74
75 struct i2c_adapter i2c_adap;
76 struct semaphore i2c_sem;
77
78 struct module *owner;
79
80 /* options and status */
81 int extra_feedcount;
82 int feedcount;
83 int pid_filtering;
84 int fullts_streaming_state;
85
86 /* bus specific callbacks */
87 flexcop_ibi_value (*read_ibi_reg) (struct flexcop_device *, flexcop_ibi_register);
88 int (*write_ibi_reg) (struct flexcop_device *, flexcop_ibi_register, flexcop_ibi_value);
89
90
91 int (*i2c_request) (struct flexcop_device*, flexcop_access_op_t, flexcop_i2c_port_t, u8 chipaddr, u8 addr, u8 *buf, u16 len);
92 int (*stream_control) (struct flexcop_device*, int);
93
94 int (*get_mac_addr) (struct flexcop_device *fc, int extended);
95
96 void *bus_specific;
97};
98
99/* exported prototypes */
100
101/* from flexcop.c */
102void flexcop_pass_dmx_data(struct flexcop_device *fc, u8 *buf, u32 len);
103void flexcop_pass_dmx_packets(struct flexcop_device *fc, u8 *buf, u32 no);
104
105struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len);
106void flexcop_device_kfree(struct flexcop_device*);
107
108int flexcop_device_initialize(struct flexcop_device*);
109void flexcop_device_exit(struct flexcop_device *fc);
110
111/* from flexcop-dma.c */
112int flexcop_dma_allocate(struct pci_dev *pdev, struct flexcop_dma *dma, u32 size);
113void flexcop_dma_free(struct flexcop_dma *dma);
114
115int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
116int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
117int flexcop_dma_control_packet_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
118int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx,flexcop_dma_addr_index_t index);
119int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles);
120int flexcop_dma_config_packet_count(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 packets);
121
122/* from flexcop-eeprom.c */
123/* the PCI part uses this call to get the MAC address, the USB part has its own */
124int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended);
125
126/* from flexcop-i2c.c */
127/* the PCI part uses this a i2c_request callback, whereas the usb part has its own
128 * one. We have it in flexcop-i2c.c, because it is going via the actual
129 * I2C-channel of the flexcop.
130 */
131int flexcop_i2c_request(struct flexcop_device*, flexcop_access_op_t,
132 flexcop_i2c_port_t, u8 chipaddr, u8 addr, u8 *buf, u16 len);
133
134/* from flexcop-sram.c */
135int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, flexcop_sram_dest_target_t target);
136void flexcop_wan_set_speed(struct flexcop_device *fc, flexcop_wan_speed_t s);
137void flexcop_sram_ctrl(struct flexcop_device *fc, int usb_wan, int sramdma, int maximumfill);
138
139/* global prototypes for the flexcop-chip */
140/* from flexcop-fe-tuner.c */
141int flexcop_frontend_init(struct flexcop_device *card);
142void flexcop_frontend_exit(struct flexcop_device *fc);
143
144/* from flexcop-i2c.c */
145int flexcop_i2c_init(struct flexcop_device *fc);
146void flexcop_i2c_exit(struct flexcop_device *fc);
147
148/* from flexcop-sram.c */
149int flexcop_sram_init(struct flexcop_device *fc);
150
151/* from flexcop-misc.c */
152void flexcop_determine_revision(struct flexcop_device *fc);
153void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const char *suffix);
154
155/* from flexcop-hw-filter.c */
156int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *dvbdmxfeed, int onoff);
157void flexcop_hw_filter_init(struct flexcop_device *fc);
158
159void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff);
160
161void flexcop_set_mac_filter(struct flexcop_device *fc, u8 mac[6]);
162void flexcop_mac_filter_ctrl(struct flexcop_device *fc, int onoff);
163
164#endif
diff --git a/drivers/media/dvb/b2c2/flexcop-dma.c b/drivers/media/dvb/b2c2/flexcop-dma.c
new file mode 100644
index 000000000000..8d2706075360
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-dma.c
@@ -0,0 +1,149 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-dma.c - methods for configuring and controlling the DMA of the FlexCop.
5 *
6 * see flexcop.c for copyright information.
7 */
8#include "flexcop.h"
9
10int flexcop_dma_allocate(struct pci_dev *pdev, struct flexcop_dma *dma, u32 size)
11{
12 u8 *tcpu;
13 dma_addr_t tdma;
14
15 if (size % 2) {
16 err("dma buffersize has to be even.");
17 return -EINVAL;
18 }
19
20 if ((tcpu = pci_alloc_consistent(pdev, size, &tdma)) != NULL) {
21 dma->pdev = pdev;
22 dma->cpu_addr0 = tcpu;
23 dma->dma_addr0 = tdma;
24 dma->cpu_addr1 = tcpu + size/2;
25 dma->dma_addr1 = tdma + size/2;
26 dma->size = size/2;
27 return 0;
28 }
29 return -ENOMEM;
30}
31EXPORT_SYMBOL(flexcop_dma_allocate);
32
33void flexcop_dma_free(struct flexcop_dma *dma)
34{
35 pci_free_consistent(dma->pdev, dma->size*2,dma->cpu_addr0, dma->dma_addr0);
36 memset(dma,0,sizeof(struct flexcop_dma));
37}
38EXPORT_SYMBOL(flexcop_dma_free);
39
40int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff)
41{
42 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
43
44 if (no & FC_DMA_1)
45 v.ctrl_208.DMA1_Timer_Enable_sig = onoff;
46
47 if (no & FC_DMA_2)
48 v.ctrl_208.DMA2_Timer_Enable_sig = onoff;
49
50 fc->write_ibi_reg(fc,ctrl_208,v);
51 return 0;
52}
53EXPORT_SYMBOL(flexcop_dma_control_timer_irq);
54
55int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff)
56{
57 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
58
59 if (no & FC_DMA_1)
60 v.ctrl_208.DMA1_IRQ_Enable_sig = onoff;
61
62 if (no & FC_DMA_2)
63 v.ctrl_208.DMA2_IRQ_Enable_sig = onoff;
64
65 fc->write_ibi_reg(fc,ctrl_208,v);
66 return 0;
67}
68EXPORT_SYMBOL(flexcop_dma_control_size_irq);
69
70int flexcop_dma_control_packet_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff)
71{
72 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
73
74 if (no & FC_DMA_1)
75 v.ctrl_208.DMA1_Size_IRQ_Enable_sig = onoff;
76
77 if (no & FC_DMA_2)
78 v.ctrl_208.DMA2_Size_IRQ_Enable_sig = onoff;
79
80 fc->write_ibi_reg(fc,ctrl_208,v);
81 return 0;
82}
83EXPORT_SYMBOL(flexcop_dma_control_packet_irq);
84
85int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx,flexcop_dma_addr_index_t index)
86{
87
88 flexcop_ibi_value v0x0,v0x4,v0xc;
89 v0x0.raw = v0x4.raw = v0xc.raw = 0;
90
91 v0x0.dma_0x0.dma_address0 = dma->dma_addr0 >> 2;
92 v0xc.dma_0xc.dma_address1 = dma->dma_addr1 >> 2;
93 v0x4.dma_0x4_write.dma_addr_size = dma->size / 4;
94
95 if (index & FC_DMA_SUBADDR_0)
96 v0x0.dma_0x0.dma_0start = 1;
97
98 if (index & FC_DMA_SUBADDR_1)
99 v0xc.dma_0xc.dma_1start = 1;
100
101 if (dma_idx & FC_DMA_1) {
102 fc->write_ibi_reg(fc,dma1_000,v0x0);
103 fc->write_ibi_reg(fc,dma1_004,v0x4);
104 fc->write_ibi_reg(fc,dma1_00c,v0xc);
105 } else { /* (dma_idx & FC_DMA_2) */
106 fc->write_ibi_reg(fc,dma2_010,v0x0);
107 fc->write_ibi_reg(fc,dma2_014,v0x4);
108 fc->write_ibi_reg(fc,dma2_01c,v0xc);
109 }
110
111 return 0;
112}
113EXPORT_SYMBOL(flexcop_dma_config);
114
115static int flexcop_dma_remap(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, int onoff)
116{
117 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_00c : dma2_01c;
118 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
119 v.dma_0xc.remap_enable = onoff;
120 fc->write_ibi_reg(fc,r,v);
121 return 0;
122}
123
124/* 1 cycles = 1.97 msec */
125int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles)
126{
127 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014;
128 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
129
130 flexcop_dma_remap(fc,dma_idx,0);
131
132 v.dma_0x4_write.dmatimer = cycles >> 1;
133 fc->write_ibi_reg(fc,r,v);
134 return 0;
135}
136EXPORT_SYMBOL(flexcop_dma_config_timer);
137
138int flexcop_dma_config_packet_count(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 packets)
139{
140 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014;
141 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
142
143 flexcop_dma_remap(fc,dma_idx,1);
144
145 v.dma_0x4_remap.DMA_maxpackets = packets;
146 fc->write_ibi_reg(fc,r,v);
147 return 0;
148}
149EXPORT_SYMBOL(flexcop_dma_config_packet_count);
diff --git a/drivers/media/dvb/b2c2/flexcop-eeprom.c b/drivers/media/dvb/b2c2/flexcop-eeprom.c
new file mode 100644
index 000000000000..bbcf070a178d
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-eeprom.c
@@ -0,0 +1,153 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-eeprom.c - eeprom access methods (currently only MAC address reading is used)
5 *
6 * see flexcop.c for copyright information.
7 */
8#include "flexcop.h"
9
10#if 0
11/*EEPROM (Skystar2 has one "24LC08B" chip on board) */
12static int eeprom_write(struct adapter *adapter, u16 addr, u8 *buf, u16 len)
13{
14 return flex_i2c_write(adapter, 0x20000000, 0x50, addr, buf, len);
15}
16
17static int eeprom_lrc_write(struct adapter *adapter, u32 addr, u32 len, u8 *wbuf, u8 *rbuf, int retries)
18{
19 int i;
20
21 for (i = 0; i < retries; i++) {
22 if (eeprom_write(adapter, addr, wbuf, len) == len) {
23 if (eeprom_lrc_read(adapter, addr, len, rbuf, retries) == 1)
24 return 1;
25 }
26 }
27
28 return 0;
29}
30
31/* These functions could be used to unlock SkyStar2 cards. */
32
33static int eeprom_writeKey(struct adapter *adapter, u8 *key, u32 len)
34{
35 u8 rbuf[20];
36 u8 wbuf[20];
37
38 if (len != 16)
39 return 0;
40
41 memcpy(wbuf, key, len);
42
43 wbuf[16] = 0;
44 wbuf[17] = 0;
45 wbuf[18] = 0;
46 wbuf[19] = calc_lrc(wbuf, 19);
47
48 return eeprom_lrc_write(adapter, 0x3e4, 20, wbuf, rbuf, 4);
49}
50
51static int eeprom_readKey(struct adapter *adapter, u8 *key, u32 len)
52{
53 u8 buf[20];
54
55 if (len != 16)
56 return 0;
57
58 if (eeprom_lrc_read(adapter, 0x3e4, 20, buf, 4) == 0)
59 return 0;
60
61 memcpy(key, buf, len);
62
63 return 1;
64}
65
66static char eeprom_set_mac_addr(struct adapter *adapter, char type, u8 *mac)
67{
68 u8 tmp[8];
69
70 if (type != 0) {
71 tmp[0] = mac[0];
72 tmp[1] = mac[1];
73 tmp[2] = mac[2];
74 tmp[3] = mac[5];
75 tmp[4] = mac[6];
76 tmp[5] = mac[7];
77
78 } else {
79
80 tmp[0] = mac[0];
81 tmp[1] = mac[1];
82 tmp[2] = mac[2];
83 tmp[3] = mac[3];
84 tmp[4] = mac[4];
85 tmp[5] = mac[5];
86 }
87
88 tmp[6] = 0;
89 tmp[7] = calc_lrc(tmp, 7);
90
91 if (eeprom_write(adapter, 0x3f8, tmp, 8) == 8)
92 return 1;
93
94 return 0;
95}
96
97static int flexcop_eeprom_read(struct flexcop_device *fc, u16 addr, u8 *buf, u16 len)
98{
99 return fc->i2c_request(fc,FC_READ,FC_I2C_PORT_EEPROM,0x50,addr,buf,len);
100}
101
102#endif
103
104static u8 calc_lrc(u8 *buf, int len)
105{
106 int i;
107 u8 sum = 0;
108 for (i = 0; i < len; i++)
109 sum = sum ^ buf[i];
110 return sum;
111}
112
113static int flexcop_eeprom_request(struct flexcop_device *fc, flexcop_access_op_t op, u16 addr, u8 *buf, u16 len, int retries)
114{
115 int i,ret = 0;
116 u8 chipaddr = 0x50 | ((addr >> 8) & 3);
117 for (i = 0; i < retries; i++)
118 if ((ret = fc->i2c_request(fc,op,FC_I2C_PORT_EEPROM,chipaddr,addr & 0xff,buf,len)) == 0)
119 break;
120 return ret;
121}
122
123static int flexcop_eeprom_lrc_read(struct flexcop_device *fc, u16 addr, u8 *buf, u16 len, int retries)
124{
125 int ret = flexcop_eeprom_request(fc,FC_READ,addr,buf,len,retries);
126 if (ret == 0)
127 if (calc_lrc(buf, len - 1) != buf[len - 1])
128 ret = -EINVAL;
129 return ret;
130}
131
132/* JJ's comment about extended == 1: it is not presently used anywhere but was
133 * added to the low-level functions for possible support of EUI64
134 */
135int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended)
136{
137 u8 buf[8];
138 int ret = 0;
139
140 if ((ret = flexcop_eeprom_lrc_read(fc,0x3f8,buf,8,4)) == 0) {
141 if (extended != 0) {
142 err("TODO: extended (EUI64) MAC addresses aren't completely supported yet");
143 ret = -EINVAL;
144/* memcpy(fc->dvb_adapter.proposed_mac,buf,3);
145 mac[3] = 0xfe;
146 mac[4] = 0xff;
147 memcpy(&fc->dvb_adapter.proposed_mac[3],&buf[5],3); */
148 } else
149 memcpy(fc->dvb_adapter.proposed_mac,buf,6);
150 }
151 return ret;
152}
153EXPORT_SYMBOL(flexcop_eeprom_check_mac_addr);
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
new file mode 100644
index 000000000000..71be400e9aeb
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -0,0 +1,403 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-fe-tuner.c - methods for attaching a frontend and controlling DiSEqC.
5 *
6 * see flexcop.c for copyright information.
7 */
8#include "flexcop.h"
9
10#include "stv0299.h"
11#include "mt352.h"
12#include "nxt2002.h"
13#include "stv0297.h"
14#include "mt312.h"
15
16/* lnb control */
17
18static int flexcop_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
19{
20 struct flexcop_device *fc = fe->dvb->priv;
21 flexcop_ibi_value v;
22 deb_tuner("polarity/voltage = %u\n", voltage);
23
24 v = fc->read_ibi_reg(fc, misc_204);
25 switch (voltage) {
26 case SEC_VOLTAGE_OFF:
27 v.misc_204.ACPI1_sig = 1;
28 break;
29 case SEC_VOLTAGE_13:
30 v.misc_204.ACPI1_sig = 0;
31 v.misc_204.LNB_L_H_sig = 0;
32 break;
33 case SEC_VOLTAGE_18:
34 v.misc_204.ACPI1_sig = 0;
35 v.misc_204.LNB_L_H_sig = 1;
36 break;
37 default:
38 err("unknown SEC_VOLTAGE value");
39 return -EINVAL;
40 }
41 return fc->write_ibi_reg(fc, misc_204, v);
42}
43
44static int flexcop_sleep(struct dvb_frontend* fe)
45{
46 struct flexcop_device *fc = fe->dvb->priv;
47/* flexcop_ibi_value v = fc->read_ibi_reg(fc,misc_204); */
48
49 if (fc->fe_sleep)
50 return fc->fe_sleep(fe);
51
52/* v.misc_204.ACPI3_sig = 1;
53 fc->write_ibi_reg(fc,misc_204,v);*/
54
55 return 0;
56}
57
58static int flexcop_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
59{
60 /* u16 wz_half_period_for_45_mhz[] = { 0x01ff, 0x0154, 0x00ff, 0x00cc }; */
61 struct flexcop_device *fc = fe->dvb->priv;
62 flexcop_ibi_value v;
63 u16 ax;
64 v.raw = 0;
65
66 deb_tuner("tone = %u\n",tone);
67
68 switch (tone) {
69 case SEC_TONE_ON:
70 ax = 0x01ff;
71 break;
72 case SEC_TONE_OFF:
73 ax = 0;
74 break;
75 default:
76 err("unknown SEC_TONE value");
77 return -EINVAL;
78 }
79
80 v.lnb_switch_freq_200.LNB_CTLPrescaler_sig = 1; /* divide by 2 */
81
82 v.lnb_switch_freq_200.LNB_CTLHighCount_sig = ax;
83 v.lnb_switch_freq_200.LNB_CTLLowCount_sig = ax == 0 ? 0x1ff : ax;
84
85 return fc->write_ibi_reg(fc,lnb_switch_freq_200,v);
86}
87
88static void flexcop_diseqc_send_bit(struct dvb_frontend* fe, int data)
89{
90 flexcop_set_tone(fe, SEC_TONE_ON);
91 udelay(data ? 500 : 1000);
92 flexcop_set_tone(fe, SEC_TONE_OFF);
93 udelay(data ? 1000 : 500);
94}
95
96static void flexcop_diseqc_send_byte(struct dvb_frontend* fe, int data)
97{
98 int i, par = 1, d;
99
100 for (i = 7; i >= 0; i--) {
101 d = (data >> i) & 1;
102 par ^= d;
103 flexcop_diseqc_send_bit(fe, d);
104 }
105
106 flexcop_diseqc_send_bit(fe, par);
107}
108
109static int flexcop_send_diseqc_msg(struct dvb_frontend* fe, int len, u8 *msg, unsigned long burst)
110{
111 int i;
112
113 flexcop_set_tone(fe, SEC_TONE_OFF);
114 mdelay(16);
115
116 for (i = 0; i < len; i++)
117 flexcop_diseqc_send_byte(fe,msg[i]);
118
119 mdelay(16);
120
121 if (burst != -1) {
122 if (burst)
123 flexcop_diseqc_send_byte(fe, 0xff);
124 else {
125 flexcop_set_tone(fe, SEC_TONE_ON);
126 udelay(12500);
127 flexcop_set_tone(fe, SEC_TONE_OFF);
128 }
129 msleep(20);
130 }
131 return 0;
132}
133
134static int flexcop_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
135{
136 return flexcop_send_diseqc_msg(fe, cmd->msg_len, cmd->msg, 0);
137}
138
139static int flexcop_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
140{
141 return flexcop_send_diseqc_msg(fe, 0, NULL, minicmd);
142}
143
144/* dvb-s stv0299 */
145static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
146{
147 u8 aclk = 0;
148 u8 bclk = 0;
149
150 if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
151 else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
152 else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
153 else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
154 else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
155 else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
156
157 stv0299_writereg (fe, 0x13, aclk);
158 stv0299_writereg (fe, 0x14, bclk);
159 stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
160 stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff);
161 stv0299_writereg (fe, 0x21, (ratio ) & 0xf0);
162
163 return 0;
164}
165
166static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
167{
168 u8 buf[4];
169 u32 div;
170 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
171 struct flexcop_device *fc = fe->dvb->priv;
172
173 div = params->frequency / 125;
174
175 buf[0] = (div >> 8) & 0x7f;
176 buf[1] = div & 0xff;
177 buf[2] = 0x84; /* 0xC4 */
178 buf[3] = 0x08;
179
180 if (params->frequency < 1500000) buf[3] |= 0x10;
181
182 if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1)
183 return -EIO;
184 return 0;
185}
186
187static u8 samsung_tbmu24112_inittab[] = {
188 0x01, 0x15,
189 0x02, 0x30,
190 0x03, 0x00,
191 0x04, 0x7D,
192 0x05, 0x35,
193 0x06, 0x02,
194 0x07, 0x00,
195 0x08, 0xC3,
196 0x0C, 0x00,
197 0x0D, 0x81,
198 0x0E, 0x23,
199 0x0F, 0x12,
200 0x10, 0x7E,
201 0x11, 0x84,
202 0x12, 0xB9,
203 0x13, 0x88,
204 0x14, 0x89,
205 0x15, 0xC9,
206 0x16, 0x00,
207 0x17, 0x5C,
208 0x18, 0x00,
209 0x19, 0x00,
210 0x1A, 0x00,
211 0x1C, 0x00,
212 0x1D, 0x00,
213 0x1E, 0x00,
214 0x1F, 0x3A,
215 0x20, 0x2E,
216 0x21, 0x80,
217 0x22, 0xFF,
218 0x23, 0xC1,
219 0x28, 0x00,
220 0x29, 0x1E,
221 0x2A, 0x14,
222 0x2B, 0x0F,
223 0x2C, 0x09,
224 0x2D, 0x05,
225 0x31, 0x1F,
226 0x32, 0x19,
227 0x33, 0xFE,
228 0x34, 0x93,
229 0xff, 0xff,
230};
231
232static struct stv0299_config samsung_tbmu24112_config = {
233 .demod_address = 0x68,
234 .inittab = samsung_tbmu24112_inittab,
235 .mclk = 88000000UL,
236 .invert = 0,
237 .enhanced_tuning = 0,
238 .skip_reinit = 0,
239 .lock_output = STV0229_LOCKOUTPUT_LK,
240 .volt13_op0_op1 = STV0299_VOLT13_OP1,
241 .min_delay_ms = 100,
242 .set_symbol_rate = samsung_tbmu24112_set_symbol_rate,
243 .pll_set = samsung_tbmu24112_pll_set,
244};
245
246/* dvb-t mt352 */
247static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
248{
249 static u8 mt352_clock_config [] = { 0x89, 0x18, 0x2d };
250 static u8 mt352_reset [] = { 0x50, 0x80 };
251 static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
252 static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0xa1 };
253 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
254
255 mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
256 udelay(2000);
257 mt352_write(fe, mt352_reset, sizeof(mt352_reset));
258 mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
259
260 mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
261 mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
262
263 return 0;
264}
265
266static int samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
267{
268 u32 div;
269 unsigned char bs = 0;
270
271 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
272 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
273
274 if (params->frequency >= 48000000 && params->frequency <= 154000000) bs = 0x09;
275 if (params->frequency >= 161000000 && params->frequency <= 439000000) bs = 0x0a;
276 if (params->frequency >= 447000000 && params->frequency <= 863000000) bs = 0x08;
277
278 pllbuf[0] = 0xc2; /* Note: non-linux standard PLL i2c address */
279 pllbuf[1] = div >> 8;
280 pllbuf[2] = div & 0xff;
281 pllbuf[3] = 0xcc;
282 pllbuf[4] = bs;
283
284 return 0;
285}
286
287static struct mt352_config samsung_tdtc9251dh0_config = {
288
289 .demod_address = 0x0f,
290 .demod_init = samsung_tdtc9251dh0_demod_init,
291 .pll_set = samsung_tdtc9251dh0_pll_set,
292};
293
294static int nxt2002_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
295{
296 struct flexcop_device *fc = fe->dvb->priv;
297 return request_firmware(fw, name, fc->dev);
298}
299
300static struct nxt2002_config samsung_tbmv_config = {
301 .demod_address = 0x0a,
302 .request_firmware = nxt2002_request_firmware,
303};
304
305static int skystar23_samsung_tbdu18132_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
306{
307 u8 buf[4];
308 u32 div;
309 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
310 struct flexcop_device *fc = fe->dvb->priv;
311
312 div = (params->frequency + (125/2)) / 125;
313
314 buf[0] = (div >> 8) & 0x7f;
315 buf[1] = (div >> 0) & 0xff;
316 buf[2] = 0x84 | ((div >> 10) & 0x60);
317 buf[3] = 0x80;
318
319 if (params->frequency < 1550000)
320 buf[3] |= 0x02;
321
322 if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1)
323 return -EIO;
324 return 0;
325}
326
327static struct mt312_config skystar23_samsung_tbdu18132_config = {
328
329 .demod_address = 0x0e,
330 .pll_set = skystar23_samsung_tbdu18132_pll_set,
331};
332
333static struct stv0297_config alps_tdee4_stv0297_config = {
334 .demod_address = 0x1c,
335// .invert = 1,
336// .pll_set = alps_tdee4_stv0297_pll_set,
337};
338
339/* try to figure out the frontend, each card/box can have on of the following list */
340int flexcop_frontend_init(struct flexcop_device *fc)
341{
342 /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */
343 if ((fc->fe = stv0299_attach(&samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) {
344 fc->fe->ops->set_voltage = flexcop_set_voltage;
345
346 fc->fe_sleep = fc->fe->ops->sleep;
347 fc->fe->ops->sleep = flexcop_sleep;
348
349 fc->dev_type = FC_SKY;
350 info("found the stv0299 at i2c address: 0x%02x",samsung_tbmu24112_config.demod_address);
351 } else
352 /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */
353 if ((fc->fe = mt352_attach(&samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) {
354 fc->dev_type = FC_AIR_DVB;
355 info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address);
356 } else
357 /* try the air atsc (nxt2002) */
358 if ((fc->fe = nxt2002_attach(&samsung_tbmv_config, &fc->i2c_adap)) != NULL) {
359 fc->dev_type = FC_AIR_ATSC;
360 info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address);
361 } else
362 /* try the cable dvb (stv0297) */
363 if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap, 0xf8)) != NULL) {
364 fc->dev_type = FC_CABLE;
365 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address);
366 } else
367 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
368 if ((fc->fe = vp310_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
369 fc->fe->ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
370 fc->fe->ops->diseqc_send_burst = flexcop_diseqc_send_burst;
371 fc->fe->ops->set_tone = flexcop_set_tone;
372 fc->fe->ops->set_voltage = flexcop_set_voltage;
373
374 fc->fe_sleep = fc->fe->ops->sleep;
375 fc->fe->ops->sleep = flexcop_sleep;
376
377 fc->dev_type = FC_SKY_OLD;
378 info("found the vp310 (aka mt312) at i2c address: 0x%02x",skystar23_samsung_tbdu18132_config.demod_address);
379 }
380
381 if (fc->fe == NULL) {
382 err("no frontend driver found for this B2C2/FlexCop adapter");
383 return -ENODEV;
384 } else {
385 if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) {
386 err("frontend registration failed!");
387 if (fc->fe->ops->release != NULL)
388 fc->fe->ops->release(fc->fe);
389 fc->fe = NULL;
390 return -EINVAL;
391 }
392 }
393 fc->init_state |= FC_STATE_FE_INIT;
394 return 0;
395}
396
397void flexcop_frontend_exit(struct flexcop_device *fc)
398{
399 if (fc->init_state & FC_STATE_FE_INIT)
400 dvb_unregister_frontend(fc->fe);
401
402 fc->init_state &= ~FC_STATE_FE_INIT;
403}
diff --git a/drivers/media/dvb/b2c2/flexcop-hw-filter.c b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
new file mode 100644
index 000000000000..2baf43d3ce8f
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
@@ -0,0 +1,204 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-hw-filter.c - pid and mac address filtering and corresponding control functions.
5 *
6 * see flexcop.c for copyright information.
7 */
8#include "flexcop.h"
9
10static void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff)
11{
12 flexcop_set_ibi_value(ctrl_208,Rcv_Data_sig,onoff);
13}
14
15void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff)
16{
17 flexcop_set_ibi_value(ctrl_208,SMC_Enable_sig,onoff);
18}
19
20void flexcop_null_filter_ctrl(struct flexcop_device *fc, int onoff)
21{
22 flexcop_set_ibi_value(ctrl_208,Null_filter_sig,onoff);
23}
24
25void flexcop_set_mac_filter(struct flexcop_device *fc, u8 mac[6])
26{
27 flexcop_ibi_value v418,v41c;
28 v41c = fc->read_ibi_reg(fc,mac_address_41c);
29
30 v418.mac_address_418.MAC1 = mac[0];
31 v418.mac_address_418.MAC2 = mac[1];
32 v418.mac_address_418.MAC3 = mac[2];
33 v418.mac_address_418.MAC6 = mac[3];
34 v41c.mac_address_41c.MAC7 = mac[4];
35 v41c.mac_address_41c.MAC8 = mac[5];
36
37 fc->write_ibi_reg(fc,mac_address_418,v418);
38 fc->write_ibi_reg(fc,mac_address_41c,v41c);
39}
40
41void flexcop_mac_filter_ctrl(struct flexcop_device *fc, int onoff)
42{
43 flexcop_set_ibi_value(ctrl_208,MAC_filter_Mode_sig,onoff);
44}
45
46static void flexcop_pid_group_filter(struct flexcop_device *fc, u16 pid, u16 mask)
47{
48 /* index_reg_310.extra_index_reg need to 0 or 7 to work */
49 flexcop_ibi_value v30c;
50 v30c.pid_filter_30c_ext_ind_0_7.Group_PID = pid;
51 v30c.pid_filter_30c_ext_ind_0_7.Group_mask = mask;
52 fc->write_ibi_reg(fc,pid_filter_30c,v30c);
53}
54
55static void flexcop_pid_group_filter_ctrl(struct flexcop_device *fc, int onoff)
56{
57 flexcop_set_ibi_value(ctrl_208,Mask_filter_sig,onoff);
58}
59
60/* this fancy define reduces the code size of the quite similar PID controlling of
61 * the first 6 PIDs
62 */
63
64#define pid_ctrl(vregname,field,enablefield,trans_field,transval) \
65 flexcop_ibi_value vpid = fc->read_ibi_reg(fc, vregname), \
66 v208 = fc->read_ibi_reg(fc, ctrl_208); \
67\
68 vpid.vregname.field = onoff ? pid : 0x1fff; \
69 vpid.vregname.trans_field = transval; \
70 v208.ctrl_208.enablefield = onoff; \
71\
72 fc->write_ibi_reg(fc,vregname,vpid); \
73 fc->write_ibi_reg(fc,ctrl_208,v208);
74
75static void flexcop_pid_Stream1_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
76{
77 pid_ctrl(pid_filter_300,Stream1_PID,Stream1_filter_sig,Stream1_trans,0);
78}
79
80static void flexcop_pid_Stream2_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
81{
82 pid_ctrl(pid_filter_300,Stream2_PID,Stream2_filter_sig,Stream2_trans,0);
83}
84
85static void flexcop_pid_PCR_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
86{
87 pid_ctrl(pid_filter_304,PCR_PID,PCR_filter_sig,PCR_trans,0);
88}
89
90static void flexcop_pid_PMT_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
91{
92 pid_ctrl(pid_filter_304,PMT_PID,PMT_filter_sig,PMT_trans,0);
93}
94
95static void flexcop_pid_EMM_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
96{
97 pid_ctrl(pid_filter_308,EMM_PID,EMM_filter_sig,EMM_trans,0);
98}
99
100static void flexcop_pid_ECM_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
101{
102 pid_ctrl(pid_filter_308,ECM_PID,ECM_filter_sig,ECM_trans,0);
103}
104
105static void flexcop_pid_control(struct flexcop_device *fc, int index, u16 pid,int onoff)
106{
107 if (pid == 0x2000)
108 return;
109
110 deb_ts("setting pid: %5d %04x at index %d '%s'\n",pid,pid,index,onoff ? "on" : "off");
111
112 /* We could use bit magic here to reduce source code size.
113 * I decided against it, but to use the real register names */
114 switch (index) {
115 case 0: flexcop_pid_Stream1_PID_ctrl(fc,pid,onoff); break;
116 case 1: flexcop_pid_Stream2_PID_ctrl(fc,pid,onoff); break;
117 case 2: flexcop_pid_PCR_PID_ctrl(fc,pid,onoff); break;
118 case 3: flexcop_pid_PMT_PID_ctrl(fc,pid,onoff); break;
119 case 4: flexcop_pid_EMM_PID_ctrl(fc,pid,onoff); break;
120 case 5: flexcop_pid_ECM_PID_ctrl(fc,pid,onoff); break;
121 default:
122 if (fc->has_32_hw_pid_filter && index < 38) {
123 flexcop_ibi_value vpid,vid;
124
125 /* set the index */
126 vid = fc->read_ibi_reg(fc,index_reg_310);
127 vid.index_reg_310.index_reg = index - 6;
128 fc->write_ibi_reg(fc,index_reg_310, vid);
129
130 vpid = fc->read_ibi_reg(fc,pid_n_reg_314);
131 vpid.pid_n_reg_314.PID = onoff ? pid : 0x1fff;
132 vpid.pid_n_reg_314.PID_enable_bit = onoff;
133 fc->write_ibi_reg(fc,pid_n_reg_314, vpid);
134 }
135 break;
136 }
137}
138
139static int flexcop_toggle_fullts_streaming(struct flexcop_device *fc,int onoff)
140{
141 if (fc->fullts_streaming_state != onoff) {
142 deb_ts("%s full TS transfer\n",onoff ? "enabling" : "disabling");
143 flexcop_pid_group_filter(fc, 0, 0x1fe0 * (!onoff));
144 flexcop_pid_group_filter_ctrl(fc,onoff);
145 fc->fullts_streaming_state = onoff;
146 }
147 return 0;
148}
149
150int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *dvbdmxfeed, int onoff)
151{
152 int max_pid_filter = 6 + fc->has_32_hw_pid_filter*32;
153
154 fc->feedcount += onoff ? 1 : -1;
155 if (dvbdmxfeed->index >= max_pid_filter)
156 fc->extra_feedcount += onoff ? 1 : -1;
157
158 /* toggle complete-TS-streaming when:
159 * - pid_filtering is not enabled and it is the first or last feed requested
160 * - pid_filtering is enabled,
161 * - but the number of requested feeds is exceeded
162 * - or the requested pid is 0x2000 */
163
164 if (!fc->pid_filtering && fc->feedcount == onoff)
165 flexcop_toggle_fullts_streaming(fc,onoff);
166
167 if (fc->pid_filtering) {
168 flexcop_pid_control(fc,dvbdmxfeed->index,dvbdmxfeed->pid,onoff);
169
170 if (fc->extra_feedcount > 0)
171 flexcop_toggle_fullts_streaming(fc,1);
172 else if (dvbdmxfeed->pid == 0x2000)
173 flexcop_toggle_fullts_streaming(fc,onoff);
174 else
175 flexcop_toggle_fullts_streaming(fc,0);
176 }
177
178 /* if it was the first or last feed request change the stream-status */
179 if (fc->feedcount == onoff) {
180 flexcop_rcv_data_ctrl(fc,onoff);
181 if (fc->stream_control)
182 fc->stream_control(fc,onoff);
183 }
184
185 return 0;
186}
187
188void flexcop_hw_filter_init(struct flexcop_device *fc)
189{
190 int i;
191 flexcop_ibi_value v;
192 for (i = 0; i < 6 + 32*fc->has_32_hw_pid_filter; i++)
193 flexcop_pid_control(fc,i,0x1fff,0);
194
195 flexcop_pid_group_filter(fc, 0, 0x1fe0);
196 flexcop_pid_group_filter_ctrl(fc,0);
197
198 v = fc->read_ibi_reg(fc,pid_filter_308);
199 v.pid_filter_308.EMM_filter_4 = 1;
200 v.pid_filter_308.EMM_filter_6 = 0;
201 fc->write_ibi_reg(fc,pid_filter_308,v);
202
203 flexcop_null_filter_ctrl(fc, 1);
204}
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c
new file mode 100644
index 000000000000..be4266d4ae91
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-i2c.c
@@ -0,0 +1,210 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-i2c.c - flexcop internal 2Wire bus (I2C) and dvb i2c initialization
5 *
6 * see flexcop.c for copyright information.
7 */
8#include "flexcop.h"
9
10#define FC_MAX_I2C_RETRIES 100000
11
12static int flexcop_i2c_operation(struct flexcop_device *fc, flexcop_ibi_value *r100)
13{
14 int i;
15 flexcop_ibi_value r;
16
17 r100->tw_sm_c_100.working_start = 1;
18 deb_i2c("r100 before: %08x\n",r100->raw);
19
20 fc->write_ibi_reg(fc, tw_sm_c_100, ibi_zero);
21 fc->write_ibi_reg(fc, tw_sm_c_100, *r100); /* initiating i2c operation */
22
23 for (i = 0; i < FC_MAX_I2C_RETRIES; i++) {
24 r = fc->read_ibi_reg(fc, tw_sm_c_100);
25
26 if (!r.tw_sm_c_100.no_base_addr_ack_error) {
27 if (r.tw_sm_c_100.st_done) { /* && !r.tw_sm_c_100.working_start */
28 *r100 = r;
29 deb_i2c("i2c success\n");
30 return 0;
31 }
32 } else {
33 deb_i2c("suffering from an i2c ack_error\n");
34 return -EREMOTEIO;
35 }
36 }
37 deb_i2c("tried %d times i2c operation, never finished or too many ack errors.\n",i);
38 return -EREMOTEIO;
39}
40
41static int flexcop_i2c_read4(struct flexcop_device *fc, flexcop_ibi_value r100, u8 *buf)
42{
43 flexcop_ibi_value r104;
44 int len = r100.tw_sm_c_100.total_bytes, /* remember total_bytes is buflen-1 */
45 ret;
46
47 if ((ret = flexcop_i2c_operation(fc,&r100)) != 0) {
48 /* The Cablestar needs a different kind of i2c-transfer (does not
49 * support "Repeat Start"):
50 * wait for the ACK failure,
51 * and do a subsequent read with the Bit 30 enabled
52 */
53 r100.tw_sm_c_100.no_base_addr_ack_error = 1;
54 if ((ret = flexcop_i2c_operation(fc,&r100)) != 0) {
55 deb_i2c("no_base_addr read failed. %d\n",ret);
56 return ret;
57 }
58 }
59
60 buf[0] = r100.tw_sm_c_100.data1_reg;
61
62 if (len > 0) {
63 r104 = fc->read_ibi_reg(fc,tw_sm_c_104);
64 deb_i2c("read: r100: %08x, r104: %08x\n",r100.raw,r104.raw);
65
66 /* there is at least one more byte, otherwise we wouldn't be here */
67 buf[1] = r104.tw_sm_c_104.data2_reg;
68 if (len > 1) buf[2] = r104.tw_sm_c_104.data3_reg;
69 if (len > 2) buf[3] = r104.tw_sm_c_104.data4_reg;
70 }
71
72 return 0;
73}
74
75static int flexcop_i2c_write4(struct flexcop_device *fc, flexcop_ibi_value r100, u8 *buf)
76{
77 flexcop_ibi_value r104;
78 int len = r100.tw_sm_c_100.total_bytes; /* remember total_bytes is buflen-1 */
79 r104.raw = 0;
80
81 /* there is at least one byte, otherwise we wouldn't be here */
82 r100.tw_sm_c_100.data1_reg = buf[0];
83
84 r104.tw_sm_c_104.data2_reg = len > 0 ? buf[1] : 0;
85 r104.tw_sm_c_104.data3_reg = len > 1 ? buf[2] : 0;
86 r104.tw_sm_c_104.data4_reg = len > 2 ? buf[3] : 0;
87
88 deb_i2c("write: r100: %08x, r104: %08x\n",r100.raw,r104.raw);
89
90 /* write the additional i2c data before doing the actual i2c operation */
91 fc->write_ibi_reg(fc,tw_sm_c_104,r104);
92 return flexcop_i2c_operation(fc,&r100);
93}
94
95int flexcop_i2c_request(struct flexcop_device *fc, flexcop_access_op_t op,
96 flexcop_i2c_port_t port, u8 chipaddr, u8 addr, u8 *buf, u16 len)
97{
98 int ret;
99 u16 bytes_to_transfer;
100 flexcop_ibi_value r100;
101
102 deb_i2c("op = %d\n",op);
103 r100.raw = 0;
104 r100.tw_sm_c_100.chipaddr = chipaddr;
105 r100.tw_sm_c_100.twoWS_rw = op;
106 r100.tw_sm_c_100.twoWS_port_reg = port;
107
108 while (len != 0) {
109 bytes_to_transfer = len > 4 ? 4 : len;
110
111 r100.tw_sm_c_100.total_bytes = bytes_to_transfer - 1;
112 r100.tw_sm_c_100.baseaddr = addr;
113
114 if (op == FC_READ)
115 ret = flexcop_i2c_read4(fc, r100, buf);
116 else
117 ret = flexcop_i2c_write4(fc,r100, buf);
118
119 if (ret < 0)
120 return ret;
121
122 buf += bytes_to_transfer;
123 addr += bytes_to_transfer;
124 len -= bytes_to_transfer;
125 };
126
127 return 0;
128}
129/* exported for PCI i2c */
130EXPORT_SYMBOL(flexcop_i2c_request);
131
132/* master xfer callback for demodulator */
133static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
134{
135 struct flexcop_device *fc = i2c_get_adapdata(i2c_adap);
136 int i, ret = 0;
137
138 if (down_interruptible(&fc->i2c_sem))
139 return -ERESTARTSYS;
140
141 /* reading */
142 if (num == 2 &&
143 msgs[0].flags == 0 &&
144 msgs[1].flags == I2C_M_RD &&
145 msgs[0].buf != NULL &&
146 msgs[1].buf != NULL) {
147
148 ret = fc->i2c_request(fc, FC_READ, FC_I2C_PORT_DEMOD, msgs[0].addr, msgs[0].buf[0], msgs[1].buf, msgs[1].len);
149
150 } else for (i = 0; i < num; i++) { /* writing command */
151 if (msgs[i].flags != 0 || msgs[i].buf == NULL || msgs[i].len < 2) {
152 ret = -EINVAL;
153 break;
154 }
155
156 ret = fc->i2c_request(fc, FC_WRITE, FC_I2C_PORT_DEMOD, msgs[i].addr, msgs[i].buf[0], &msgs[i].buf[1], msgs[i].len - 1);
157 }
158
159 if (ret < 0)
160 err("i2c master_xfer failed");
161 else
162 ret = num;
163
164 up(&fc->i2c_sem);
165
166 return ret;
167}
168
169static u32 flexcop_i2c_func(struct i2c_adapter *adapter)
170{
171 return I2C_FUNC_I2C;
172}
173
174static struct i2c_algorithm flexcop_algo = {
175 .name = "FlexCop I2C algorithm",
176 .id = I2C_ALGO_BIT,
177 .master_xfer = flexcop_master_xfer,
178 .functionality = flexcop_i2c_func,
179};
180
181int flexcop_i2c_init(struct flexcop_device *fc)
182{
183 int ret;
184
185 sema_init(&fc->i2c_sem,1);
186
187 memset(&fc->i2c_adap, 0, sizeof(struct i2c_adapter));
188 strncpy(fc->i2c_adap.name, "B2C2 FlexCop device",I2C_NAME_SIZE);
189
190 i2c_set_adapdata(&fc->i2c_adap,fc);
191
192 fc->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
193 fc->i2c_adap.algo = &flexcop_algo;
194 fc->i2c_adap.algo_data = NULL;
195 fc->i2c_adap.id = I2C_ALGO_BIT;
196
197 if ((ret = i2c_add_adapter(&fc->i2c_adap)) < 0)
198 return ret;
199
200 fc->init_state |= FC_STATE_I2C_INIT;
201 return 0;
202}
203
204void flexcop_i2c_exit(struct flexcop_device *fc)
205{
206 if (fc->init_state & FC_STATE_I2C_INIT)
207 i2c_del_adapter(&fc->i2c_adap);
208
209 fc->init_state &= ~FC_STATE_I2C_INIT;
210}
diff --git a/drivers/media/dvb/b2c2/flexcop-misc.c b/drivers/media/dvb/b2c2/flexcop-misc.c
new file mode 100644
index 000000000000..19e06da46774
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-misc.c
@@ -0,0 +1,66 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-misc.c - miscellaneous functions.
5 *
6 * see flexcop.c for copyright information.
7 */
8#include "flexcop.h"
9
10void flexcop_determine_revision(struct flexcop_device *fc)
11{
12 flexcop_ibi_value v = fc->read_ibi_reg(fc,misc_204);
13
14 switch (v.misc_204.Rev_N_sig_revision_hi) {
15 case 0x2:
16 deb_info("found a FlexCopII.\n");
17 fc->rev = FLEXCOP_II;
18 break;
19 case 0x3:
20 deb_info("found a FlexCopIIb.\n");
21 fc->rev = FLEXCOP_IIB;
22 break;
23 case 0x0:
24 deb_info("found a FlexCopIII.\n");
25 fc->rev = FLEXCOP_III;
26 break;
27 default:
28 err("unkown FlexCop Revision: %x. Please report the linux-dvb@linuxtv.org.",v.misc_204.Rev_N_sig_revision_hi);
29 break;
30 }
31
32 if ((fc->has_32_hw_pid_filter = v.misc_204.Rev_N_sig_caps))
33 deb_info("this FlexCop has the additional 32 hardware pid filter.\n");
34 else
35 deb_info("this FlexCop has only the 6 basic main hardware pid filter.\n");
36 /* bus parts have to decide if hw pid filtering is used or not. */
37}
38
39const char *flexcop_revision_names[] = {
40 "Unkown chip",
41 "FlexCopII",
42 "FlexCopIIb",
43 "FlexCopIII",
44};
45
46const char *flexcop_device_names[] = {
47 "Unkown device",
48 "AirStar 2 DVB-T",
49 "AirStar 2 ATSC",
50 "SkyStar 2 DVB-S",
51 "SkyStar 2 DVB-S (old version)",
52 "CableStar 2 DVB-C",
53};
54
55const char *flexcop_bus_names[] = {
56 "USB",
57 "PCI",
58};
59
60void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const
61 char *suffix)
62{
63 info("%s '%s' at the '%s' bus controlled by a '%s' %s",prefix,
64 flexcop_device_names[fc->dev_type],flexcop_bus_names[fc->bus_type],
65 flexcop_revision_names[fc->rev],suffix);
66}
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c
new file mode 100644
index 000000000000..ed717c0073d5
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-pci.c
@@ -0,0 +1,381 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-pci.c - covers the PCI part including DMA transfers.
5 *
6 * see flexcop.c for copyright information.
7 */
8
9#define FC_LOG_PREFIX "flexcop-pci"
10#include "flexcop-common.h"
11
12static int enable_pid_filtering = 1;
13module_param(enable_pid_filtering, int, 0444);
14MODULE_PARM_DESC(enable_pid_filtering, "enable hardware pid filtering: supported values: 0 (fullts), 1");
15
16#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
17#define dprintk(level,args...) \
18 do { if ((debug & level)) printk(args); } while (0)
19#define DEBSTATUS ""
20#else
21#define dprintk(level,args...)
22#define DEBSTATUS " (debugging is not enabled)"
23#endif
24
25#define deb_info(args...) dprintk(0x01,args)
26#define deb_reg(args...) dprintk(0x02,args)
27#define deb_ts(args...) dprintk(0x04,args)
28#define deb_irq(args...) dprintk(0x08,args)
29
30static int debug = 0;
31module_param(debug, int, 0644);
32MODULE_PARM_DESC(debug, "set debug level (1=info,2=regs,4=TS,8=irqdma (|-able))." DEBSTATUS);
33
34#define DRIVER_VERSION "0.1"
35#define DRIVER_NAME "Technisat/B2C2 FlexCop II/IIb/III Digital TV PCI Driver"
36#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>"
37
38struct flexcop_pci {
39 struct pci_dev *pdev;
40
41#define FC_PCI_INIT 0x01
42#define FC_PCI_DMA_INIT 0x02
43 int init_state;
44
45 void __iomem *io_mem;
46 u32 irq;
47/* buffersize (at least for DMA1, need to be % 188 == 0,
48 * this logic is required */
49#define FC_DEFAULT_DMA1_BUFSIZE (1280 * 188)
50#define FC_DEFAULT_DMA2_BUFSIZE (10 * 188)
51 struct flexcop_dma dma[2];
52
53 int active_dma1_addr; /* 0 = addr0 of dma1; 1 = addr1 of dma1 */
54 u32 last_dma1_cur_pos; /* position of the pointer last time the timer/packet irq occured */
55 int count;
56
57 spinlock_t irq_lock;
58
59 struct flexcop_device *fc_dev;
60};
61
62static int lastwreg,lastwval,lastrreg,lastrval;
63
64static flexcop_ibi_value flexcop_pci_read_ibi_reg (struct flexcop_device *fc, flexcop_ibi_register r)
65{
66 struct flexcop_pci *fc_pci = fc->bus_specific;
67 flexcop_ibi_value v;
68 v.raw = readl(fc_pci->io_mem + r);
69
70 if (lastrreg != r || lastrval != v.raw) {
71 lastrreg = r; lastrval = v.raw;
72 deb_reg("new rd: %3x: %08x\n",r,v.raw);
73 }
74
75 return v;
76}
77
78static int flexcop_pci_write_ibi_reg(struct flexcop_device *fc, flexcop_ibi_register r, flexcop_ibi_value v)
79{
80 struct flexcop_pci *fc_pci = fc->bus_specific;
81
82 if (lastwreg != r || lastwval != v.raw) {
83 lastwreg = r; lastwval = v.raw;
84 deb_reg("new wr: %3x: %08x\n",r,v.raw);
85 }
86
87 writel(v.raw, fc_pci->io_mem + r);
88 return 0;
89}
90
91/* When PID filtering is turned on, we use the timer IRQ, because small amounts
92 * of data need to be passed to the user space instantly as well. When PID
93 * filtering is turned off, we use the page-change-IRQ */
94static irqreturn_t flexcop_pci_irq(int irq, void *dev_id, struct pt_regs *regs)
95{
96 struct flexcop_pci *fc_pci = dev_id;
97 struct flexcop_device *fc = fc_pci->fc_dev;
98 flexcop_ibi_value v = fc->read_ibi_reg(fc,irq_20c);
99 irqreturn_t ret = IRQ_HANDLED;
100
101 spin_lock_irq(&fc_pci->irq_lock);
102
103 if (v.irq_20c.DMA1_IRQ_Status == 1) {
104 if (fc_pci->active_dma1_addr == 0)
105 flexcop_pass_dmx_packets(fc_pci->fc_dev,fc_pci->dma[0].cpu_addr0,fc_pci->dma[0].size / 188);
106 else
107 flexcop_pass_dmx_packets(fc_pci->fc_dev,fc_pci->dma[0].cpu_addr1,fc_pci->dma[0].size / 188);
108
109 deb_irq("page change to page: %d\n",!fc_pci->active_dma1_addr);
110 fc_pci->active_dma1_addr = !fc_pci->active_dma1_addr;
111 } else if (v.irq_20c.DMA1_Timer_Status == 1) {
112 /* for the timer IRQ we only can use buffer dmx feeding, because we don't have
113 * complete TS packets when reading from the DMA memory */
114 dma_addr_t cur_addr =
115 fc->read_ibi_reg(fc,dma1_008).dma_0x8.dma_cur_addr << 2;
116 u32 cur_pos = cur_addr - fc_pci->dma[0].dma_addr0;
117
118 deb_irq("irq: %08x cur_addr: %08x: cur_pos: %08x, last_cur_pos: %08x ",
119 v.raw,cur_addr,cur_pos,fc_pci->last_dma1_cur_pos);
120
121 /* buffer end was reached, restarted from the beginning
122 * pass the data from last_cur_pos to the buffer end to the demux
123 */
124 if (cur_pos < fc_pci->last_dma1_cur_pos) {
125 deb_irq(" end was reached: passing %d bytes ",(fc_pci->dma[0].size*2 - 1) - fc_pci->last_dma1_cur_pos);
126 flexcop_pass_dmx_data(fc_pci->fc_dev,
127 fc_pci->dma[0].cpu_addr0 + fc_pci->last_dma1_cur_pos,
128 (fc_pci->dma[0].size*2) - fc_pci->last_dma1_cur_pos);
129 fc_pci->last_dma1_cur_pos = 0;
130 fc_pci->count = 0;
131 }
132
133 if (cur_pos > fc_pci->last_dma1_cur_pos) {
134 deb_irq(" passing %d bytes ",cur_pos - fc_pci->last_dma1_cur_pos);
135 flexcop_pass_dmx_data(fc_pci->fc_dev,
136 fc_pci->dma[0].cpu_addr0 + fc_pci->last_dma1_cur_pos,
137 cur_pos - fc_pci->last_dma1_cur_pos);
138 }
139 deb_irq("\n");
140
141 fc_pci->last_dma1_cur_pos = cur_pos;
142 } else
143 ret = IRQ_NONE;
144
145 spin_unlock_irq(&fc_pci->irq_lock);
146
147/* packet count would be ideal for hw filtering, but it isn't working. Either
148 * the data book is wrong, or I'm unable to read it correctly */
149
150/* if (v.irq_20c.DMA1_Size_IRQ_Status == 1) { packet counter */
151
152 return ret;
153}
154
155static int flexcop_pci_stream_control(struct flexcop_device *fc, int onoff)
156{
157 struct flexcop_pci *fc_pci = fc->bus_specific;
158 if (onoff) {
159 flexcop_dma_config(fc,&fc_pci->dma[0],FC_DMA_1,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1);
160 flexcop_dma_config(fc,&fc_pci->dma[1],FC_DMA_2,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1);
161 flexcop_dma_config_timer(fc,FC_DMA_1,1);
162
163 if (fc_pci->fc_dev->pid_filtering) {
164 fc_pci->last_dma1_cur_pos = 0;
165 flexcop_dma_control_timer_irq(fc,FC_DMA_1,1);
166 } else {
167 fc_pci->active_dma1_addr = 0;
168 flexcop_dma_control_size_irq(fc,FC_DMA_1,1);
169 }
170
171/* flexcop_dma_config_packet_count(fc,FC_DMA_1,0xc0);
172 flexcop_dma_control_packet_irq(fc,FC_DMA_1,1); */
173
174 deb_irq("irqs enabled\n");
175 } else {
176 if (fc_pci->fc_dev->pid_filtering)
177 flexcop_dma_control_timer_irq(fc,FC_DMA_1,0);
178 else
179 flexcop_dma_control_size_irq(fc,FC_DMA_1,0);
180
181// flexcop_dma_control_packet_irq(fc,FC_DMA_1,0);
182 deb_irq("irqs disabled\n");
183 }
184
185 return 0;
186}
187
188static int flexcop_pci_dma_init(struct flexcop_pci *fc_pci)
189{
190 int ret;
191 if ((ret = flexcop_dma_allocate(fc_pci->pdev,&fc_pci->dma[0],FC_DEFAULT_DMA1_BUFSIZE)) != 0)
192 return ret;
193
194 if ((ret = flexcop_dma_allocate(fc_pci->pdev,&fc_pci->dma[1],FC_DEFAULT_DMA2_BUFSIZE)) != 0)
195 goto dma1_free;
196
197 flexcop_sram_set_dest(fc_pci->fc_dev,FC_SRAM_DEST_MEDIA | FC_SRAM_DEST_NET, FC_SRAM_DEST_TARGET_DMA1);
198 flexcop_sram_set_dest(fc_pci->fc_dev,FC_SRAM_DEST_CAO | FC_SRAM_DEST_CAI, FC_SRAM_DEST_TARGET_DMA2);
199
200 fc_pci->init_state |= FC_PCI_DMA_INIT;
201 goto success;
202dma1_free:
203 flexcop_dma_free(&fc_pci->dma[0]);
204
205success:
206 return ret;
207}
208
209static void flexcop_pci_dma_exit(struct flexcop_pci *fc_pci)
210{
211 if (fc_pci->init_state & FC_PCI_DMA_INIT) {
212 flexcop_dma_free(&fc_pci->dma[0]);
213 flexcop_dma_free(&fc_pci->dma[1]);
214 }
215 fc_pci->init_state &= ~FC_PCI_DMA_INIT;
216}
217
218static int flexcop_pci_init(struct flexcop_pci *fc_pci)
219{
220 int ret;
221 u8 card_rev;
222
223 pci_read_config_byte(fc_pci->pdev, PCI_CLASS_REVISION, &card_rev);
224 info("card revision %x", card_rev);
225
226 if ((ret = pci_enable_device(fc_pci->pdev)) != 0)
227 return ret;
228
229 pci_set_master(fc_pci->pdev);
230
231 /* enable interrupts */
232 // pci_write_config_dword(pdev, 0x6c, 0x8000);
233
234 if ((ret = pci_request_regions(fc_pci->pdev, DRIVER_NAME)) != 0)
235 goto err_pci_disable_device;
236
237 fc_pci->io_mem = pci_iomap(fc_pci->pdev, 0, 0x800);
238
239 if (!fc_pci->io_mem) {
240 err("cannot map io memory\n");
241 ret = -EIO;
242 goto err_pci_release_regions;
243 }
244
245 pci_set_drvdata(fc_pci->pdev, fc_pci);
246
247 if ((ret = request_irq(fc_pci->pdev->irq, flexcop_pci_irq,
248 SA_SHIRQ, DRIVER_NAME, fc_pci)) != 0)
249 goto err_pci_iounmap;
250
251 spin_lock_init(&fc_pci->irq_lock);
252
253 fc_pci->init_state |= FC_PCI_INIT;
254 goto success;
255
256err_pci_iounmap:
257 pci_iounmap(fc_pci->pdev, fc_pci->io_mem);
258 pci_set_drvdata(fc_pci->pdev, NULL);
259err_pci_release_regions:
260 pci_release_regions(fc_pci->pdev);
261err_pci_disable_device:
262 pci_disable_device(fc_pci->pdev);
263
264success:
265 return ret;
266}
267
268static void flexcop_pci_exit(struct flexcop_pci *fc_pci)
269{
270 if (fc_pci->init_state & FC_PCI_INIT) {
271 free_irq(fc_pci->pdev->irq, fc_pci);
272 pci_iounmap(fc_pci->pdev, fc_pci->io_mem);
273 pci_set_drvdata(fc_pci->pdev, NULL);
274 pci_release_regions(fc_pci->pdev);
275 pci_disable_device(fc_pci->pdev);
276 }
277 fc_pci->init_state &= ~FC_PCI_INIT;
278}
279
280
281static int flexcop_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
282{
283 struct flexcop_device *fc;
284 struct flexcop_pci *fc_pci;
285 int ret = -ENOMEM;
286
287 if ((fc = flexcop_device_kmalloc(sizeof(struct flexcop_pci))) == NULL) {
288 err("out of memory\n");
289 return -ENOMEM;
290 }
291
292/* general flexcop init */
293 fc_pci = fc->bus_specific;
294 fc_pci->fc_dev = fc;
295
296 fc->read_ibi_reg = flexcop_pci_read_ibi_reg;
297 fc->write_ibi_reg = flexcop_pci_write_ibi_reg;
298 fc->i2c_request = flexcop_i2c_request;
299 fc->get_mac_addr = flexcop_eeprom_check_mac_addr;
300
301 fc->stream_control = flexcop_pci_stream_control;
302
303 if (enable_pid_filtering)
304 info("will use the HW PID filter.");
305 else
306 info("will pass the complete TS to the demuxer.");
307
308 fc->pid_filtering = enable_pid_filtering;
309 fc->bus_type = FC_PCI;
310
311 fc->dev = &pdev->dev;
312 fc->owner = THIS_MODULE;
313
314/* bus specific part */
315 fc_pci->pdev = pdev;
316 if ((ret = flexcop_pci_init(fc_pci)) != 0)
317 goto err_kfree;
318
319/* init flexcop */
320 if ((ret = flexcop_device_initialize(fc)) != 0)
321 goto err_pci_exit;
322
323/* init dma */
324 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0)
325 goto err_fc_exit;
326
327 goto success;
328err_fc_exit:
329 flexcop_device_exit(fc);
330err_pci_exit:
331 flexcop_pci_exit(fc_pci);
332err_kfree:
333 flexcop_device_kfree(fc);
334success:
335 return ret;
336}
337
338/* in theory every _exit function should be called exactly two times,
339 * here and in the bail-out-part of the _init-function
340 */
341static void flexcop_pci_remove(struct pci_dev *pdev)
342{
343 struct flexcop_pci *fc_pci = pci_get_drvdata(pdev);
344
345 flexcop_pci_dma_exit(fc_pci);
346 flexcop_device_exit(fc_pci->fc_dev);
347 flexcop_pci_exit(fc_pci);
348 flexcop_device_kfree(fc_pci->fc_dev);
349}
350
351static struct pci_device_id flexcop_pci_tbl[] = {
352 { PCI_DEVICE(0x13d0, 0x2103) },
353/* { PCI_DEVICE(0x13d0, 0x2200) }, PCI FlexCopIII ? */
354 { },
355};
356
357MODULE_DEVICE_TABLE(pci, flexcop_pci_tbl);
358
359static struct pci_driver flexcop_pci_driver = {
360 .name = "Technisat/B2C2 FlexCop II/IIb/III PCI",
361 .id_table = flexcop_pci_tbl,
362 .probe = flexcop_pci_probe,
363 .remove = flexcop_pci_remove,
364};
365
366static int __init flexcop_pci_module_init(void)
367{
368 return pci_register_driver(&flexcop_pci_driver);
369}
370
371static void __exit flexcop_pci_module_exit(void)
372{
373 pci_unregister_driver(&flexcop_pci_driver);
374}
375
376module_init(flexcop_pci_module_init);
377module_exit(flexcop_pci_module_exit);
378
379MODULE_AUTHOR(DRIVER_AUTHOR);
380MODULE_DESCRIPTION(DRIVER_NAME);
381MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/b2c2/flexcop-reg.h b/drivers/media/dvb/b2c2/flexcop-reg.h
new file mode 100644
index 000000000000..5e131be55cb3
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-reg.h
@@ -0,0 +1,701 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-reg.h - register abstraction for FlexCopII, FlexCopIIb and FlexCopIII
5 *
6 * see flexcop.c for copyright information.
7 */
8#ifndef __FLEXCOP_REG_H__
9#define __FLEXCOP_REG_H__
10
11
12typedef enum {
13 FLEXCOP_UNK = 0,
14 FLEXCOP_II,
15 FLEXCOP_IIB,
16 FLEXCOP_III,
17} flexcop_revision_t;
18
19extern const char *flexcop_revision_names[];
20
21typedef enum {
22 FC_UNK = 0,
23 FC_AIR_DVB,
24 FC_AIR_ATSC,
25 FC_SKY,
26 FC_SKY_OLD,
27 FC_CABLE,
28} flexcop_device_type_t;
29
30typedef enum {
31 FC_USB = 0,
32 FC_PCI,
33} flexcop_bus_t;
34
35extern const char *flexcop_device_names[];
36
37/* FlexCop IBI Registers */
38
39/* flexcop_ibi_reg - a huge union representing the register structure */
40typedef union {
41 u32 raw;
42
43/* DMA 0x000 to 0x01c
44 * DMA1 0x000 to 0x00c
45 * DMA2 0x010 to 0x01c
46 */
47 struct {
48 u32 dma_0start : 1; /* set: data will be delivered to dma1_address0 */
49 u32 dma_0No_update : 1; /* set: dma1_cur_address will be updated, unset: no update */
50 u32 dma_address0 :30; /* physical/virtual host memory address0 DMA */
51 } dma_0x0;
52
53 struct {
54 u32 DMA_maxpackets : 8; /* (remapped) PCI DMA1 Packet Count Interrupt. This variable
55 is able to be read and written while bit(1) of register
56 0x00c (remap_enable) is set. This variable represents
57 the number of packets that will be transmitted to the PCI
58 host using PCI DMA1 before an interrupt to the PCI is
59 asserted. This functionality may be enabled using bit(20)
60 of register 0x208. N=0 disables the IRQ. */
61 u32 dma_addr_size :24; /* size of memory buffer in DWORDs (bytesize / 4) for DMA */
62 } dma_0x4_remap;
63
64 struct {
65 u32 dma1timer : 7; /* reading PCI DMA1 timer ... when remap_enable is 0 */
66 u32 unused : 1;
67 u32 dma_addr_size :24;
68 } dma_0x4_read;
69
70 struct {
71 u32 unused : 1;
72 u32 dmatimer : 7; /* writing PCI DMA1 timer ... when remap_enable is 0 */
73 u32 dma_addr_size :24;
74 } dma_0x4_write;
75
76 struct {
77 u32 unused : 2;
78 u32 dma_cur_addr :30; /* current physical host memory address pointer for DMA */
79 } dma_0x8;
80
81 struct {
82 u32 dma_1start : 1; /* set: data will be delivered to dma_address1, when dma_address0 is full */
83 u32 remap_enable : 1; /* remap enable for 0x0x4(7:0) */
84 u32 dma_address1 :30; /* Physical/virtual address 1 on DMA */
85 } dma_0xc;
86
87/* Two-wire Serial Master and Clock 0x100-0x110 */
88 struct {
89// u32 slave_transmitter : 1; /* ???*/
90 u32 chipaddr : 7; /* two-line serial address of the target slave */
91 u32 reserved1 : 1;
92 u32 baseaddr : 8; /* address of the location of the read/write operation */
93 u32 data1_reg : 8; /* first byte in two-line serial read/write operation */
94 u32 working_start : 1; /* when doing a write operation this indicator is 0 when ready
95 * set to 1 when doing a write operation */
96 u32 twoWS_rw : 1; /* read/write indicator (1 = read, 0 write) */
97 u32 total_bytes : 2; /* number of data bytes in each two-line serial transaction (0 = 1 byte, 11 = 4byte)*/
98 u32 twoWS_port_reg : 2; /* port selection: 01 - Front End/Demod, 10 - EEPROM, 11 - Tuner */
99 u32 no_base_addr_ack_error : 1; /* writing: write-req: frame is produced w/o baseaddr, read-req: read-cycles w/o
100 * preceding address assignment write frame
101 * ACK_ERROR = 1 when no ACK from slave in the last transaction */
102 u32 st_done : 1; /* indicator for transaction is done */
103 } tw_sm_c_100;
104
105 struct {
106 u32 data2_reg : 8; /* 2nd data byte */
107 u32 data3_reg : 8; /* 3rd data byte */
108 u32 data4_reg : 8; /* 4th data byte */
109 u32 exlicit_stops : 1; /* when set, transactions are produced w/o trailing STOP flag, then send isolated STOP flags */
110 u32 force_stop : 1; /* isolated stop flag */
111 u32 unused : 6;
112 } tw_sm_c_104;
113
114/* Clock. The register allows the FCIII to convert an incoming Master clock
115 * (MCLK) signal into a lower frequency clock through the use of a LowCounter
116 * (TLO) and a High- Counter (THI). The time counts for THI and TLO are
117 * measured in MCLK; each count represents 4 MCLK input clock cycles.
118 *
119 * The default output for port #1 is set for Front End Demod communication. (0x108)
120 * The default output for port #2 is set for EEPROM communication. (0x10c)
121 * The default output for port #3 is set for Tuner communication. (0x110)
122 */
123 struct {
124 u32 thi1 : 6; /* Thi for port #1 (def: 100110b; 38) */
125 u32 reserved1 : 2;
126 u32 tlo1 : 5; /* Tlo for port #1 (def: 11100b; 28) */
127 u32 reserved2 :19;
128 } tw_sm_c_108;
129
130 struct {
131 u32 thi1 : 6; /* Thi for port #2 (def: 111001b; 57) */
132 u32 reserved1 : 2;
133 u32 tlo1 : 5; /* Tlo for port #2 (def: 11100b; 28) */
134 u32 reserved2 :19;
135 } tw_sm_c_10c;
136
137 struct {
138 u32 thi1 : 6; /* Thi for port #3 (def: 111001b; 57) */
139 u32 reserved1 : 2;
140 u32 tlo1 : 5; /* Tlo for port #3 (def: 11100b; 28) */
141 u32 reserved2 :19;
142 } tw_sm_c_110;
143
144/* LNB Switch Frequency 0x200
145 * Clock that creates the LNB switch tone. The default is set to have a fixed
146 * low output (not oscillating) to the LNB_CTL line.
147 */
148 struct {
149 u32 LNB_CTLHighCount_sig :15; /* It is the number of pre-scaled clock cycles that will be low. */
150 u32 LNB_CTLLowCount_sig :15; /* For example, to obtain a 22KHz output given a 45 Mhz Master
151 Clock signal (MCLK), set PreScalar=01 and LowCounter value to 0x1ff. */
152 u32 LNB_CTLPrescaler_sig : 2; /* pre-scaler divides MCLK: 00 (no division), 01 by 2, 10 by 4, 11 by 12 */
153 } lnb_switch_freq_200;
154
155/* ACPI, Peripheral Reset, LNB Polarity
156 * ACPI power conservation mode, LNB polarity selection (low or high voltage),
157 * and peripheral reset.
158 */
159 struct {
160 u32 ACPI1_sig : 1; /* turn of the power of tuner and LNB, not implemented in FCIII */
161 u32 ACPI3_sig : 1; /* turn of power of the complete satelite receiver board (except FCIII) */
162 u32 LNB_L_H_sig : 1; /* low or high voltage for LNB. (0 = low, 1 = high) */
163 u32 Per_reset_sig : 1; /* misc. init reset (default: 1), to reset set to low and back to high */
164 u32 reserved :20;
165 u32 Rev_N_sig_revision_hi : 4;/* 0xc in case of FCIII */
166 u32 Rev_N_sig_reserved1 : 2;
167 u32 Rev_N_sig_caps : 1; /* if 1, FCIII has 32 PID- and MAC-filters and is capable of IP multicast */
168 u32 Rev_N_sig_reserved2 : 1;
169 } misc_204;
170
171/* Control and Status 0x208 to 0x21c */
172/* Gross enable and disable control */
173 struct {
174 u32 Stream1_filter_sig : 1; /* Stream1 PID filtering */
175 u32 Stream2_filter_sig : 1; /* Stream2 PID filtering */
176 u32 PCR_filter_sig : 1; /* PCR PID filter */
177 u32 PMT_filter_sig : 1; /* PMT PID filter */
178
179 u32 EMM_filter_sig : 1; /* EMM PID filter */
180 u32 ECM_filter_sig : 1; /* ECM PID filter */
181 u32 Null_filter_sig : 1; /* Filters null packets, PID=0x1fff. */
182 u32 Mask_filter_sig : 1; /* mask PID filter */
183
184 u32 WAN_Enable_sig : 1; /* WAN output line through V8 memory space is activated. */
185 u32 WAN_CA_Enable_sig : 1; /* not in FCIII */
186 u32 CA_Enable_sig : 1; /* not in FCIII */
187 u32 SMC_Enable_sig : 1; /* CI stream data (CAI) goes directly to the smart card intf (opposed IBI 0x600 or SC-cmd buf). */
188
189 u32 Per_CA_Enable_sig : 1; /* not in FCIII */
190 u32 Multi2_Enable_sig : 1; /* ? */
191 u32 MAC_filter_Mode_sig : 1; /* (MAC_filter_enable) Globally enables MAC filters for Net PID filteres. */
192 u32 Rcv_Data_sig : 1; /* PID filtering module enable. When this bit is a one, the PID filter will
193 examine and process packets according to all other (individual) PID
194 filtering controls. If it a zero, no packet processing of any kind will
195 take place. All data from the tuner will be thrown away. */
196
197 u32 DMA1_IRQ_Enable_sig : 1; /* When set, a DWORD counter is enabled on PCI DMA1 that asserts the PCI
198 * interrupt after the specified count for filling the buffer. */
199 u32 DMA1_Timer_Enable_sig : 1; /* When set, a timer is enabled on PCI DMA1 that asserts the PCI interrupt
200 after a specified amount of time. */
201 u32 DMA2_IRQ_Enable_sig : 1; /* same as DMA1_IRQ_Enable_sig but for DMA2 */
202 u32 DMA2_Timer_Enable_sig : 1; /* same as DMA1_Timer_Enable_sig but for DMA2 */
203
204 u32 DMA1_Size_IRQ_Enable_sig : 1; /* When set, a packet count detector is enabled on PCI DMA1 that asserts the PCI interrupt. */
205 u32 DMA2_Size_IRQ_Enable_sig : 1; /* When set, a packet count detector is enabled on PCI DMA2 that asserts the PCI interrupt. */
206 u32 Mailbox_from_V8_Enable_sig: 1; /* When set, writes to the mailbox register produce an interrupt to the
207 PCI host to indicate that mailbox data is available. */
208
209 u32 unused : 9;
210 } ctrl_208;
211
212/* General status. When a PCI interrupt occurs, this register is read to
213 * discover the reason for the interrupt.
214 */
215 struct {
216 u32 DMA1_IRQ_Status : 1; /* When set(1) the DMA1 counter had generated an IRQ. Read Only. */
217 u32 DMA1_Timer_Status : 1; /* When set(1) the DMA1 timer had generated an IRQ. Read Only. */
218 u32 DMA2_IRQ_Status : 1; /* When set(1) the DMA2 counter had generated an IRQ. Read Only. */
219 u32 DMA2_Timer_Status : 1; /* When set(1) the DMA2 timer had generated an IRQ. Read Only. */
220 u32 DMA1_Size_IRQ_Status : 1; /* (Read only). This register is read after an interrupt to */
221 u32 DMA2_Size_IRQ_Status : 1; /* find out why we had an IRQ. Reading this register will clear this bit. Packet count*/
222 u32 Mailbox_from_V8_Status_sig: 1; /* Same as above. Reading this register will clear this bit. */
223 u32 Data_receiver_error : 1; /* 1 indicate an error in the receiver Front End (Tuner module) */
224 u32 Continuity_error_flag : 1; /* 1 indicates a continuity error in the TS stream. */
225 u32 LLC_SNAP_FLAG_set : 1; /* 1 indicates that the LCC_SNAP_FLAG was set. */
226 u32 Transport_Error : 1; /* When set indicates that an unexpected packet was received. */
227 u32 reserved :21;
228 } irq_20c;
229
230
231/* Software reset register */
232 struct {
233 u32 reset_blocks : 8; /* Enabled when Block_reset_enable = 0xB2 and 0x208 bits 15:8 = 0x00.
234 Each bit location represents a 0x100 block of registers. Writing
235 a one in a bit location resets that block of registers and the logic
236 that it controls. */
237 u32 Block_reset_enable : 8; /* This variable is set to 0xB2 when the register is written. */
238 u32 Special_controls :16; /* Asserts Reset_V8 => 0xC258; Turns on pci encryption => 0xC25A;
239 Turns off pci encryption => 0xC259 Note: pci_encryption default
240 at power-up is ON. */
241 } sw_reset_210;
242
243 struct {
244 u32 vuart_oe_sig : 1; /* When clear, the V8 processor has sole control of the serial UART
245 (RS-232 Smart Card interface). When set, the IBI interface
246 defined by register 0x600 controls the serial UART. */
247 u32 v2WS_oe_sig : 1; /* When clear, the V8 processor has direct control of the Two-line
248 Serial Master EEPROM target. When set, the Two-line Serial Master
249 EEPROM target interface is controlled by IBI register 0x100. */
250 u32 halt_V8_sig : 1; /* When set, contiguous wait states are applied to the V8-space
251 bus masters. Once this signal is cleared, normal V8-space
252 operations resume. */
253 u32 section_pkg_enable_sig: 1; /* When set, this signal enables the front end translation circuitry
254 to process section packed transport streams. */
255 u32 s2p_sel_sig : 1; /* Serial to parallel conversion. When set, polarized transport data
256 within the FlexCop3 front end circuitry is converted from a serial
257 stream into parallel data before downstream processing otherwise
258 interprets the data. */
259 u32 unused1 : 3;
260 u32 polarity_PS_CLK_sig: 1; /* This signal is used to invert the input polarity of the tranport
261 stream CLOCK signal before any processing occurs on the transport
262 stream within FlexCop3. */
263 u32 polarity_PS_VALID_sig: 1; /* This signal is used to invert the input polarity of the tranport
264 stream VALID signal before any processing occurs on the transport
265 stream within FlexCop3. */
266 u32 polarity_PS_SYNC_sig: 1; /* This signal is used to invert the input polarity of the tranport
267 stream SYNC signal before any processing occurs on the transport
268 stream within FlexCop3. */
269 u32 polarity_PS_ERR_sig: 1; /* This signal is used to invert the input polarity of the tranport
270 stream ERROR signal before any processing occurs on the transport
271 stream within FlexCop3. */
272 u32 unused2 :20;
273 } misc_214;
274
275/* Mailbox from V8 to host */
276 struct {
277 u32 Mailbox_from_V8 :32; /* When this register is written by either the V8 processor or by an
278 end host, an interrupt is generated to the PCI host to indicate
279 that mailbox data is available. Reading register 20c will clear
280 the IRQ. */
281 } mbox_v8_to_host_218;
282
283/* Mailbox from host to v8 Mailbox_to_V8
284 * Mailbox_to_V8 mailbox storage register
285 * used to send messages from PCI to V8. Writing to this register will send an
286 * IRQ to the V8. Then it can read the data from here. Reading this register
287 * will clear the IRQ. If the V8 is halted and bit 31 of this register is set,
288 * then this register is used instead as a direct interface to access the
289 * V8space memory.
290 */
291 struct {
292 u32 sysramaccess_data : 8; /* Data byte written or read from the specified address in V8 SysRAM. */
293 u32 sysramaccess_addr :15; /* 15 bit address used to access V8 Sys-RAM. */
294 u32 unused : 7;
295 u32 sysramaccess_write: 1; /* Write flag used to latch data into the V8 SysRAM. */
296 u32 sysramaccess_busmuster: 1; /* Setting this bit when the V8 is halted at 0x214 Bit(2) allows
297 this IBI register interface to directly drive the V8-space memory. */
298 } mbox_host_to_v8_21c;
299
300
301/* PIDs, Translation Bit, SMC Filter Select 0x300 to 0x31c */
302 struct {
303 u32 Stream1_PID :13; /* Primary use is receiving Net data, so these 13 bits normally
304 hold the PID value for the desired network stream. */
305 u32 Stream1_trans : 1; /* When set, Net translation will take place for Net data ferried in TS packets. */
306 u32 MAC_Multicast_filter : 1; /* When clear, multicast MAC filtering is not allowed for Stream1 and PID_n filters. */
307 u32 debug_flag_pid_saved : 1;
308 u32 Stream2_PID :13; /* 13 bits for Stream 2 PID filter value. General use. */
309 u32 Stream2_trans : 1; /* When set Tables/CAI translation will take place for the data ferried in
310 Stream2_PID TS packets. */
311 u32 debug_flag_write_status00 : 1;
312 u32 debug_fifo_problem : 1;
313 } pid_filter_300;
314
315 struct {
316 u32 PCR_PID :13; /* PCR stream PID filter value. Primary use is Program Clock Reference stream filtering. */
317 u32 PCR_trans : 1; /* When set, Tables/CAI translation will take place for these packets. */
318 u32 debug_overrun3 : 1;
319 u32 debug_overrun2 : 1;
320 u32 PMT_PID :13; /* stream PID filter value. Primary use is Program Management Table segment filtering. */
321 u32 PMT_trans : 1; /* When set, Tables/CAI translation will take place for these packets. */
322 u32 reserved : 2;
323 } pid_filter_304;
324
325 struct {
326 u32 EMM_PID :13; /* EMM PID filter value. Primary use is Entitlement Management Messaging for
327 conditional access-related data. */
328 u32 EMM_trans : 1; /* When set, Tables/CAI translation will take place for these packets. */
329 u32 EMM_filter_4 : 1; /* When set will pass only EMM data possessing the same ID code as the
330 first four bytes (32 bits) of the end-user s 6-byte Smart Card ID number Select */
331 u32 EMM_filter_6 : 1; /* When set will pass only EMM data possessing the same 6-byte code as the end-users
332 complete 6-byte Smart Card ID number. */
333 u32 ECM_PID :13; /* ECM PID filter value. Primary use is Entitlement Control Messaging for conditional
334 access-related data. */
335 u32 ECM_trans : 1; /* When set, Tables/CAI translation will take place for these packets. */
336 u32 reserved : 2;
337 } pid_filter_308;
338
339 struct {
340 u32 Group_PID :13; /* PID value for group filtering. */
341 u32 Group_trans : 1; /* When set, Tables/CAI translation will take place for these packets. */
342 u32 unused1 : 2;
343 u32 Group_mask :13; /* Mask value used in logical "and" equation that defines group filtering */
344 u32 unused2 : 3;
345 } pid_filter_30c_ext_ind_0_7;
346
347 struct {
348 u32 net_master_read :17;
349 u32 unused :15;
350 } pid_filter_30c_ext_ind_1;
351
352 struct {
353 u32 net_master_write :17;
354 u32 unused :15;
355 } pid_filter_30c_ext_ind_2;
356
357 struct {
358 u32 next_net_master_write :17;
359 u32 unused :15;
360 } pid_filter_30c_ext_ind_3;
361
362 struct {
363 u32 unused1 : 1;
364 u32 state_write :10;
365 u32 reserved1 : 6; /* default: 000100 */
366 u32 stack_read :10;
367 u32 reserved2 : 5; /* default: 00100 */
368 } pid_filter_30c_ext_ind_4;
369
370 struct {
371 u32 stack_cnt :10;
372 u32 unused :22;
373 } pid_filter_30c_ext_ind_5;
374
375 struct {
376 u32 pid_fsm_save_reg0 : 2;
377 u32 pid_fsm_save_reg1 : 2;
378 u32 pid_fsm_save_reg2 : 2;
379 u32 pid_fsm_save_reg3 : 2;
380 u32 pid_fsm_save_reg4 : 2;
381 u32 pid_fsm_save_reg300 : 2;
382 u32 write_status1 : 2;
383 u32 write_status4 : 2;
384 u32 data_size_reg :12;
385 u32 unused : 4;
386 } pid_filter_30c_ext_ind_6;
387
388 struct {
389 u32 index_reg : 5; /* (Index pointer) Points at an internal PIDn register. A binary code
390 representing one of 32 internal PIDn registers as well as its
391 corresponding internal MAC_lown register. */
392 u32 extra_index_reg : 3; /* This vector is used to select between sets of debug signals routed to register 0x30c. */
393 u32 AB_select : 1; /* Used in conjunction with 0x31c. read/write to the MAC_highA or MAC_highB register
394 0=MAC_highB register, 1=MAC_highA */
395 u32 pass_alltables : 1; /* 1=Net packets are not filtered against the Network Table ID found in register 0x400.
396 All types of networks (DVB, ATSC, ISDB) are passed. */
397 u32 unused :22;
398 } index_reg_310;
399
400 struct {
401 u32 PID :13; /* PID value */
402 u32 PID_trans : 1; /* translation will take place for packets filtered */
403 u32 PID_enable_bit : 1; /* When set this PID filter is enabled */
404 u32 reserved :17;
405 } pid_n_reg_314;
406
407 struct {
408 u32 A4_byte : 8;
409 u32 A5_byte : 8;
410 u32 A6_byte : 8;
411 u32 Enable_bit : 1; /* enabled (1) or disabled (1) */
412 u32 HighAB_bit : 1; /* use MAC_highA (1) or MAC_highB (0) as MSB */
413 u32 reserved : 6;
414 } mac_low_reg_318;
415
416 struct {
417 u32 A1_byte : 8;
418 u32 A2_byte : 8;
419 u32 A3_byte : 8;
420 u32 reserved : 8;
421 } mac_high_reg_31c;
422
423/* Table, SMCID,MACDestination Filters 0x400 to 0x41c */
424 struct {
425 u32 reserved :16;
426#define fc_data_Tag_ID_DVB 0x3e
427#define fc_data_Tag_ID_ATSC 0x3f
428#define fc_data_Tag_ID_IDSB 0x8b
429 u32 data_Tag_ID :16;
430 } data_tag_400;
431
432 struct {
433 u32 Card_IDbyte6 : 8;
434 u32 Card_IDbyte5 : 8;
435 u32 Card_IDbyte4 : 8;
436 u32 Card_IDbyte3 : 8;
437 } card_id_408;
438
439 struct {
440 u32 Card_IDbyte2 : 8;
441 u32 Card_IDbyte1 : 8;
442 } card_id_40c;
443
444 /* holding the unique mac address of the receiver which houses the FlexCopIII */
445 struct {
446 u32 MAC1 : 8;
447 u32 MAC2 : 8;
448 u32 MAC3 : 8;
449 u32 MAC6 : 8;
450 } mac_address_418;
451
452 struct {
453 u32 MAC7 : 8;
454 u32 MAC8 : 8;
455 u32 reserved : 16;
456 } mac_address_41c;
457
458 struct {
459 u32 transmitter_data_byte : 8;
460 u32 ReceiveDataReady : 1;
461 u32 ReceiveByteFrameError: 1;
462 u32 txbuffempty : 1;
463 u32 reserved :21;
464 } ci_600;
465
466 struct {
467 u32 pi_d : 8;
468 u32 pi_ha :20;
469 u32 pi_rw : 1;
470 u32 pi_component_reg : 3;
471 } pi_604;
472
473 struct {
474 u32 serialReset : 1;
475 u32 oncecycle_read : 1;
476 u32 Timer_Read_req : 1;
477 u32 Timer_Load_req : 1;
478 u32 timer_data : 7;
479 u32 unused : 1; /* ??? not mentioned in data book */
480 u32 Timer_addr : 5;
481 u32 reserved : 3;
482 u32 pcmcia_a_mod_pwr_n : 1;
483 u32 pcmcia_b_mod_pwr_n : 1;
484 u32 config_Done_stat : 1;
485 u32 config_Init_stat : 1;
486 u32 config_Prog_n : 1;
487 u32 config_wr_n : 1;
488 u32 config_cs_n : 1;
489 u32 config_cclk : 1;
490 u32 pi_CiMax_IRQ_n : 1;
491 u32 pi_timeout_status : 1;
492 u32 pi_wait_n : 1;
493 u32 pi_busy_n : 1;
494 } pi_608;
495
496 struct {
497 u32 PID :13;
498 u32 key_enable : 1;
499#define fc_key_code_default 0x1
500#define fc_key_code_even 0x2
501#define fc_key_code_odd 0x3
502 u32 key_code : 2;
503 u32 key_array_col : 3;
504 u32 key_array_row : 5;
505 u32 dvb_en : 1; /* 0=TS bypasses the Descrambler */
506 u32 rw_flag : 1;
507 u32 reserved : 6;
508 } dvb_reg_60c;
509
510/* SRAM and Output Destination 0x700 to 0x714 */
511 struct {
512 u32 sram_addr :15;
513 u32 sram_rw : 1; /* 0=write, 1=read */
514 u32 sram_data : 8;
515 u32 sc_xfer_bit : 1;
516 u32 reserved1 : 3;
517 u32 oe_pin_reg : 1;
518 u32 ce_pin_reg : 1;
519 u32 reserved2 : 1;
520 u32 start_sram_ibi : 1;
521 } sram_ctrl_reg_700;
522
523 struct {
524 u32 net_addr_read :16;
525 u32 net_addr_write :16;
526 } net_buf_reg_704;
527
528 struct {
529 u32 cai_read :11;
530 u32 reserved1 : 5;
531 u32 cai_write :11;
532 u32 reserved2 : 6;
533 u32 cai_cnt : 4;
534 } cai_buf_reg_708;
535
536 struct {
537 u32 cao_read :11;
538 u32 reserved1 : 5;
539 u32 cap_write :11;
540 u32 reserved2 : 6;
541 u32 cao_cnt : 4;
542 } cao_buf_reg_70c;
543
544 struct {
545 u32 media_read :11;
546 u32 reserved1 : 5;
547 u32 media_write :11;
548 u32 reserved2 : 6;
549 u32 media_cnt : 4;
550 } media_buf_reg_710;
551
552 struct {
553 u32 NET_Dest : 2;
554 u32 CAI_Dest : 2;
555 u32 CAO_Dest : 2;
556 u32 MEDIA_Dest : 2;
557 u32 net_ovflow_error : 1;
558 u32 media_ovflow_error : 1;
559 u32 cai_ovflow_error : 1;
560 u32 cao_ovflow_error : 1;
561 u32 ctrl_usb_wan : 1;
562 u32 ctrl_sramdma : 1;
563 u32 ctrl_maximumfill : 1;
564 u32 reserved :17;
565 } sram_dest_reg_714;
566
567 struct {
568 u32 net_cnt :12;
569 u32 reserved1 : 4;
570 u32 net_addr_read : 1;
571 u32 reserved2 : 3;
572 u32 net_addr_write : 1;
573 u32 reserved3 :11;
574 } net_buf_reg_718;
575
576 struct {
577 u32 wan_speed_sig : 2;
578 u32 reserved1 : 6;
579 u32 wan_wait_state : 8;
580 u32 sram_chip : 2;
581 u32 sram_memmap : 2;
582 u32 reserved2 : 4;
583 u32 wan_pkt_frame : 4;
584 u32 reserved3 : 4;
585 } wan_ctrl_reg_71c;
586} flexcop_ibi_value;
587
588extern flexcop_ibi_value ibi_zero;
589
590typedef enum {
591 FC_I2C_PORT_DEMOD = 1,
592 FC_I2C_PORT_EEPROM = 2,
593 FC_I2C_PORT_TUNER = 3,
594} flexcop_i2c_port_t;
595
596typedef enum {
597 FC_WRITE = 0,
598 FC_READ = 1,
599} flexcop_access_op_t;
600
601typedef enum {
602 FC_SRAM_DEST_NET = 1,
603 FC_SRAM_DEST_CAI = 2,
604 FC_SRAM_DEST_CAO = 4,
605 FC_SRAM_DEST_MEDIA = 8
606} flexcop_sram_dest_t;
607
608typedef enum {
609 FC_SRAM_DEST_TARGET_WAN_USB = 0,
610 FC_SRAM_DEST_TARGET_DMA1 = 1,
611 FC_SRAM_DEST_TARGET_DMA2 = 2,
612 FC_SRAM_DEST_TARGET_FC3_CA = 3
613} flexcop_sram_dest_target_t;
614
615typedef enum {
616 FC_SRAM_2_32KB = 0, /* 64KB */
617 FC_SRAM_1_32KB = 1, /* 32KB - default fow FCII */
618 FC_SRAM_1_128KB = 2, /* 128KB */
619 FC_SRAM_1_48KB = 3, /* 48KB - default for FCIII */
620} flexcop_sram_type_t;
621
622typedef enum {
623 FC_WAN_SPEED_4MBITS = 0,
624 FC_WAN_SPEED_8MBITS = 1,
625 FC_WAN_SPEED_12MBITS = 2,
626 FC_WAN_SPEED_16MBITS = 3,
627} flexcop_wan_speed_t;
628
629typedef enum {
630 FC_DMA_1 = 1,
631 FC_DMA_2 = 2,
632} flexcop_dma_index_t;
633
634typedef enum {
635 FC_DMA_SUBADDR_0 = 1,
636 FC_DMA_SUBADDR_1 = 2,
637} flexcop_dma_addr_index_t;
638
639/* names of the particular registers */
640typedef enum {
641 dma1_000 = 0x000,
642 dma1_004 = 0x004,
643 dma1_008 = 0x008,
644 dma1_00c = 0x00c,
645 dma2_010 = 0x010,
646 dma2_014 = 0x014,
647 dma2_018 = 0x018,
648 dma2_01c = 0x01c,
649
650 tw_sm_c_100 = 0x100,
651 tw_sm_c_104 = 0x104,
652 tw_sm_c_108 = 0x108,
653 tw_sm_c_10c = 0x10c,
654 tw_sm_c_110 = 0x110,
655
656 lnb_switch_freq_200 = 0x200,
657 misc_204 = 0x204,
658 ctrl_208 = 0x208,
659 irq_20c = 0x20c,
660 sw_reset_210 = 0x210,
661 misc_214 = 0x214,
662 mbox_v8_to_host_218 = 0x218,
663 mbox_host_to_v8_21c = 0x21c,
664
665 pid_filter_300 = 0x300,
666 pid_filter_304 = 0x304,
667 pid_filter_308 = 0x308,
668 pid_filter_30c = 0x30c,
669 index_reg_310 = 0x310,
670 pid_n_reg_314 = 0x314,
671 mac_low_reg_318 = 0x318,
672 mac_high_reg_31c = 0x31c,
673
674 data_tag_400 = 0x400,
675 card_id_408 = 0x408,
676 card_id_40c = 0x40c,
677 mac_address_418 = 0x418,
678 mac_address_41c = 0x41c,
679
680 ci_600 = 0x600,
681 pi_604 = 0x604,
682 pi_608 = 0x608,
683 dvb_reg_60c = 0x60c,
684
685 sram_ctrl_reg_700 = 0x700,
686 net_buf_reg_704 = 0x704,
687 cai_buf_reg_708 = 0x708,
688 cao_buf_reg_70c = 0x70c,
689 media_buf_reg_710 = 0x710,
690 sram_dest_reg_714 = 0x714,
691 net_buf_reg_718 = 0x718,
692 wan_ctrl_reg_71c = 0x71c,
693} flexcop_ibi_register;
694
695#define flexcop_set_ibi_value(reg,attr,val) { \
696 flexcop_ibi_value v = fc->read_ibi_reg(fc,reg); \
697 v.reg.attr = val; \
698 fc->write_ibi_reg(fc,reg,v); \
699}
700
701#endif
diff --git a/drivers/media/dvb/b2c2/flexcop-sram.c b/drivers/media/dvb/b2c2/flexcop-sram.c
new file mode 100644
index 000000000000..01570ec80962
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-sram.c
@@ -0,0 +1,403 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-sram.c - functions for controlling the SRAM.
5 *
6 * see flexcop.c for copyright information.
7 */
8#include "flexcop.h"
9
10static void flexcop_sram_set_chip (struct flexcop_device *fc, flexcop_sram_type_t type)
11{
12 flexcop_set_ibi_value(wan_ctrl_reg_71c,sram_chip,type);
13}
14
15int flexcop_sram_init(struct flexcop_device *fc)
16{
17 switch (fc->rev) {
18 case FLEXCOP_II:
19 case FLEXCOP_IIB:
20 flexcop_sram_set_chip(fc,FC_SRAM_1_32KB);
21 break;
22 case FLEXCOP_III:
23 flexcop_sram_set_chip(fc,FC_SRAM_1_48KB);
24 break;
25 default:
26 return -EINVAL;
27 }
28 return 0;
29}
30
31int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, flexcop_sram_dest_target_t target)
32{
33 flexcop_ibi_value v;
34
35 v = fc->read_ibi_reg(fc,sram_dest_reg_714);
36
37 if (fc->rev != FLEXCOP_III && target == FC_SRAM_DEST_TARGET_FC3_CA) {
38 err("SRAM destination target to available on FlexCopII(b)\n");
39 return -EINVAL;
40 }
41
42 deb_sram("sram dest: %x target: %x\n",dest, target);
43
44 if (dest & FC_SRAM_DEST_NET)
45 v.sram_dest_reg_714.NET_Dest = target;
46 if (dest & FC_SRAM_DEST_CAI)
47 v.sram_dest_reg_714.CAI_Dest = target;
48 if (dest & FC_SRAM_DEST_CAO)
49 v.sram_dest_reg_714.CAO_Dest = target;
50 if (dest & FC_SRAM_DEST_MEDIA)
51 v.sram_dest_reg_714.MEDIA_Dest = target;
52
53 fc->write_ibi_reg(fc,sram_dest_reg_714,v);
54 udelay(1000); /* TODO delay really necessary */
55
56 return 0;
57}
58EXPORT_SYMBOL(flexcop_sram_set_dest);
59
60void flexcop_wan_set_speed(struct flexcop_device *fc, flexcop_wan_speed_t s)
61{
62 flexcop_set_ibi_value(wan_ctrl_reg_71c,wan_speed_sig,s);
63}
64EXPORT_SYMBOL(flexcop_wan_set_speed);
65
66void flexcop_sram_ctrl(struct flexcop_device *fc, int usb_wan, int sramdma, int maximumfill)
67{
68 flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714);
69 v.sram_dest_reg_714.ctrl_usb_wan = usb_wan;
70 v.sram_dest_reg_714.ctrl_sramdma = sramdma;
71 v.sram_dest_reg_714.ctrl_maximumfill = maximumfill;
72 fc->write_ibi_reg(fc,sram_dest_reg_714,v);
73}
74EXPORT_SYMBOL(flexcop_sram_ctrl);
75
76#if 0
77static void flexcop_sram_write(struct adapter *adapter, u32 bank, u32 addr, u8 *buf, u32 len)
78{
79 int i, retries;
80 u32 command;
81
82 for (i = 0; i < len; i++) {
83 command = bank | addr | 0x04000000 | (*buf << 0x10);
84
85 retries = 2;
86
87 while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
88 mdelay(1);
89 retries--;
90 };
91
92 if (retries == 0)
93 printk("%s: SRAM timeout\n", __FUNCTION__);
94
95 write_reg_dw(adapter, 0x700, command);
96
97 buf++;
98 addr++;
99 }
100}
101
102static void flex_sram_read(struct adapter *adapter, u32 bank, u32 addr, u8 *buf, u32 len)
103{
104 int i, retries;
105 u32 command, value;
106
107 for (i = 0; i < len; i++) {
108 command = bank | addr | 0x04008000;
109
110 retries = 10000;
111
112 while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
113 mdelay(1);
114 retries--;
115 };
116
117 if (retries == 0)
118 printk("%s: SRAM timeout\n", __FUNCTION__);
119
120 write_reg_dw(adapter, 0x700, command);
121
122 retries = 10000;
123
124 while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
125 mdelay(1);
126 retries--;
127 };
128
129 if (retries == 0)
130 printk("%s: SRAM timeout\n", __FUNCTION__);
131
132 value = read_reg_dw(adapter, 0x700) >> 0x10;
133
134 *buf = (value & 0xff);
135
136 addr++;
137 buf++;
138 }
139}
140
141static void sram_write_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len)
142{
143 u32 bank;
144
145 bank = 0;
146
147 if (adapter->dw_sram_type == 0x20000) {
148 bank = (addr & 0x18000) << 0x0d;
149 }
150
151 if (adapter->dw_sram_type == 0x00000) {
152 if ((addr >> 0x0f) == 0)
153 bank = 0x20000000;
154 else
155 bank = 0x10000000;
156 }
157
158 flex_sram_write(adapter, bank, addr & 0x7fff, buf, len);
159}
160
161static void sram_read_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len)
162{
163 u32 bank;
164
165 bank = 0;
166
167 if (adapter->dw_sram_type == 0x20000) {
168 bank = (addr & 0x18000) << 0x0d;
169 }
170
171 if (adapter->dw_sram_type == 0x00000) {
172 if ((addr >> 0x0f) == 0)
173 bank = 0x20000000;
174 else
175 bank = 0x10000000;
176 }
177
178 flex_sram_read(adapter, bank, addr & 0x7fff, buf, len);
179}
180
181static void sram_read(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
182{
183 u32 length;
184
185 while (len != 0) {
186 length = len;
187
188 // check if the address range belongs to the same
189 // 32K memory chip. If not, the data is read from
190 // one chip at a time.
191 if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) {
192 length = (((addr >> 0x0f) + 1) << 0x0f) - addr;
193 }
194
195 sram_read_chunk(adapter, addr, buf, length);
196
197 addr = addr + length;
198 buf = buf + length;
199 len = len - length;
200 }
201}
202
203static void sram_write(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
204{
205 u32 length;
206
207 while (len != 0) {
208 length = len;
209
210 // check if the address range belongs to the same
211 // 32K memory chip. If not, the data is written to
212 // one chip at a time.
213 if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) {
214 length = (((addr >> 0x0f) + 1) << 0x0f) - addr;
215 }
216
217 sram_write_chunk(adapter, addr, buf, length);
218
219 addr = addr + length;
220 buf = buf + length;
221 len = len - length;
222 }
223}
224
225static void sram_set_size(struct adapter *adapter, u32 mask)
226{
227 write_reg_dw(adapter, 0x71c, (mask | (~0x30000 & read_reg_dw(adapter, 0x71c))));
228}
229
230static void sram_init(struct adapter *adapter)
231{
232 u32 tmp;
233
234 tmp = read_reg_dw(adapter, 0x71c);
235
236 write_reg_dw(adapter, 0x71c, 1);
237
238 if (read_reg_dw(adapter, 0x71c) != 0) {
239 write_reg_dw(adapter, 0x71c, tmp);
240
241 adapter->dw_sram_type = tmp & 0x30000;
242
243 ddprintk("%s: dw_sram_type = %x\n", __FUNCTION__, adapter->dw_sram_type);
244
245 } else {
246
247 adapter->dw_sram_type = 0x10000;
248
249 ddprintk("%s: dw_sram_type = %x\n", __FUNCTION__, adapter->dw_sram_type);
250 }
251
252 /* return value is never used? */
253/* return adapter->dw_sram_type; */
254}
255
256static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr)
257{
258 u8 tmp1, tmp2;
259
260 dprintk("%s: mask = %x, addr = %x\n", __FUNCTION__, mask, addr);
261
262 sram_set_size(adapter, mask);
263 sram_init(adapter);
264
265 tmp2 = 0xa5;
266 tmp1 = 0x4f;
267
268 sram_write(adapter, addr, &tmp2, 1);
269 sram_write(adapter, addr + 4, &tmp1, 1);
270
271 tmp2 = 0;
272
273 mdelay(20);
274
275 sram_read(adapter, addr, &tmp2, 1);
276 sram_read(adapter, addr, &tmp2, 1);
277
278 dprintk("%s: wrote 0xa5, read 0x%2x\n", __FUNCTION__, tmp2);
279
280 if (tmp2 != 0xa5)
281 return 0;
282
283 tmp2 = 0x5a;
284 tmp1 = 0xf4;
285
286 sram_write(adapter, addr, &tmp2, 1);
287 sram_write(adapter, addr + 4, &tmp1, 1);
288
289 tmp2 = 0;
290
291 mdelay(20);
292
293 sram_read(adapter, addr, &tmp2, 1);
294 sram_read(adapter, addr, &tmp2, 1);
295
296 dprintk("%s: wrote 0x5a, read 0x%2x\n", __FUNCTION__, tmp2);
297
298 if (tmp2 != 0x5a)
299 return 0;
300
301 return 1;
302}
303
304static u32 sram_length(struct adapter *adapter)
305{
306 if (adapter->dw_sram_type == 0x10000)
307 return 32768; // 32K
308 if (adapter->dw_sram_type == 0x00000)
309 return 65536; // 64K
310 if (adapter->dw_sram_type == 0x20000)
311 return 131072; // 128K
312
313 return 32768; // 32K
314}
315
316/* FlexcopII can work with 32K, 64K or 128K of external SRAM memory.
317 - for 128K there are 4x32K chips at bank 0,1,2,3.
318 - for 64K there are 2x32K chips at bank 1,2.
319 - for 32K there is one 32K chip at bank 0.
320
321 FlexCop works only with one bank at a time. The bank is selected
322 by bits 28-29 of the 0x700 register.
323
324 bank 0 covers addresses 0x00000-0x07fff
325 bank 1 covers addresses 0x08000-0x0ffff
326 bank 2 covers addresses 0x10000-0x17fff
327 bank 3 covers addresses 0x18000-0x1ffff
328*/
329
330static int flexcop_sram_detect(struct flexcop_device *fc)
331{
332 flexcop_ibi_value r208,r71c_0,vr71c_1;
333
334 r208 = fc->read_ibi_reg(fc, ctrl_208);
335 fc->write_ibi_reg(fc, ctrl_208, ibi_zero);
336
337 r71c_0 = fc->read_ibi_reg(fc, wan_ctrl_reg_71c);
338
339 write_reg_dw(adapter, 0x71c, 1);
340
341 tmp3 = read_reg_dw(adapter, 0x71c);
342
343 dprintk("%s: tmp3 = %x\n", __FUNCTION__, tmp3);
344
345 write_reg_dw(adapter, 0x71c, tmp2);
346
347 // check for internal SRAM ???
348 tmp3--;
349 if (tmp3 != 0) {
350 sram_set_size(adapter, 0x10000);
351 sram_init(adapter);
352 write_reg_dw(adapter, 0x208, tmp);
353
354 dprintk("%s: sram size = 32K\n", __FUNCTION__);
355
356 return 32;
357 }
358
359 if (sram_test_location(adapter, 0x20000, 0x18000) != 0) {
360 sram_set_size(adapter, 0x20000);
361 sram_init(adapter);
362 write_reg_dw(adapter, 0x208, tmp);
363
364 dprintk("%s: sram size = 128K\n", __FUNCTION__);
365
366 return 128;
367 }
368
369 if (sram_test_location(adapter, 0x00000, 0x10000) != 0) {
370 sram_set_size(adapter, 0x00000);
371 sram_init(adapter);
372 write_reg_dw(adapter, 0x208, tmp);
373
374 dprintk("%s: sram size = 64K\n", __FUNCTION__);
375
376 return 64;
377 }
378
379 if (sram_test_location(adapter, 0x10000, 0x00000) != 0) {
380 sram_set_size(adapter, 0x10000);
381 sram_init(adapter);
382 write_reg_dw(adapter, 0x208, tmp);
383
384 dprintk("%s: sram size = 32K\n", __FUNCTION__);
385
386 return 32;
387 }
388
389 sram_set_size(adapter, 0x10000);
390 sram_init(adapter);
391 write_reg_dw(adapter, 0x208, tmp);
392
393 dprintk("%s: SRAM detection failed. Set to 32K \n", __FUNCTION__);
394
395 return 0;
396}
397
398static void sll_detect_sram_size(struct adapter *adapter)
399{
400 sram_detect_for_flex2(adapter);
401}
402
403#endif
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c
new file mode 100644
index 000000000000..0113449abd15
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-usb.c
@@ -0,0 +1,577 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-usb.c - covers the USB part.
5 *
6 * see flexcop.c for copyright information.
7 */
8
9#define FC_LOG_PREFIX "flexcop_usb"
10#include "flexcop-usb.h"
11#include "flexcop-common.h"
12
13/* Version information */
14#define DRIVER_VERSION "0.1"
15#define DRIVER_NAME "Technisat/B2C2 FlexCop II/IIb/III Digital TV USB Driver"
16#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>"
17
18/* debug */
19#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
20#define dprintk(level,args...) \
21 do { if ((debug & level)) { printk(args); } } while (0)
22#define debug_dump(b,l,method) {\
23 int i; \
24 for (i = 0; i < l; i++) method("%02x ", b[i]); \
25 method("\n");\
26}
27
28#define DEBSTATUS ""
29#else
30#define dprintk(level,args...)
31#define debug_dump(b,l,method)
32#define DEBSTATUS " (debugging is not enabled)"
33#endif
34
35static int debug;
36module_param(debug, int, 0644);
37MODULE_PARM_DESC(debug, "set debugging level (1=info,ts=2,ctrl=4,i2c=8,v8mem=16 (or-able))." DEBSTATUS);
38#undef DEBSTATUS
39
40#define deb_info(args...) dprintk(0x01,args)
41#define deb_ts(args...) dprintk(0x02,args)
42#define deb_ctrl(args...) dprintk(0x04,args)
43#define deb_i2c(args...) dprintk(0x08,args)
44#define deb_v8(args...) dprintk(0x10,args)
45
46/* JLP 111700: we will include the 1 bit gap between the upper and lower 3 bits
47 * in the IBI address, to make the V8 code simpler.
48 * PCI ADDRESS FORMAT: 0x71C -> 0000 0111 0001 1100 (these are the six bits used)
49 * in general: 0000 0HHH 000L LL00
50 * IBI ADDRESS FORMAT: RHHH BLLL
51 *
52 * where R is the read(1)/write(0) bit, B is the busy bit
53 * and HHH and LLL are the two sets of three bits from the PCI address.
54 */
55#define B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(usPCI) (u8) (((usPCI >> 2) & 0x07) + ((usPCI >> 4) & 0x70))
56#define B2C2_FLEX_INTERNALADDR_TO_PCIOFFSET(ucAddr) (u16) (((ucAddr & 0x07) << 2) + ((ucAddr & 0x70) << 4))
57
58/*
59 * DKT 020228
60 * - forget about this VENDOR_BUFFER_SIZE, read and write register
61 * deal with DWORD or 4 bytes, that should be should from now on
62 * - from now on, we don't support anything older than firm 1.00
63 * I eliminated the write register as a 2 trip of writing hi word and lo word
64 * and force this to write only 4 bytes at a time.
65 * NOTE: this should work with all the firmware from 1.00 and newer
66 */
67static int flexcop_usb_readwrite_dw(struct flexcop_device *fc, u16 wRegOffsPCI, u32 *val, u8 read)
68{
69 struct flexcop_usb *fc_usb = fc->bus_specific;
70 u8 request = read ? B2C2_USB_READ_REG : B2C2_USB_WRITE_REG;
71 u8 request_type = (read ? USB_DIR_IN : USB_DIR_OUT) | USB_TYPE_VENDOR;
72 u8 wAddress = B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(wRegOffsPCI) | (read ? 0x80 : 0);
73
74 int len = usb_control_msg(fc_usb->udev,
75 read ? B2C2_USB_CTRL_PIPE_IN : B2C2_USB_CTRL_PIPE_OUT,
76 request,
77 request_type, /* 0xc0 read or 0x40 write*/
78 wAddress,
79 0,
80 val,
81 sizeof(u32),
82 B2C2_WAIT_FOR_OPERATION_RDW * HZ);
83
84 if (len != sizeof(u32)) {
85 err("error while %s dword from %d (%d).",read ? "reading" : "writing",
86 wAddress,wRegOffsPCI);
87 return -EIO;
88 }
89 return 0;
90}
91
92/*
93 * DKT 010817 - add support for V8 memory read/write and flash update
94 */
95static int flexcop_usb_v8_memory_req(struct flexcop_usb *fc_usb,
96 flexcop_usb_request_t req, u8 page, u16 wAddress,
97 u8 *pbBuffer,u32 buflen)
98{
99// u8 dwRequestType;
100 u8 request_type = USB_TYPE_VENDOR;
101 u16 wIndex;
102 int nWaitTime,pipe,len;
103
104 wIndex = page << 8;
105
106 switch (req) {
107 case B2C2_USB_READ_V8_MEM:
108 nWaitTime = B2C2_WAIT_FOR_OPERATION_V8READ;
109 request_type |= USB_DIR_IN;
110// dwRequestType = (u8) RTYPE_READ_V8_MEMORY;
111 pipe = B2C2_USB_CTRL_PIPE_IN;
112 break;
113 case B2C2_USB_WRITE_V8_MEM:
114 wIndex |= pbBuffer[0];
115 request_type |= USB_DIR_OUT;
116 nWaitTime = B2C2_WAIT_FOR_OPERATION_V8WRITE;
117// dwRequestType = (u8) RTYPE_WRITE_V8_MEMORY;
118 pipe = B2C2_USB_CTRL_PIPE_OUT;
119 break;
120 case B2C2_USB_FLASH_BLOCK:
121 request_type |= USB_DIR_OUT;
122 nWaitTime = B2C2_WAIT_FOR_OPERATION_V8FLASH;
123// dwRequestType = (u8) RTYPE_WRITE_V8_FLASH;
124 pipe = B2C2_USB_CTRL_PIPE_OUT;
125 break;
126 default:
127 deb_info("unsupported request for v8_mem_req %x.\n",req);
128 return -EINVAL;
129 }
130 deb_v8("v8mem: %02x %02x %04x %04x, len: %d\n",request_type,req,
131 wAddress,wIndex,buflen);
132
133 len = usb_control_msg(fc_usb->udev,pipe,
134 req,
135 request_type,
136 wAddress,
137 wIndex,
138 pbBuffer,
139 buflen,
140 nWaitTime * HZ);
141
142 debug_dump(pbBuffer,len,deb_v8);
143
144 return len == buflen ? 0 : -EIO;
145}
146
147#define bytes_left_to_read_on_page(paddr,buflen) \
148 ((V8_MEMORY_PAGE_SIZE - (paddr & V8_MEMORY_PAGE_MASK)) > buflen \
149 ? buflen : (V8_MEMORY_PAGE_SIZE - (paddr & V8_MEMORY_PAGE_MASK)))
150
151static int flexcop_usb_memory_req(struct flexcop_usb *fc_usb,flexcop_usb_request_t req,
152 flexcop_usb_mem_page_t page_start, u32 addr, int extended, u8 *buf, u32 len)
153{
154 int i,ret = 0;
155 u16 wMax;
156 u32 pagechunk = 0;
157
158 switch(req) {
159 case B2C2_USB_READ_V8_MEM: wMax = USB_MEM_READ_MAX; break;
160 case B2C2_USB_WRITE_V8_MEM: wMax = USB_MEM_WRITE_MAX; break;
161 case B2C2_USB_FLASH_BLOCK: wMax = USB_FLASH_MAX; break;
162 default:
163 return -EINVAL;
164 break;
165 }
166 for (i = 0; i < len;) {
167 pagechunk = wMax < bytes_left_to_read_on_page(addr,len) ? wMax : bytes_left_to_read_on_page(addr,len);
168 deb_info("%x\n",(addr & V8_MEMORY_PAGE_MASK) | (V8_MEMORY_EXTENDED*extended));
169 if ((ret = flexcop_usb_v8_memory_req(fc_usb,req,
170 page_start + (addr / V8_MEMORY_PAGE_SIZE), /* actual page */
171 (addr & V8_MEMORY_PAGE_MASK) | (V8_MEMORY_EXTENDED*extended),
172 &buf[i],pagechunk)) < 0)
173 return ret;
174
175 addr += pagechunk;
176 len -= pagechunk;
177 }
178 return 0;
179}
180
181static int flexcop_usb_get_mac_addr(struct flexcop_device *fc, int extended)
182{
183 return flexcop_usb_memory_req(fc->bus_specific,B2C2_USB_READ_V8_MEM,
184 V8_MEMORY_PAGE_FLASH,0x1f010,1,fc->dvb_adapter.proposed_mac,6);
185}
186
187#if 0
188static int flexcop_usb_utility_req(struct flexcop_usb *fc_usb, int set,
189 flexcop_usb_utility_function_t func, u8 extra, u16 wIndex,
190 u16 buflen, u8 *pvBuffer)
191{
192 u16 wValue;
193 u8 request_type = (set ? USB_DIR_OUT : USB_DIR_IN) | USB_TYPE_VENDOR;
194// u8 dwRequestType = (u8) RTYPE_GENERIC,
195 int nWaitTime = 2,
196 pipe = set ? B2C2_USB_CTRL_PIPE_OUT : B2C2_USB_CTRL_PIPE_IN,
197 len;
198
199 wValue = (func << 8) | extra;
200
201 len = usb_control_msg(fc_usb->udev,pipe,
202 B2C2_USB_UTILITY,
203 request_type,
204 wValue,
205 wIndex,
206 pvBuffer,
207 buflen,
208 nWaitTime * HZ);
209 return len == buflen ? 0 : -EIO;
210}
211#endif
212
213/* usb i2c stuff */
214static int flexcop_usb_i2c_req(struct flexcop_usb *fc_usb,
215 flexcop_usb_request_t req, flexcop_usb_i2c_function_t func,
216 flexcop_i2c_port_t port, u8 chipaddr, u8 addr, u8 *buf, u8 buflen)
217{
218 u16 wValue, wIndex;
219 int nWaitTime,pipe,len;
220// u8 dwRequestType;
221 u8 request_type = USB_TYPE_VENDOR;
222
223 switch (func) {
224 case USB_FUNC_I2C_WRITE:
225 case USB_FUNC_I2C_MULTIWRITE:
226 case USB_FUNC_I2C_REPEATWRITE:
227 /* DKT 020208 - add this to support special case of DiSEqC */
228 case USB_FUNC_I2C_CHECKWRITE:
229 pipe = B2C2_USB_CTRL_PIPE_OUT;
230 nWaitTime = 2;
231// dwRequestType = (u8) RTYPE_GENERIC;
232 request_type |= USB_DIR_OUT;
233 break;
234 case USB_FUNC_I2C_READ:
235 case USB_FUNC_I2C_REPEATREAD:
236 pipe = B2C2_USB_CTRL_PIPE_IN;
237 nWaitTime = 2;
238// dwRequestType = (u8) RTYPE_GENERIC;
239 request_type |= USB_DIR_IN;
240 break;
241 default:
242 deb_info("unsupported function for i2c_req %x\n",func);
243 return -EINVAL;
244 }
245 wValue = (func << 8 ) | (port << 4);
246 wIndex = (chipaddr << 8 ) | addr;
247
248 deb_i2c("i2c %2d: %02x %02x %02x %02x %02x %02x\n",func,request_type,req,
249 ((wValue && 0xff) << 8),wValue >> 8,((wIndex && 0xff) << 8),wIndex >> 8);
250
251 len = usb_control_msg(fc_usb->udev,pipe,
252 req,
253 request_type,
254 wValue,
255 wIndex,
256 buf,
257 buflen,
258 nWaitTime * HZ);
259
260 return len == buflen ? 0 : -EREMOTEIO;
261}
262
263/* actual bus specific access functions, make sure prototype are/will be equal to pci */
264static flexcop_ibi_value flexcop_usb_read_ibi_reg(struct flexcop_device *fc, flexcop_ibi_register reg)
265{
266 flexcop_ibi_value val;
267 val.raw = 0;
268 flexcop_usb_readwrite_dw(fc,reg, &val.raw, 1);
269 return val;
270}
271
272static int flexcop_usb_write_ibi_reg(struct flexcop_device *fc, flexcop_ibi_register reg, flexcop_ibi_value val)
273{
274 return flexcop_usb_readwrite_dw(fc,reg, &val.raw, 0);
275}
276
277static int flexcop_usb_i2c_request(struct flexcop_device *fc, flexcop_access_op_t op,
278 flexcop_i2c_port_t port, u8 chipaddr, u8 addr, u8 *buf, u16 len)
279{
280 if (op == FC_READ)
281 return flexcop_usb_i2c_req(fc->bus_specific,B2C2_USB_I2C_REQUEST,USB_FUNC_I2C_READ,port,chipaddr,addr,buf,len);
282 else
283 return flexcop_usb_i2c_req(fc->bus_specific,B2C2_USB_I2C_REQUEST,USB_FUNC_I2C_WRITE,port,chipaddr,addr,buf,len);
284}
285
286static void flexcop_usb_process_frame(struct flexcop_usb *fc_usb, u8 *buffer, int buffer_length)
287{
288 u8 *b;
289 int l;
290
291 deb_ts("tmp_buffer_length=%d, buffer_length=%d\n", fc_usb->tmp_buffer_length, buffer_length);
292
293 if (fc_usb->tmp_buffer_length > 0) {
294 memcpy(fc_usb->tmp_buffer+fc_usb->tmp_buffer_length, buffer, buffer_length);
295 fc_usb->tmp_buffer_length += buffer_length;
296 b = fc_usb->tmp_buffer;
297 l = fc_usb->tmp_buffer_length;
298 } else {
299 b=buffer;
300 l=buffer_length;
301 }
302
303 while (l >= 190) {
304 if (*b == 0xff)
305 switch (*(b+1) & 0x03) {
306 case 0x01: /* media packet */
307 if ( *(b+2) == 0x47 )
308 flexcop_pass_dmx_packets(fc_usb->fc_dev, b+2, 1);
309 else
310 deb_ts("not ts packet %02x %02x %02x %02x \n", *(b+2), *(b+3), *(b+4), *(b+5) );
311
312 b += 190;
313 l -= 190;
314 break;
315 default:
316 deb_ts("wrong packet type\n");
317 l = 0;
318 break;
319 }
320 else {
321 deb_ts("wrong header\n");
322 l = 0;
323 }
324 }
325
326 if (l>0)
327 memcpy(fc_usb->tmp_buffer, b, l);
328 fc_usb->tmp_buffer_length = l;
329}
330
331static void flexcop_usb_urb_complete(struct urb *urb, struct pt_regs *ptregs)
332{
333 struct flexcop_usb *fc_usb = urb->context;
334 int i;
335
336 if (urb->actual_length > 0)
337 deb_ts("urb completed, bufsize: %d actlen; %d\n",urb->transfer_buffer_length, urb->actual_length);
338
339 for (i = 0; i < urb->number_of_packets; i++) {
340 if (urb->iso_frame_desc[i].status < 0) {
341 err("iso frame descriptor %d has an error: %d\n",i,urb->iso_frame_desc[i].status);
342 } else
343 if (urb->iso_frame_desc[i].actual_length > 0) {
344 deb_ts("passed %d bytes to the demux\n",urb->iso_frame_desc[i].actual_length);
345
346 flexcop_usb_process_frame(fc_usb,
347 urb->transfer_buffer + urb->iso_frame_desc[i].offset,
348 urb->iso_frame_desc[i].actual_length);
349 }
350 urb->iso_frame_desc[i].status = 0;
351 urb->iso_frame_desc[i].actual_length = 0;
352 }
353
354 usb_submit_urb(urb,GFP_ATOMIC);
355}
356
357static int flexcop_usb_stream_control(struct flexcop_device *fc, int onoff)
358{
359 /* submit/kill iso packets */
360 return 0;
361}
362
363static void flexcop_usb_transfer_exit(struct flexcop_usb *fc_usb)
364{
365 int i;
366 for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++)
367 if (fc_usb->iso_urb[i] != NULL) {
368 deb_ts("unlinking/killing urb no. %d\n",i);
369 usb_kill_urb(fc_usb->iso_urb[i]);
370 usb_free_urb(fc_usb->iso_urb[i]);
371 }
372
373 if (fc_usb->iso_buffer != NULL)
374 pci_free_consistent(NULL,fc_usb->buffer_size, fc_usb->iso_buffer, fc_usb->dma_addr);
375}
376
377static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb)
378{
379 u16 frame_size = fc_usb->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize;
380 int bufsize = B2C2_USB_NUM_ISO_URB * B2C2_USB_FRAMES_PER_ISO * frame_size,i,j,ret;
381 int buffer_offset = 0;
382
383 deb_ts("creating %d iso-urbs with %d frames each of %d bytes size = %d.\n",
384 B2C2_USB_NUM_ISO_URB, B2C2_USB_FRAMES_PER_ISO, frame_size,bufsize);
385
386 fc_usb->iso_buffer = pci_alloc_consistent(NULL,bufsize,&fc_usb->dma_addr);
387 if (fc_usb->iso_buffer == NULL)
388 return -ENOMEM;
389 memset(fc_usb->iso_buffer, 0, bufsize);
390 fc_usb->buffer_size = bufsize;
391
392 /* creating iso urbs */
393 for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++)
394 if (!(fc_usb->iso_urb[i] = usb_alloc_urb(B2C2_USB_FRAMES_PER_ISO,GFP_ATOMIC))) {
395 ret = -ENOMEM;
396 goto urb_error;
397 }
398 /* initialising and submitting iso urbs */
399 for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++) {
400 int frame_offset = 0;
401 struct urb *urb = fc_usb->iso_urb[i];
402 deb_ts("initializing and submitting urb no. %d (buf_offset: %d).\n",i,buffer_offset);
403
404 urb->dev = fc_usb->udev;
405 urb->context = fc_usb;
406 urb->complete = flexcop_usb_urb_complete;
407 urb->pipe = B2C2_USB_DATA_PIPE;
408 urb->transfer_flags = URB_ISO_ASAP;
409 urb->interval = 1;
410 urb->number_of_packets = B2C2_USB_FRAMES_PER_ISO;
411 urb->transfer_buffer_length = frame_size * B2C2_USB_FRAMES_PER_ISO;
412 urb->transfer_buffer = fc_usb->iso_buffer + buffer_offset;
413
414 buffer_offset += frame_size * B2C2_USB_FRAMES_PER_ISO;
415 for (j = 0; j < B2C2_USB_FRAMES_PER_ISO; j++) {
416 deb_ts("urb no: %d, frame: %d, frame_offset: %d\n",i,j,frame_offset);
417 urb->iso_frame_desc[j].offset = frame_offset;
418 urb->iso_frame_desc[j].length = frame_size;
419 frame_offset += frame_size;
420 }
421
422 if ((ret = usb_submit_urb(fc_usb->iso_urb[i],GFP_ATOMIC))) {
423 err("submitting urb %d failed with %d.",i,ret);
424 goto urb_error;
425 }
426 deb_ts("submitted urb no. %d.\n",i);
427 }
428
429/* SRAM */
430
431 flexcop_sram_set_dest(fc_usb->fc_dev,FC_SRAM_DEST_MEDIA | FC_SRAM_DEST_NET |
432 FC_SRAM_DEST_CAO | FC_SRAM_DEST_CAI, FC_SRAM_DEST_TARGET_WAN_USB);
433 flexcop_wan_set_speed(fc_usb->fc_dev,FC_WAN_SPEED_8MBITS);
434 flexcop_sram_ctrl(fc_usb->fc_dev,1,1,1);
435
436 ret = 0;
437 goto success;
438urb_error:
439 flexcop_usb_transfer_exit(fc_usb);
440success:
441 return ret;
442}
443
444static int flexcop_usb_init(struct flexcop_usb *fc_usb)
445{
446 /* use the alternate setting with the larges buffer */
447 usb_set_interface(fc_usb->udev,0,1);
448 switch (fc_usb->udev->speed) {
449 case USB_SPEED_LOW:
450 err("cannot handle USB speed because it is to sLOW.");
451 return -ENODEV;
452 break;
453 case USB_SPEED_FULL:
454 info("running at FULL speed.");
455 break;
456 case USB_SPEED_HIGH:
457 info("running at HIGH speed.");
458 break;
459 case USB_SPEED_UNKNOWN: /* fall through */
460 default:
461 err("cannot handle USB speed because it is unkown.");
462 return -ENODEV;
463 }
464 usb_set_intfdata(fc_usb->uintf, fc_usb);
465 return 0;
466}
467
468static void flexcop_usb_exit(struct flexcop_usb *fc_usb)
469{
470 usb_set_intfdata(fc_usb->uintf, NULL);
471}
472
473static int flexcop_usb_probe(struct usb_interface *intf,
474 const struct usb_device_id *id)
475{
476 struct usb_device *udev = interface_to_usbdev(intf);
477 struct flexcop_usb *fc_usb = NULL;
478 struct flexcop_device *fc = NULL;
479 int ret;
480
481 if ((fc = flexcop_device_kmalloc(sizeof(struct flexcop_usb))) == NULL) {
482 err("out of memory\n");
483 return -ENOMEM;
484 }
485
486/* general flexcop init */
487 fc_usb = fc->bus_specific;
488 fc_usb->fc_dev = fc;
489
490 fc->read_ibi_reg = flexcop_usb_read_ibi_reg;
491 fc->write_ibi_reg = flexcop_usb_write_ibi_reg;
492 fc->i2c_request = flexcop_usb_i2c_request;
493 fc->get_mac_addr = flexcop_usb_get_mac_addr;
494
495 fc->stream_control = flexcop_usb_stream_control;
496
497 fc->pid_filtering = 1;
498 fc->bus_type = FC_USB;
499
500 fc->dev = &udev->dev;
501 fc->owner = THIS_MODULE;
502
503/* bus specific part */
504 fc_usb->udev = udev;
505 fc_usb->uintf = intf;
506 if ((ret = flexcop_usb_init(fc_usb)) != 0)
507 goto err_kfree;
508
509/* init flexcop */
510 if ((ret = flexcop_device_initialize(fc)) != 0)
511 goto err_usb_exit;
512
513/* xfer init */
514 if ((ret = flexcop_usb_transfer_init(fc_usb)) != 0)
515 goto err_fc_exit;
516
517 info("%s successfully initialized and connected.",DRIVER_NAME);
518 ret = 0;
519 goto success;
520err_fc_exit:
521 flexcop_device_exit(fc);
522err_usb_exit:
523 flexcop_usb_exit(fc_usb);
524err_kfree:
525 flexcop_device_kfree(fc);
526success:
527 return ret;
528}
529
530static void flexcop_usb_disconnect(struct usb_interface *intf)
531{
532 struct flexcop_usb *fc_usb = usb_get_intfdata(intf);
533 flexcop_usb_transfer_exit(fc_usb);
534 flexcop_device_exit(fc_usb->fc_dev);
535 flexcop_usb_exit(fc_usb);
536 flexcop_device_kfree(fc_usb->fc_dev);
537 info("%s successfully deinitialized and disconnected.",DRIVER_NAME);
538}
539
540static struct usb_device_id flexcop_usb_table [] = {
541 { USB_DEVICE(0x0af7, 0x0101) },
542 { }
543};
544
545/* usb specific object needed to register this driver with the usb subsystem */
546static struct usb_driver flexcop_usb_driver = {
547 .owner = THIS_MODULE,
548 .name = "Technisat/B2C2 FlexCop II/IIb/III USB",
549 .probe = flexcop_usb_probe,
550 .disconnect = flexcop_usb_disconnect,
551 .id_table = flexcop_usb_table,
552};
553
554/* module stuff */
555static int __init flexcop_usb_module_init(void)
556{
557 int result;
558 if ((result = usb_register(&flexcop_usb_driver))) {
559 err("usb_register failed. (%d)",result);
560 return result;
561 }
562
563 return 0;
564}
565
566static void __exit flexcop_usb_module_exit(void)
567{
568 /* deregister this driver from the USB subsystem */
569 usb_deregister(&flexcop_usb_driver);
570}
571
572module_init(flexcop_usb_module_init);
573module_exit(flexcop_usb_module_exit);
574
575MODULE_AUTHOR(DRIVER_AUTHOR);
576MODULE_DESCRIPTION(DRIVER_NAME);
577MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.h b/drivers/media/dvb/b2c2/flexcop-usb.h
new file mode 100644
index 000000000000..630e647a2caa
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop-usb.h
@@ -0,0 +1,119 @@
1#ifndef __FLEXCOP_USB_H_INCLUDED__
2#define __FLEXCOP_USB_H_INCLUDED__
3
4#include <linux/usb.h>
5
6/* transfer parameters */
7#define B2C2_USB_FRAMES_PER_ISO 4
8#define B2C2_USB_NUM_ISO_URB 4
9
10#define B2C2_USB_CTRL_PIPE_IN usb_rcvctrlpipe(fc_usb->udev,0)
11#define B2C2_USB_CTRL_PIPE_OUT usb_sndctrlpipe(fc_usb->udev,0)
12#define B2C2_USB_DATA_PIPE usb_rcvisocpipe(fc_usb->udev,0x81)
13
14struct flexcop_usb {
15 struct usb_device *udev;
16 struct usb_interface *uintf;
17
18 u8 *iso_buffer;
19 int buffer_size;
20 dma_addr_t dma_addr;
21 struct urb *iso_urb[B2C2_USB_NUM_ISO_URB];
22
23 struct flexcop_device *fc_dev;
24
25 u8 tmp_buffer[1023+190];
26 int tmp_buffer_length;
27};
28
29#if 0
30/* request types TODO What is its use?*/
31typedef enum {
32
33/* something is wrong with this part
34 RTYPE_READ_DW = (1 << 6),
35 RTYPE_WRITE_DW_1 = (3 << 6),
36 RTYPE_READ_V8_MEMORY = (6 << 6),
37 RTYPE_WRITE_V8_MEMORY = (7 << 6),
38 RTYPE_WRITE_V8_FLASH = (8 << 6),
39 RTYPE_GENERIC = (9 << 6),
40*/
41} flexcop_usb_request_type_t;
42#endif
43
44/* request */
45typedef enum {
46 B2C2_USB_WRITE_V8_MEM = 0x04,
47 B2C2_USB_READ_V8_MEM = 0x05,
48 B2C2_USB_READ_REG = 0x08,
49 B2C2_USB_WRITE_REG = 0x0A,
50/* B2C2_USB_WRITEREGLO = 0x0A, */
51 B2C2_USB_WRITEREGHI = 0x0B,
52 B2C2_USB_FLASH_BLOCK = 0x10,
53 B2C2_USB_I2C_REQUEST = 0x11,
54 B2C2_USB_UTILITY = 0x12,
55} flexcop_usb_request_t;
56
57/* function definition for I2C_REQUEST */
58typedef enum {
59 USB_FUNC_I2C_WRITE = 0x01,
60 USB_FUNC_I2C_MULTIWRITE = 0x02,
61 USB_FUNC_I2C_READ = 0x03,
62 USB_FUNC_I2C_REPEATWRITE = 0x04,
63 USB_FUNC_GET_DESCRIPTOR = 0x05,
64 USB_FUNC_I2C_REPEATREAD = 0x06,
65/* DKT 020208 - add this to support special case of DiSEqC */
66 USB_FUNC_I2C_CHECKWRITE = 0x07,
67 USB_FUNC_I2C_CHECKRESULT = 0x08,
68} flexcop_usb_i2c_function_t;
69
70/*
71 * function definition for UTILITY request 0x12
72 * DKT 020304 - new utility function
73 */
74typedef enum {
75 UTILITY_SET_FILTER = 0x01,
76 UTILITY_DATA_ENABLE = 0x02,
77 UTILITY_FLEX_MULTIWRITE = 0x03,
78 UTILITY_SET_BUFFER_SIZE = 0x04,
79 UTILITY_FLEX_OPERATOR = 0x05,
80 UTILITY_FLEX_RESET300_START = 0x06,
81 UTILITY_FLEX_RESET300_STOP = 0x07,
82 UTILITY_FLEX_RESET300 = 0x08,
83 UTILITY_SET_ISO_SIZE = 0x09,
84 UTILITY_DATA_RESET = 0x0A,
85 UTILITY_GET_DATA_STATUS = 0x10,
86 UTILITY_GET_V8_REG = 0x11,
87/* DKT 020326 - add function for v1.14 */
88 UTILITY_SRAM_WRITE = 0x12,
89 UTILITY_SRAM_READ = 0x13,
90 UTILITY_SRAM_TESTFILL = 0x14,
91 UTILITY_SRAM_TESTSET = 0x15,
92 UTILITY_SRAM_TESTVERIFY = 0x16,
93} flexcop_usb_utility_function_t;
94
95#define B2C2_WAIT_FOR_OPERATION_RW 1*HZ /* 1 s */
96#define B2C2_WAIT_FOR_OPERATION_RDW 3*HZ /* 3 s */
97#define B2C2_WAIT_FOR_OPERATION_WDW 1*HZ /* 1 s */
98
99#define B2C2_WAIT_FOR_OPERATION_V8READ 3*HZ /* 3 s */
100#define B2C2_WAIT_FOR_OPERATION_V8WRITE 3*HZ /* 3 s */
101#define B2C2_WAIT_FOR_OPERATION_V8FLASH 3*HZ /* 3 s */
102
103typedef enum {
104 V8_MEMORY_PAGE_DVB_CI = 0x20,
105 V8_MEMORY_PAGE_DVB_DS = 0x40,
106 V8_MEMORY_PAGE_MULTI2 = 0x60,
107 V8_MEMORY_PAGE_FLASH = 0x80
108} flexcop_usb_mem_page_t;
109
110#define V8_MEMORY_EXTENDED (1 << 15)
111
112#define USB_MEM_READ_MAX 32
113#define USB_MEM_WRITE_MAX 1
114#define USB_FLASH_MAX 8
115
116#define V8_MEMORY_PAGE_SIZE 0x8000 // 32K
117#define V8_MEMORY_PAGE_MASK 0x7FFF
118
119#endif
diff --git a/drivers/media/dvb/b2c2/flexcop.c b/drivers/media/dvb/b2c2/flexcop.c
new file mode 100644
index 000000000000..8b5d14dd36e3
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop.c
@@ -0,0 +1,286 @@
1/*
2 * flexcop.c - driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * Copyright (C) 2004-5 Patrick Boettcher <patrick.boettcher@desy.de>
5 *
6 * based on the skystar2-driver
7 * Copyright (C) 2003 Vadim Catana, skystar@moldova.cc
8 *
9 * Acknowledgements:
10 * John Jurrius from BBTI, Inc. for extensive support with
11 * code examples and data books
12 *
13 * Bjarne Steinsbo, bjarne at steinsbo.com (some ideas for rewriting)
14 *
15 * Contributions to the skystar2-driver have been done by
16 * Vincenzo Di Massa, hawk.it at tiscalinet.it (several DiSEqC fixes)
17 * Roberto Ragusa, r.ragusa at libero.it (polishing, restyling the code)
18 * Niklas Peinecke, peinecke at gdv.uni-hannover.de (hardware pid/mac filtering)
19 *
20 *
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU Lesser General Public License
23 * as published by the Free Software Foundation; either version 2.1
24 * of the License, or (at your option) any later version.
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
30 *
31 * You should have received a copy of the GNU Lesser General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 */
35
36#include "flexcop.h"
37
38#define DRIVER_NAME "B2C2 FlexcopII/II(b)/III digital TV receiver chip"
39#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de"
40
41#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
42#define DEBSTATUS ""
43#else
44#define DEBSTATUS " (debugging is not enabled)"
45#endif
46
47int b2c2_flexcop_debug;
48module_param_named(debug, b2c2_flexcop_debug, int, 0644);
49MODULE_PARM_DESC(debug, "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram (|-able))." DEBSTATUS);
50#undef DEBSTATUS
51
52/* global zero for ibi values */
53flexcop_ibi_value ibi_zero;
54
55static int flexcop_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
56{
57 struct flexcop_device *fc = dvbdmxfeed->demux->priv;
58 return flexcop_pid_feed_control(fc,dvbdmxfeed,1);
59}
60
61static int flexcop_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
62{
63 struct flexcop_device *fc = dvbdmxfeed->demux->priv;
64 return flexcop_pid_feed_control(fc,dvbdmxfeed,0);
65}
66
67static int flexcop_dvb_init(struct flexcop_device *fc)
68{
69 int ret;
70 if ((ret = dvb_register_adapter(&fc->dvb_adapter,"FlexCop Digital TV device",fc->owner)) < 0) {
71 err("error registering DVB adapter");
72 return ret;
73 }
74 fc->dvb_adapter.priv = fc;
75
76 fc->demux.dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING);
77 fc->demux.priv = fc;
78
79 fc->demux.filternum = fc->demux.feednum = FC_MAX_FEED;
80
81 fc->demux.start_feed = flexcop_dvb_start_feed;
82 fc->demux.stop_feed = flexcop_dvb_stop_feed;
83 fc->demux.write_to_decoder = NULL;
84
85 if ((ret = dvb_dmx_init(&fc->demux)) < 0) {
86 err("dvb_dmx failed: error %d",ret);
87 goto err_dmx;
88 }
89
90 fc->hw_frontend.source = DMX_FRONTEND_0;
91
92 fc->dmxdev.filternum = fc->demux.feednum;
93 fc->dmxdev.demux = &fc->demux.dmx;
94 fc->dmxdev.capabilities = 0;
95 if ((ret = dvb_dmxdev_init(&fc->dmxdev, &fc->dvb_adapter)) < 0) {
96 err("dvb_dmxdev_init failed: error %d",ret);
97 goto err_dmx_dev;
98 }
99
100 if ((ret = fc->demux.dmx.add_frontend(&fc->demux.dmx, &fc->hw_frontend)) < 0) {
101 err("adding hw_frontend to dmx failed: error %d",ret);
102 goto err_dmx_add_hw_frontend;
103 }
104
105 fc->mem_frontend.source = DMX_MEMORY_FE;
106 if ((ret = fc->demux.dmx.add_frontend(&fc->demux.dmx, &fc->mem_frontend)) < 0) {
107 err("adding mem_frontend to dmx failed: error %d",ret);
108 goto err_dmx_add_mem_frontend;
109 }
110
111 if ((ret = fc->demux.dmx.connect_frontend(&fc->demux.dmx, &fc->hw_frontend)) < 0) {
112 err("connect frontend failed: error %d",ret);
113 goto err_connect_frontend;
114 }
115
116 dvb_net_init(&fc->dvb_adapter, &fc->dvbnet, &fc->demux.dmx);
117
118 fc->init_state |= FC_STATE_DVB_INIT;
119 goto success;
120
121err_connect_frontend:
122 fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->mem_frontend);
123err_dmx_add_mem_frontend:
124 fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->hw_frontend);
125err_dmx_add_hw_frontend:
126 dvb_dmxdev_release(&fc->dmxdev);
127err_dmx_dev:
128 dvb_dmx_release(&fc->demux);
129err_dmx:
130 dvb_unregister_adapter(&fc->dvb_adapter);
131 return ret;
132
133success:
134 return 0;
135}
136
137static void flexcop_dvb_exit(struct flexcop_device *fc)
138{
139 if (fc->init_state & FC_STATE_DVB_INIT) {
140 dvb_net_release(&fc->dvbnet);
141
142 fc->demux.dmx.close(&fc->demux.dmx);
143 fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->mem_frontend);
144 fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->hw_frontend);
145 dvb_dmxdev_release(&fc->dmxdev);
146 dvb_dmx_release(&fc->demux);
147 dvb_unregister_adapter(&fc->dvb_adapter);
148
149 deb_info("deinitialized dvb stuff\n");
150 }
151 fc->init_state &= ~FC_STATE_DVB_INIT;
152}
153
154/* these methods are necessary to achieve the long-term-goal of hiding the
155 * struct flexcop_device from the bus-parts */
156void flexcop_pass_dmx_data(struct flexcop_device *fc, u8 *buf, u32 len)
157{
158 dvb_dmx_swfilter(&fc->demux, buf, len);
159}
160EXPORT_SYMBOL(flexcop_pass_dmx_data);
161
162void flexcop_pass_dmx_packets(struct flexcop_device *fc, u8 *buf, u32 no)
163{
164 dvb_dmx_swfilter_packets(&fc->demux, buf, no);
165}
166EXPORT_SYMBOL(flexcop_pass_dmx_packets);
167
168static void flexcop_reset(struct flexcop_device *fc)
169{
170 flexcop_ibi_value v210,v204;
171
172/* reset the flexcop itself */
173 fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
174
175 v210.raw = 0;
176 v210.sw_reset_210.reset_blocks = 0xff;
177 v210.sw_reset_210.Block_reset_enable = 0xb2;
178 fc->write_ibi_reg(fc,sw_reset_210,v210);
179
180/* reset the periphical devices */
181
182 v204 = fc->read_ibi_reg(fc,misc_204);
183 v204.misc_204.Per_reset_sig = 0;
184 fc->write_ibi_reg(fc,misc_204,v204);
185 v204.misc_204.Per_reset_sig = 1;
186 fc->write_ibi_reg(fc,misc_204,v204);
187}
188
189struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len)
190{
191 void *bus;
192 struct flexcop_device *fc = kmalloc(sizeof(struct flexcop_device), GFP_KERNEL);
193 if (!fc) {
194 err("no memory");
195 return NULL;
196 }
197 memset(fc, 0, sizeof(struct flexcop_device));
198
199 bus = kmalloc(bus_specific_len, GFP_KERNEL);
200 if (!bus) {
201 err("no memory");
202 kfree(fc);
203 return NULL;
204 }
205 memset(bus, 0, bus_specific_len);
206
207 fc->bus_specific = bus;
208
209 return fc;
210}
211EXPORT_SYMBOL(flexcop_device_kmalloc);
212
213void flexcop_device_kfree(struct flexcop_device *fc)
214{
215 kfree(fc->bus_specific);
216 kfree(fc);
217}
218EXPORT_SYMBOL(flexcop_device_kfree);
219
220int flexcop_device_initialize(struct flexcop_device *fc)
221{
222 int ret;
223 ibi_zero.raw = 0;
224
225 flexcop_reset(fc);
226 flexcop_determine_revision(fc);
227 flexcop_sram_init(fc);
228 flexcop_hw_filter_init(fc);
229
230 flexcop_smc_ctrl(fc, 0);
231
232 if ((ret = flexcop_dvb_init(fc)))
233 goto error;
234
235 /* do the MAC address reading after initializing the dvb_adapter */
236 if (fc->get_mac_addr(fc, 0) == 0) {
237 u8 *b = fc->dvb_adapter.proposed_mac;
238 info("MAC address = %02x:%02x:%02x:%02x:%02x:%02x", b[0],b[1],b[2],b[3],b[4],b[5]);
239 flexcop_set_mac_filter(fc,b);
240 flexcop_mac_filter_ctrl(fc,1);
241 } else
242 warn("reading of MAC address failed.\n");
243
244
245 if ((ret = flexcop_i2c_init(fc)))
246 goto error;
247
248 if ((ret = flexcop_frontend_init(fc)))
249 goto error;
250
251 flexcop_device_name(fc,"initialization of","complete");
252
253 ret = 0;
254 goto success;
255error:
256 flexcop_device_exit(fc);
257success:
258 return ret;
259}
260EXPORT_SYMBOL(flexcop_device_initialize);
261
262void flexcop_device_exit(struct flexcop_device *fc)
263{
264 flexcop_frontend_exit(fc);
265 flexcop_i2c_exit(fc);
266 flexcop_dvb_exit(fc);
267}
268EXPORT_SYMBOL(flexcop_device_exit);
269
270static int flexcop_module_init(void)
271{
272 info(DRIVER_NAME " loaded successfully");
273 return 0;
274}
275
276static void flexcop_module_cleanup(void)
277{
278 info(DRIVER_NAME " unloaded successfully");
279}
280
281module_init(flexcop_module_init);
282module_exit(flexcop_module_cleanup);
283
284MODULE_AUTHOR(DRIVER_AUTHOR);
285MODULE_DESCRIPTION(DRIVER_NAME);
286MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/b2c2/flexcop.h b/drivers/media/dvb/b2c2/flexcop.h
new file mode 100644
index 000000000000..caa343a97bdc
--- /dev/null
+++ b/drivers/media/dvb/b2c2/flexcop.h
@@ -0,0 +1,30 @@
1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop.h - private header file for all flexcop-chip-source files.
5 *
6 * see flexcop.c for copyright information.
7 */
8#ifndef __FLEXCOP_H__
9#define __FLEXCOP_H___
10
11#define FC_LOG_PREFIX "b2c2-flexcop"
12#include "flexcop-common.h"
13
14extern int b2c2_flexcop_debug;
15
16/* debug */
17#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
18#define dprintk(level,args...) \
19 do { if ((b2c2_flexcop_debug & level)) printk(args); } while (0)
20#else
21#define dprintk(level,args...)
22#endif
23
24#define deb_info(args...) dprintk(0x01,args)
25#define deb_tuner(args...) dprintk(0x02,args)
26#define deb_i2c(args...) dprintk(0x04,args)
27#define deb_ts(args...) dprintk(0x08,args)
28#define deb_sram(args...) dprintk(0x10,args)
29
30#endif
diff --git a/drivers/media/dvb/b2c2/skystar2.c b/drivers/media/dvb/b2c2/skystar2.c
index 336c178fcd5f..acbc4c34f72a 100644
--- a/drivers/media/dvb/b2c2/skystar2.c
+++ b/drivers/media/dvb/b2c2/skystar2.c
@@ -97,7 +97,7 @@ struct adapter {
97 u8 mac_addr[8]; 97 u8 mac_addr[8];
98 u32 dw_sram_type; 98 u32 dw_sram_type;
99 99
100 struct dvb_adapter *dvb_adapter; 100 struct dvb_adapter dvb_adapter;
101 struct dvb_demux demux; 101 struct dvb_demux demux;
102 struct dmxdev dmxdev; 102 struct dmxdev dmxdev;
103 struct dmx_frontend hw_frontend; 103 struct dmx_frontend hw_frontend;
@@ -2461,7 +2461,7 @@ static void frontend_init(struct adapter *skystar2)
2461 skystar2->pdev->subsystem_vendor, 2461 skystar2->pdev->subsystem_vendor,
2462 skystar2->pdev->subsystem_device); 2462 skystar2->pdev->subsystem_device);
2463 } else { 2463 } else {
2464 if (dvb_register_frontend(skystar2->dvb_adapter, skystar2->fe)) { 2464 if (dvb_register_frontend(&skystar2->dvb_adapter, skystar2->fe)) {
2465 printk("skystar2: Frontend registration failed!\n"); 2465 printk("skystar2: Frontend registration failed!\n");
2466 if (skystar2->fe->ops->release) 2466 if (skystar2->fe->ops->release)
2467 skystar2->fe->ops->release(skystar2->fe); 2467 skystar2->fe->ops->release(skystar2->fe);
@@ -2486,17 +2486,17 @@ static int skystar2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2486 if (ret < 0) 2486 if (ret < 0)
2487 goto out; 2487 goto out;
2488 2488
2489 ret = dvb_register_adapter(&dvb_adapter, skystar2_pci_driver.name, 2489 adapter = pci_get_drvdata(pdev);
2490 dvb_adapter = &adapter->dvb_adapter;
2491
2492 ret = dvb_register_adapter(dvb_adapter, skystar2_pci_driver.name,
2490 THIS_MODULE); 2493 THIS_MODULE);
2491 if (ret < 0) { 2494 if (ret < 0) {
2492 printk("%s: Error registering DVB adapter\n", __FUNCTION__); 2495 printk("%s: Error registering DVB adapter\n", __FUNCTION__);
2493 goto err_halt; 2496 goto err_halt;
2494 } 2497 }
2495 2498
2496 adapter = pci_get_drvdata(pdev);
2497
2498 dvb_adapter->priv = adapter; 2499 dvb_adapter->priv = adapter;
2499 adapter->dvb_adapter = dvb_adapter;
2500 2500
2501 2501
2502 init_MUTEX(&adapter->i2c_sem); 2502 init_MUTEX(&adapter->i2c_sem);
@@ -2541,7 +2541,7 @@ static int skystar2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2541 adapter->dmxdev.demux = dmx; 2541 adapter->dmxdev.demux = dmx;
2542 adapter->dmxdev.capabilities = 0; 2542 adapter->dmxdev.capabilities = 0;
2543 2543
2544 ret = dvb_dmxdev_init(&adapter->dmxdev, adapter->dvb_adapter); 2544 ret = dvb_dmxdev_init(&adapter->dmxdev, &adapter->dvb_adapter);
2545 if (ret < 0) 2545 if (ret < 0)
2546 goto err_dmx_release; 2546 goto err_dmx_release;
2547 2547
@@ -2559,7 +2559,7 @@ static int skystar2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2559 if (ret < 0) 2559 if (ret < 0)
2560 goto err_remove_mem_frontend; 2560 goto err_remove_mem_frontend;
2561 2561
2562 dvb_net_init(adapter->dvb_adapter, &adapter->dvbnet, &dvbdemux->dmx); 2562 dvb_net_init(&adapter->dvb_adapter, &adapter->dvbnet, &dvbdemux->dmx);
2563 2563
2564 frontend_init(adapter); 2564 frontend_init(adapter);
2565out: 2565out:
@@ -2576,7 +2576,7 @@ err_dmx_release:
2576err_i2c_del: 2576err_i2c_del:
2577 i2c_del_adapter(&adapter->i2c_adap); 2577 i2c_del_adapter(&adapter->i2c_adap);
2578err_dvb_unregister: 2578err_dvb_unregister:
2579 dvb_unregister_adapter(adapter->dvb_adapter); 2579 dvb_unregister_adapter(&adapter->dvb_adapter);
2580err_halt: 2580err_halt:
2581 driver_halt(pdev); 2581 driver_halt(pdev);
2582 goto out; 2582 goto out;
@@ -2605,7 +2605,7 @@ static void skystar2_remove(struct pci_dev *pdev)
2605 if (adapter->fe != NULL) 2605 if (adapter->fe != NULL)
2606 dvb_unregister_frontend(adapter->fe); 2606 dvb_unregister_frontend(adapter->fe);
2607 2607
2608 dvb_unregister_adapter(adapter->dvb_adapter); 2608 dvb_unregister_adapter(&adapter->dvb_adapter);
2609 2609
2610 i2c_del_adapter(&adapter->i2c_adap); 2610 i2c_del_adapter(&adapter->i2c_adap);
2611 2611
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig
index e7d11e0667a8..b12545f093f8 100644
--- a/drivers/media/dvb/bt8xx/Kconfig
+++ b/drivers/media/dvb/bt8xx/Kconfig
@@ -11,9 +11,8 @@ config DVB_BT8XX
11 the Nebula cards, the Pinnacle PCTV cards, the Twinhan DST cards and 11 the Nebula cards, the Pinnacle PCTV cards, the Twinhan DST cards and
12 pcHDTV HD2000 cards. 12 pcHDTV HD2000 cards.
13 13
14 Since these cards have no MPEG decoder onboard, they transmit 14 Since these cards have no MPEG decoder onboard, they transmit
15 only compressed MPEG data over the PCI bus, so you need 15 only compressed MPEG data over the PCI bus, so you need
16 an external software decoder to watch TV on your computer. 16 an external software decoder to watch TV on your computer.
17 17
18 Say Y if you own such a device and want to use it. 18 Say Y if you own such a device and want to use it.
19
diff --git a/drivers/media/dvb/bt8xx/Makefile b/drivers/media/dvb/bt8xx/Makefile
index 9da8604b9e18..d188e4c670b5 100644
--- a/drivers/media/dvb/bt8xx/Makefile
+++ b/drivers/media/dvb/bt8xx/Makefile
@@ -1,5 +1,3 @@
1 1obj-$(CONFIG_DVB_BT8XX) += bt878.o dvb-bt8xx.o dst.o dst_ca.o
2obj-$(CONFIG_DVB_BT8XX) += bt878.o dvb-bt8xx.o dst.o
3 2
4EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/video -Idrivers/media/dvb/frontends 3EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/video -Idrivers/media/dvb/frontends
5
diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c
index 213ff7902024..3c5a8e273c4a 100644
--- a/drivers/media/dvb/bt8xx/bt878.c
+++ b/drivers/media/dvb/bt8xx/bt878.c
@@ -4,27 +4,27 @@
4 * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> 4 * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de>
5 * 5 *
6 * large parts based on the bttv driver 6 * large parts based on the bttv driver
7 * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) 7 * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@metzlerbros.de)
8 * & Marcus Metzler (mocm@thp.uni-koeln.de) 8 * & Marcus Metzler (mocm@metzlerbros.de)
9 * (c) 1999,2000 Gerd Knorr <kraxel@goldbach.in-berlin.de> 9 * (c) 1999,2000 Gerd Knorr <kraxel@goldbach.in-berlin.de>
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License 12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2 13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version. 14 * of the License, or (at your option) any later version.
15 * 15 *
16 16
17 * 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,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 22
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 26 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
27 * 27 *
28 */ 28 */
29 29
30#include <linux/module.h> 30#include <linux/module.h>
@@ -58,7 +58,7 @@ module_param_named(verbose, bt878_verbose, int, 0444);
58MODULE_PARM_DESC(verbose, 58MODULE_PARM_DESC(verbose,
59 "verbose startup messages, default is 1 (yes)"); 59 "verbose startup messages, default is 1 (yes)");
60module_param_named(debug, bt878_debug, int, 0644); 60module_param_named(debug, bt878_debug, int, 0644);
61MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); 61MODULE_PARM_DESC(debug, "Turn on/off debugging, default is 0 (off).");
62 62
63int bt878_num; 63int bt878_num;
64struct bt878 bt878[BT878_MAX]; 64struct bt878 bt878[BT878_MAX];
@@ -128,21 +128,21 @@ static int bt878_mem_alloc(struct bt878 *bt)
128} 128}
129 129
130/* RISC instructions */ 130/* RISC instructions */
131#define RISC_WRITE (0x01 << 28) 131#define RISC_WRITE (0x01 << 28)
132#define RISC_JUMP (0x07 << 28) 132#define RISC_JUMP (0x07 << 28)
133#define RISC_SYNC (0x08 << 28) 133#define RISC_SYNC (0x08 << 28)
134 134
135/* RISC bits */ 135/* RISC bits */
136#define RISC_WR_SOL (1 << 27) 136#define RISC_WR_SOL (1 << 27)
137#define RISC_WR_EOL (1 << 26) 137#define RISC_WR_EOL (1 << 26)
138#define RISC_IRQ (1 << 24) 138#define RISC_IRQ (1 << 24)
139#define RISC_STATUS(status) ((((~status) & 0x0F) << 20) | ((status & 0x0F) << 16)) 139#define RISC_STATUS(status) ((((~status) & 0x0F) << 20) | ((status & 0x0F) << 16))
140#define RISC_SYNC_RESYNC (1 << 15) 140#define RISC_SYNC_RESYNC (1 << 15)
141#define RISC_SYNC_FM1 0x06 141#define RISC_SYNC_FM1 0x06
142#define RISC_SYNC_VRO 0x0C 142#define RISC_SYNC_VRO 0x0C
143 143
144#define RISC_FLUSH() bt->risc_pos = 0 144#define RISC_FLUSH() bt->risc_pos = 0
145#define RISC_INSTR(instr) bt->risc_cpu[bt->risc_pos++] = cpu_to_le32(instr) 145#define RISC_INSTR(instr) bt->risc_cpu[bt->risc_pos++] = cpu_to_le32(instr)
146 146
147static int bt878_make_risc(struct bt878 *bt) 147static int bt878_make_risc(struct bt878 *bt)
148{ 148{
@@ -173,7 +173,7 @@ static void bt878_risc_program(struct bt878 *bt, u32 op_sync_orin)
173 RISC_INSTR(RISC_SYNC | RISC_SYNC_FM1 | op_sync_orin); 173 RISC_INSTR(RISC_SYNC | RISC_SYNC_FM1 | op_sync_orin);
174 RISC_INSTR(0); 174 RISC_INSTR(0);
175 175
176 dprintk("bt878: risc len lines %u, bytes per line %u\n", 176 dprintk("bt878: risc len lines %u, bytes per line %u\n",
177 bt->line_count, bt->line_bytes); 177 bt->line_count, bt->line_bytes);
178 for (line = 0; line < bt->line_count; line++) { 178 for (line = 0; line < bt->line_count; line++) {
179 // At the beginning of every block we issue an IRQ with previous (finished) block number set 179 // At the beginning of every block we issue an IRQ with previous (finished) block number set
@@ -228,14 +228,14 @@ void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin,
228 * Hacked for DST to: 228 * Hacked for DST to:
229 * SCERR | OCERR | FDSR | FTRGT | FBUS | RISCI 229 * SCERR | OCERR | FDSR | FTRGT | FBUS | RISCI
230 */ 230 */
231 int_mask = BT878_ASCERR | BT878_AOCERR | BT878_APABORT | 231 int_mask = BT878_ASCERR | BT878_AOCERR | BT878_APABORT |
232 BT878_ARIPERR | BT878_APPERR | BT878_AFDSR | BT878_AFTRGT | 232 BT878_ARIPERR | BT878_APPERR | BT878_AFDSR | BT878_AFTRGT |
233 BT878_AFBUS | BT878_ARISCI; 233 BT878_AFBUS | BT878_ARISCI;
234 234
235 235
236 /* ignore pesky bits */ 236 /* ignore pesky bits */
237 int_mask &= ~irq_err_ignore; 237 int_mask &= ~irq_err_ignore;
238 238
239 btwrite(int_mask, BT878_AINT_MASK); 239 btwrite(int_mask, BT878_AINT_MASK);
240 btwrite(controlreg, BT878_AGPIO_DMA_CTL); 240 btwrite(controlreg, BT878_AGPIO_DMA_CTL);
241} 241}
@@ -461,9 +461,9 @@ static int __devinit bt878_probe(struct pci_dev *dev,
461 pci_set_drvdata(dev, bt); 461 pci_set_drvdata(dev, bt);
462 462
463/* if(init_bt878(btv) < 0) { 463/* if(init_bt878(btv) < 0) {
464 bt878_remove(dev); 464 bt878_remove(dev);
465 return -EIO; 465 return -EIO;
466 } 466 }
467*/ 467*/
468 468
469 if ((result = bt878_mem_alloc(bt))) { 469 if ((result = bt878_mem_alloc(bt))) {
@@ -536,10 +536,10 @@ static struct pci_device_id bt878_pci_tbl[] __devinitdata = {
536MODULE_DEVICE_TABLE(pci, bt878_pci_tbl); 536MODULE_DEVICE_TABLE(pci, bt878_pci_tbl);
537 537
538static struct pci_driver bt878_pci_driver = { 538static struct pci_driver bt878_pci_driver = {
539 .name = "bt878", 539 .name = "bt878",
540 .id_table = bt878_pci_tbl, 540 .id_table = bt878_pci_tbl,
541 .probe = bt878_probe, 541 .probe = bt878_probe,
542 .remove = bt878_remove, 542 .remove = bt878_remove,
543}; 543};
544 544
545static int bt878_pci_driver_registered = 0; 545static int bt878_pci_driver_registered = 0;
@@ -558,7 +558,7 @@ static int bt878_init_module(void)
558 (BT878_VERSION_CODE >> 8) & 0xff, 558 (BT878_VERSION_CODE >> 8) & 0xff,
559 BT878_VERSION_CODE & 0xff); 559 BT878_VERSION_CODE & 0xff);
560/* 560/*
561 bt878_check_chipset(); 561 bt878_check_chipset();
562*/ 562*/
563 /* later we register inside of bt878_find_audio_dma() 563 /* later we register inside of bt878_find_audio_dma()
564 * because we may want to ignore certain cards */ 564 * because we may want to ignore certain cards */
diff --git a/drivers/media/dvb/bt8xx/bt878.h b/drivers/media/dvb/bt8xx/bt878.h
index e1b9809d1b08..837623f7fcdf 100644
--- a/drivers/media/dvb/bt8xx/bt878.h
+++ b/drivers/media/dvb/bt8xx/bt878.h
@@ -1,4 +1,4 @@
1/* 1/*
2 bt878.h - Bt878 audio module (register offsets) 2 bt878.h - Bt878 audio module (register offsets)
3 3
4 Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> 4 Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de>
@@ -120,14 +120,14 @@ struct bt878 {
120 u32 risc_pos; 120 u32 risc_pos;
121 121
122 struct tasklet_struct tasklet; 122 struct tasklet_struct tasklet;
123 int shutdown; 123 int shutdown;
124}; 124};
125 125
126extern struct bt878 bt878[BT878_MAX]; 126extern struct bt878 bt878[BT878_MAX];
127 127
128void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin, 128void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin,
129 u32 irq_err_ignore); 129 u32 irq_err_ignore);
130void bt878_stop(struct bt878 *bt); 130void bt878_stop(struct bt878 *bt);
131 131
132#if defined(__powerpc__) /* big-endian */ 132#if defined(__powerpc__) /* big-endian */
133extern __inline__ void io_st_le32(volatile unsigned __iomem *addr, unsigned val) 133extern __inline__ void io_st_le32(volatile unsigned __iomem *addr, unsigned val)
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index eac83768dfd0..d047e349d706 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -1,25 +1,25 @@
1/* 1/*
2 Frontend-driver for TwinHan DST Frontend
3 2
4 Copyright (C) 2003 Jamie Honan 3 Frontend/Card driver for TwinHan DST Frontend
4 Copyright (C) 2003 Jamie Honan
5 Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com)
5 6
6 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
7 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
8 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 10 (at your option) any later version.
10 11
11 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 15 GNU General Public License for more details.
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 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.
21*/ 20*/
22 21
22
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/init.h> 25#include <linux/init.h>
@@ -31,59 +31,22 @@
31 31
32#include "dvb_frontend.h" 32#include "dvb_frontend.h"
33#include "dst_priv.h" 33#include "dst_priv.h"
34#include "dst.h" 34#include "dst_common.h"
35
36struct dst_state {
37
38 struct i2c_adapter* i2c;
39
40 struct bt878* bt;
41
42 struct dvb_frontend_ops ops;
43
44 /* configuration settings */
45 const struct dst_config* config;
46
47 struct dvb_frontend frontend;
48
49 /* private demodulator data */
50 u8 tx_tuna[10];
51 u8 rx_tuna[10];
52 u8 rxbuffer[10];
53 u8 diseq_flags;
54 u8 dst_type;
55 u32 type_flags;
56 u32 frequency; /* intermediate frequency in kHz for QPSK */
57 fe_spectral_inversion_t inversion;
58 u32 symbol_rate; /* symbol rate in Symbols per second */
59 fe_code_rate_t fec;
60 fe_sec_voltage_t voltage;
61 fe_sec_tone_mode_t tone;
62 u32 decode_freq;
63 u8 decode_lock;
64 u16 decode_strength;
65 u16 decode_snr;
66 unsigned long cur_jiff;
67 u8 k22;
68 fe_bandwidth_t bandwidth;
69};
70 35
71static unsigned int dst_verbose = 0;
72module_param(dst_verbose, int, 0644);
73MODULE_PARM_DESC(dst_verbose, "verbose startup messages, default is 1 (yes)");
74static unsigned int dst_debug = 0;
75module_param(dst_debug, int, 0644);
76MODULE_PARM_DESC(dst_debug, "debug messages, default is 0 (no)");
77 36
78#define dprintk if (dst_debug) printk 37static unsigned int verbose = 1;
38module_param(verbose, int, 0644);
39MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
79 40
80#define DST_TYPE_IS_SAT 0 41static unsigned int debug = 1;
81#define DST_TYPE_IS_TERR 1 42module_param(debug, int, 0644);
82#define DST_TYPE_IS_CABLE 2 43MODULE_PARM_DESC(debug, "debug messages, default is 0 (yes)");
83 44
84#define DST_TYPE_HAS_NEWTUNE 1 45static unsigned int dst_addons;
85#define DST_TYPE_HAS_TS204 2 46module_param(dst_addons, int, 0644);
86#define DST_TYPE_HAS_SYMDIV 4 47MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)");
48
49#define dprintk if (debug) printk
87 50
88#define HAS_LOCK 1 51#define HAS_LOCK 1
89#define ATTEMPT_TUNE 2 52#define ATTEMPT_TUNE 2
@@ -97,7 +60,7 @@ static void dst_packsize(struct dst_state* state, int psize)
97 bt878_device_control(state->bt, DST_IG_TS, &bits); 60 bt878_device_control(state->bt, DST_IG_TS, &bits);
98} 61}
99 62
100static int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh) 63int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay)
101{ 64{
102 union dst_gpio_packet enb; 65 union dst_gpio_packet enb;
103 union dst_gpio_packet bits; 66 union dst_gpio_packet bits;
@@ -105,26 +68,33 @@ static int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhig
105 68
106 enb.enb.mask = mask; 69 enb.enb.mask = mask;
107 enb.enb.enable = enbb; 70 enb.enb.enable = enbb;
71 if (verbose > 4)
72 dprintk("%s: mask=[%04x], enbb=[%04x], outhigh=[%04x]\n", __FUNCTION__, mask, enbb, outhigh);
73
108 if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) { 74 if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) {
109 dprintk("%s: dst_gpio_enb error (err == %i, mask == 0x%02x, enb == 0x%02x)\n", __FUNCTION__, err, mask, enbb); 75 dprintk("%s: dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)\n", __FUNCTION__, err, mask, enbb);
110 return -EREMOTEIO; 76 return -EREMOTEIO;
111 } 77 }
112 78 udelay(1000);
113 /* because complete disabling means no output, no need to do output packet */ 79 /* because complete disabling means no output, no need to do output packet */
114 if (enbb == 0) 80 if (enbb == 0)
115 return 0; 81 return 0;
116 82
83 if (delay)
84 msleep(10);
85
117 bits.outp.mask = enbb; 86 bits.outp.mask = enbb;
118 bits.outp.highvals = outhigh; 87 bits.outp.highvals = outhigh;
119 88
120 if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) { 89 if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) {
121 dprintk("%s: dst_gpio_outb error (err == %i, enbb == 0x%02x, outhigh == 0x%02x)\n", __FUNCTION__, err, enbb, outhigh); 90 dprintk("%s: dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)\n", __FUNCTION__, err, enbb, outhigh);
122 return -EREMOTEIO; 91 return -EREMOTEIO;
123 } 92 }
124 return 0; 93 return 0;
125} 94}
95EXPORT_SYMBOL(dst_gpio_outb);
126 96
127static int dst_gpio_inb(struct dst_state *state, u8 * result) 97int dst_gpio_inb(struct dst_state *state, u8 * result)
128{ 98{
129 union dst_gpio_packet rd_packet; 99 union dst_gpio_packet rd_packet;
130 int err; 100 int err;
@@ -139,143 +109,225 @@ static int dst_gpio_inb(struct dst_state *state, u8 * result)
139 *result = (u8) rd_packet.rd.value; 109 *result = (u8) rd_packet.rd.value;
140 return 0; 110 return 0;
141} 111}
112EXPORT_SYMBOL(dst_gpio_inb);
142 113
143#define DST_I2C_ENABLE 1 114int rdc_reset_state(struct dst_state *state)
144#define DST_8820 2
145
146static int dst_reset8820(struct dst_state *state)
147{ 115{
148 int retval; 116 if (verbose > 1)
149 /* pull 8820 gpio pin low, wait, high, wait, then low */ 117 dprintk("%s: Resetting state machine\n", __FUNCTION__);
150 // dprintk ("%s: reset 8820\n", __FUNCTION__); 118
151 retval = dst_gpio_outb(state, DST_8820, DST_8820, 0); 119 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) {
152 if (retval < 0) 120 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
153 return retval; 121 return -1;
122 }
123
154 msleep(10); 124 msleep(10);
155 retval = dst_gpio_outb(state, DST_8820, DST_8820, DST_8820); 125
156 if (retval < 0) 126 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) {
157 return retval; 127 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
158 /* wait for more feedback on what works here * 128 msleep(10);
159 msleep(10); 129 return -1;
160 retval = dst_gpio_outb(dst, DST_8820, DST_8820, 0); 130 }
161 if (retval < 0) 131
162 return retval;
163 */
164 return 0; 132 return 0;
165} 133}
134EXPORT_SYMBOL(rdc_reset_state);
166 135
167static int dst_i2c_enable(struct dst_state *state) 136int rdc_8820_reset(struct dst_state *state)
168{ 137{
169 int retval; 138 if (verbose > 1)
170 /* pull I2C enable gpio pin low, wait */ 139 dprintk("%s: Resetting DST\n", __FUNCTION__);
171 // dprintk ("%s: i2c enable\n", __FUNCTION__); 140
172 retval = dst_gpio_outb(state, ~0, DST_I2C_ENABLE, 0); 141 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) {
173 if (retval < 0) 142 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
174 return retval; 143 return -1;
175 // dprintk ("%s: i2c enable delay\n", __FUNCTION__); 144 }
176 msleep(33); 145 udelay(1000);
146 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) {
147 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
148 return -1;
149 }
150
177 return 0; 151 return 0;
178} 152}
153EXPORT_SYMBOL(rdc_8820_reset);
179 154
180static int dst_i2c_disable(struct dst_state *state) 155int dst_pio_enable(struct dst_state *state)
181{ 156{
182 int retval; 157 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) {
183 /* release I2C enable gpio pin, wait */ 158 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
184 // dprintk ("%s: i2c disable\n", __FUNCTION__); 159 return -1;
185 retval = dst_gpio_outb(state, ~0, 0, 0); 160 }
186 if (retval < 0) 161 udelay(1000);
187 return retval; 162 return 0;
188 // dprintk ("%s: i2c disable delay\n", __FUNCTION__); 163}
189 msleep(33); 164EXPORT_SYMBOL(dst_pio_enable);
165
166int dst_pio_disable(struct dst_state *state)
167{
168 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) {
169 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
170 return -1;
171 }
172 if (state->type_flags & DST_TYPE_HAS_FW_1)
173 udelay(1000);
174
190 return 0; 175 return 0;
191} 176}
177EXPORT_SYMBOL(dst_pio_disable);
192 178
193static int dst_wait_dst_ready(struct dst_state *state) 179int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode)
194{ 180{
195 u8 reply; 181 u8 reply;
196 int retval;
197 int i; 182 int i;
183
198 for (i = 0; i < 200; i++) { 184 for (i = 0; i < 200; i++) {
199 retval = dst_gpio_inb(state, &reply); 185 if (dst_gpio_inb(state, &reply) < 0) {
200 if (retval < 0) 186 dprintk("%s: dst_gpio_inb ERROR !\n", __FUNCTION__);
201 return retval; 187 return -1;
202 if ((reply & DST_I2C_ENABLE) == 0) { 188 }
203 dprintk("%s: dst wait ready after %d\n", __FUNCTION__, i); 189
190 if ((reply & RDC_8820_PIO_0_ENABLE) == 0) {
191 if (verbose > 4)
192 dprintk("%s: dst wait ready after %d\n", __FUNCTION__, i);
204 return 1; 193 return 1;
205 } 194 }
206 msleep(10); 195 msleep(10);
207 } 196 }
208 dprintk("%s: dst wait NOT ready after %d\n", __FUNCTION__, i); 197 if (verbose > 1)
198 dprintk("%s: dst wait NOT ready after %d\n", __FUNCTION__, i);
199
200 return 0;
201}
202EXPORT_SYMBOL(dst_wait_dst_ready);
203
204int dst_error_recovery(struct dst_state *state)
205{
206 dprintk("%s: Trying to return from previous errors...\n", __FUNCTION__);
207 dst_pio_disable(state);
208 msleep(10);
209 dst_pio_enable(state);
210 msleep(10);
211
212 return 0;
213}
214EXPORT_SYMBOL(dst_error_recovery);
215
216int dst_error_bailout(struct dst_state *state)
217{
218 dprintk("%s: Trying to bailout from previous error...\n", __FUNCTION__);
219 rdc_8820_reset(state);
220 dst_pio_disable(state);
221 msleep(10);
222
223 return 0;
224}
225EXPORT_SYMBOL(dst_error_bailout);
226
227
228int dst_comm_init(struct dst_state* state)
229{
230 if (verbose > 1)
231 dprintk ("%s: Initializing DST..\n", __FUNCTION__);
232 if ((dst_pio_enable(state)) < 0) {
233 dprintk("%s: PIO Enable Failed.\n", __FUNCTION__);
234 return -1;
235 }
236 if ((rdc_reset_state(state)) < 0) {
237 dprintk("%s: RDC 8820 State RESET Failed.\n", __FUNCTION__);
238 return -1;
239 }
240 if (state->type_flags & DST_TYPE_HAS_FW_1)
241 msleep(100);
242 else
243 msleep(5);
244
209 return 0; 245 return 0;
210} 246}
247EXPORT_SYMBOL(dst_comm_init);
211 248
212static int write_dst(struct dst_state *state, u8 * data, u8 len) 249
250int write_dst(struct dst_state *state, u8 *data, u8 len)
213{ 251{
214 struct i2c_msg msg = { 252 struct i2c_msg msg = {
215 .addr = state->config->demod_address,.flags = 0,.buf = data,.len = len 253 .addr = state->config->demod_address,.flags = 0,.buf = data,.len = len
216 }; 254 };
255
217 int err; 256 int err;
218 int cnt; 257 int cnt;
219 258 if (debug && (verbose > 4)) {
220 if (dst_debug && dst_verbose) {
221 u8 i; 259 u8 i;
222 dprintk("%s writing", __FUNCTION__); 260 if (verbose > 4) {
223 for (i = 0; i < len; i++) { 261 dprintk("%s writing", __FUNCTION__);
224 dprintk(" 0x%02x", data[i]); 262 for (i = 0; i < len; i++)
263 dprintk(" %02x", data[i]);
264 dprintk("\n");
225 } 265 }
226 dprintk("\n");
227 } 266 }
228 msleep(30); 267 for (cnt = 0; cnt < 2; cnt++) {
229 for (cnt = 0; cnt < 4; cnt++) {
230 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { 268 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
231 dprintk("%s: write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, data[0]); 269 dprintk("%s: _write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, data[0]);
232 dst_i2c_disable(state); 270 dst_error_recovery(state);
233 msleep(500);
234 dst_i2c_enable(state);
235 msleep(500);
236 continue; 271 continue;
237 } else 272 } else
238 break; 273 break;
239 } 274 }
240 if (cnt >= 4) 275
241 return -EREMOTEIO; 276 if (cnt >= 2) {
277 if (verbose > 1)
278 printk("%s: RDC 8820 RESET...\n", __FUNCTION__);
279 dst_error_bailout(state);
280
281 return -1;
282 }
283
242 return 0; 284 return 0;
243} 285}
286EXPORT_SYMBOL(write_dst);
244 287
245static int read_dst(struct dst_state *state, u8 * ret, u8 len) 288int read_dst(struct dst_state *state, u8 * ret, u8 len)
246{ 289{
247 struct i2c_msg msg = {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = ret,.len = len }; 290 struct i2c_msg msg = {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = ret,.len = len };
248 int err; 291 int err;
249 int cnt; 292 int cnt;
250 293
251 for (cnt = 0; cnt < 4; cnt++) { 294 for (cnt = 0; cnt < 2; cnt++) {
252 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { 295 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
296
253 dprintk("%s: read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, ret[0]); 297 dprintk("%s: read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, ret[0]);
254 dst_i2c_disable(state); 298 dst_error_recovery(state);
255 dst_i2c_enable(state); 299
256 continue; 300 continue;
257 } else 301 } else
258 break; 302 break;
259 } 303 }
260 if (cnt >= 4) 304 if (cnt >= 2) {
261 return -EREMOTEIO; 305 if (verbose > 1)
262 dprintk("%s reply is 0x%x\n", __FUNCTION__, ret[0]); 306 printk("%s: RDC 8820 RESET...\n", __FUNCTION__);
263 if (dst_debug && dst_verbose) { 307 dst_error_bailout(state);
308
309 return -1;
310 }
311 if (debug && (verbose > 4)) {
312 dprintk("%s reply is 0x%x\n", __FUNCTION__, ret[0]);
264 for (err = 1; err < len; err++) 313 for (err = 1; err < len; err++)
265 dprintk(" 0x%x", ret[err]); 314 dprintk(" 0x%x", ret[err]);
266 if (err > 1) 315 if (err > 1)
267 dprintk("\n"); 316 dprintk("\n");
268 } 317 }
318
269 return 0; 319 return 0;
270} 320}
321EXPORT_SYMBOL(read_dst);
271 322
272static int dst_set_freq(struct dst_state *state, u32 freq) 323static int dst_set_freq(struct dst_state *state, u32 freq)
273{ 324{
274 u8 *val; 325 u8 *val;
275 326
276 state->frequency = freq; 327 state->frequency = freq;
328 if (debug > 4)
329 dprintk("%s: set Frequency %u\n", __FUNCTION__, freq);
277 330
278 // dprintk("%s: set frequency %u\n", __FUNCTION__, freq);
279 if (state->dst_type == DST_TYPE_IS_SAT) { 331 if (state->dst_type == DST_TYPE_IS_SAT) {
280 freq = freq / 1000; 332 freq = freq / 1000;
281 if (freq < 950 || freq > 2150) 333 if (freq < 950 || freq > 2150)
@@ -398,7 +450,8 @@ static int dst_set_symbolrate(struct dst_state* state, u32 srate)
398 if (state->dst_type == DST_TYPE_IS_TERR) { 450 if (state->dst_type == DST_TYPE_IS_TERR) {
399 return 0; 451 return 0;
400 } 452 }
401 // dprintk("%s: set srate %u\n", __FUNCTION__, srate); 453 if (debug > 4)
454 dprintk("%s: set symrate %u\n", __FUNCTION__, srate);
402 srate /= 1000; 455 srate /= 1000;
403 val = &state->tx_tuna[0]; 456 val = &state->tx_tuna[0];
404 457
@@ -407,7 +460,10 @@ static int dst_set_symbolrate(struct dst_state* state, u32 srate)
407 sval <<= 20; 460 sval <<= 20;
408 do_div(sval, 88000); 461 do_div(sval, 88000);
409 symcalc = (u32) sval; 462 symcalc = (u32) sval;
410 // dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc); 463
464 if (debug > 4)
465 dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc);
466
411 val[5] = (u8) (symcalc >> 12); 467 val[5] = (u8) (symcalc >> 12);
412 val[6] = (u8) (symcalc >> 4); 468 val[6] = (u8) (symcalc >> 4);
413 val[7] = (u8) (symcalc << 4); 469 val[7] = (u8) (symcalc << 4);
@@ -422,7 +478,7 @@ static int dst_set_symbolrate(struct dst_state* state, u32 srate)
422 return 0; 478 return 0;
423} 479}
424 480
425static u8 dst_check_sum(u8 * buf, u32 len) 481u8 dst_check_sum(u8 * buf, u32 len)
426{ 482{
427 u32 i; 483 u32 i;
428 u8 val = 0; 484 u8 val = 0;
@@ -433,28 +489,7 @@ static u8 dst_check_sum(u8 * buf, u32 len)
433 } 489 }
434 return ((~val) + 1); 490 return ((~val) + 1);
435} 491}
436 492EXPORT_SYMBOL(dst_check_sum);
437struct dst_types {
438 char *mstr;
439 int offs;
440 u8 dst_type;
441 u32 type_flags;
442};
443
444static struct dst_types dst_tlist[] = {
445 {"DST-020", 0, DST_TYPE_IS_SAT, DST_TYPE_HAS_SYMDIV},
446 {"DST-030", 0, DST_TYPE_IS_SAT, DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE},
447 {"DST-03T", 0, DST_TYPE_IS_SAT, DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_TS204},
448 {"DST-MOT", 0, DST_TYPE_IS_SAT, DST_TYPE_HAS_SYMDIV},
449 {"DST-CI", 1, DST_TYPE_IS_SAT, DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE},
450 {"DSTMCI", 1, DST_TYPE_IS_SAT, DST_TYPE_HAS_NEWTUNE},
451 {"DSTFCI", 1, DST_TYPE_IS_SAT, DST_TYPE_HAS_NEWTUNE},
452 {"DCTNEW", 1, DST_TYPE_IS_CABLE, DST_TYPE_HAS_NEWTUNE},
453 {"DCT-CI", 1, DST_TYPE_IS_CABLE, DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_TS204},
454 {"DTTDIG", 1, DST_TYPE_IS_TERR, 0}
455};
456
457/* DCTNEW and DCT-CI are guesses */
458 493
459static void dst_type_flags_print(u32 type_flags) 494static void dst_type_flags_print(u32 type_flags)
460{ 495{
@@ -465,93 +500,270 @@ static void dst_type_flags_print(u32 type_flags)
465 printk(" 0x%x ts204", DST_TYPE_HAS_TS204); 500 printk(" 0x%x ts204", DST_TYPE_HAS_TS204);
466 if (type_flags & DST_TYPE_HAS_SYMDIV) 501 if (type_flags & DST_TYPE_HAS_SYMDIV)
467 printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV); 502 printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV);
503 if (type_flags & DST_TYPE_HAS_FW_1)
504 printk(" 0x%x firmware version = 1", DST_TYPE_HAS_FW_1);
505 if (type_flags & DST_TYPE_HAS_FW_2)
506 printk(" 0x%x firmware version = 2", DST_TYPE_HAS_FW_2);
507 if (type_flags & DST_TYPE_HAS_FW_3)
508 printk(" 0x%x firmware version = 3", DST_TYPE_HAS_FW_3);
509// if ((type_flags & DST_TYPE_HAS_FW_BUILD) && new_fw)
510
468 printk("\n"); 511 printk("\n");
469} 512}
470 513
471static int dst_type_print(u8 type) 514
515static int dst_type_print (u8 type)
472{ 516{
473 char *otype; 517 char *otype;
474 switch (type) { 518 switch (type) {
475 case DST_TYPE_IS_SAT: 519 case DST_TYPE_IS_SAT:
476 otype = "satellite"; 520 otype = "satellite";
477 break; 521 break;
522
478 case DST_TYPE_IS_TERR: 523 case DST_TYPE_IS_TERR:
479 otype = "terrestrial"; 524 otype = "terrestrial";
480 break; 525 break;
526
481 case DST_TYPE_IS_CABLE: 527 case DST_TYPE_IS_CABLE:
482 otype = "cable"; 528 otype = "cable";
483 break; 529 break;
530
484 default: 531 default:
485 printk("%s: invalid dst type %d\n", __FUNCTION__, type); 532 printk("%s: invalid dst type %d\n", __FUNCTION__, type);
486 return -EINVAL; 533 return -EINVAL;
487 } 534 }
488 printk("DST type : %s\n", otype); 535 printk("DST type : %s\n", otype);
536
489 return 0; 537 return 0;
490} 538}
491 539
492static int dst_check_ci(struct dst_state *state) 540/*
541 Known cards list
542 Satellite
543 -------------------
544 200103A
545 VP-1020 DST-MOT LG(old), TS=188
546
547 VP-1020 DST-03T LG(new), TS=204
548 VP-1022 DST-03T LG(new), TS=204
549 VP-1025 DST-03T LG(new), TS=204
550
551 VP-1030 DSTMCI, LG(new), TS=188
552 VP-1032 DSTMCI, LG(new), TS=188
553
554 Cable
555 -------------------
556 VP-2030 DCT-CI, Samsung, TS=204
557 VP-2021 DCT-CI, Unknown, TS=204
558 VP-2031 DCT-CI, Philips, TS=188
559 VP-2040 DCT-CI, Philips, TS=188, with CA daughter board
560 VP-2040 DCT-CI, Philips, TS=204, without CA daughter board
561
562 Terrestrial
563 -------------------
564 VP-3050 DTTNXT TS=188
565 VP-3040 DTT-CI, Philips, TS=188
566 VP-3040 DTT-CI, Philips, TS=204
567
568 ATSC
569 -------------------
570 VP-3220 ATSCDI, TS=188
571 VP-3250 ATSCAD, TS=188
572
573*/
574
575struct dst_types dst_tlist[] = {
576 {
577 .device_id = "200103A",
578 .offset = 0,
579 .dst_type = DST_TYPE_IS_SAT,
580 .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_FW_1,
581 .dst_feature = 0
582 }, /* obsolete */
583
584 {
585 .device_id = "DST-020",
586 .offset = 0,
587 .dst_type = DST_TYPE_IS_SAT,
588 .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_FW_1,
589 .dst_feature = 0
590 }, /* obsolete */
591
592 {
593 .device_id = "DST-030",
594 .offset = 0,
595 .dst_type = DST_TYPE_IS_SAT,
596 .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1,
597 .dst_feature = 0
598 }, /* obsolete */
599
600 {
601 .device_id = "DST-03T",
602 .offset = 0,
603 .dst_type = DST_TYPE_IS_SAT,
604 .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2,
605 .dst_feature = DST_TYPE_HAS_DISEQC3 | DST_TYPE_HAS_DISEQC4 | DST_TYPE_HAS_DISEQC5
606 | DST_TYPE_HAS_MAC | DST_TYPE_HAS_MOTO
607 },
608
609 {
610 .device_id = "DST-MOT",
611 .offset = 0,
612 .dst_type = DST_TYPE_IS_SAT,
613 .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_FW_1,
614 .dst_feature = 0
615 }, /* obsolete */
616
617 {
618 .device_id = "DST-CI",
619 .offset = 1,
620 .dst_type = DST_TYPE_IS_SAT,
621 .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1,
622 .dst_feature = DST_TYPE_HAS_CA
623 }, /* An OEM board */
624
625 {
626 .device_id = "DSTMCI",
627 .offset = 1,
628 .dst_type = DST_TYPE_IS_SAT,
629 .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD,
630 .dst_feature = DST_TYPE_HAS_CA | DST_TYPE_HAS_DISEQC3 | DST_TYPE_HAS_DISEQC4
631 | DST_TYPE_HAS_MOTO | DST_TYPE_HAS_MAC
632 },
633
634 {
635 .device_id = "DSTFCI",
636 .offset = 1,
637 .dst_type = DST_TYPE_IS_SAT,
638 .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1,
639 .dst_feature = 0
640 }, /* unknown to vendor */
641
642 {
643 .device_id = "DCT-CI",
644 .offset = 1,
645 .dst_type = DST_TYPE_IS_CABLE,
646 .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1
647 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD,
648 .dst_feature = DST_TYPE_HAS_CA
649 },
650
651 {
652 .device_id = "DCTNEW",
653 .offset = 1,
654 .dst_type = DST_TYPE_IS_CABLE,
655 .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3,
656 .dst_feature = 0
657 },
658
659 {
660 .device_id = "DTT-CI",
661 .offset = 1,
662 .dst_type = DST_TYPE_IS_TERR,
663 .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD,
664 .dst_feature = 0
665 },
666
667 {
668 .device_id = "DTTDIG",
669 .offset = 1,
670 .dst_type = DST_TYPE_IS_TERR,
671 .type_flags = DST_TYPE_HAS_FW_2,
672 .dst_feature = 0
673 },
674
675 {
676 .device_id = "DTTNXT",
677 .offset = 1,
678 .dst_type = DST_TYPE_IS_TERR,
679 .type_flags = DST_TYPE_HAS_FW_2,
680 .dst_feature = DST_TYPE_HAS_ANALOG
681 },
682
683 {
684 .device_id = "ATSCDI",
685 .offset = 1,
686 .dst_type = DST_TYPE_IS_ATSC,
687 .type_flags = DST_TYPE_HAS_FW_2,
688 .dst_feature = 0
689 },
690
691 {
692 .device_id = "ATSCAD",
693 .offset = 1,
694 .dst_type = DST_TYPE_IS_ATSC,
695 .type_flags = DST_TYPE_HAS_FW_2,
696 .dst_feature = 0
697 },
698
699 { }
700
701};
702
703
704static int dst_get_device_id(struct dst_state *state)
493{ 705{
494 u8 txbuf[8]; 706 u8 reply;
495 u8 rxbuf[8]; 707
496 int retval;
497 int i; 708 int i;
498 struct dst_types *dsp; 709 struct dst_types *p_dst_type;
499 u8 use_dst_type; 710 u8 use_dst_type = 0;
500 u32 use_type_flags; 711 u32 use_type_flags = 0;
501 712
502 memset(txbuf, 0, sizeof(txbuf)); 713 static u8 device_type[8] = {0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff};
503 txbuf[1] = 6;
504 txbuf[7] = dst_check_sum(txbuf, 7);
505 714
506 dst_i2c_enable(state); 715 device_type[7] = dst_check_sum(device_type, 7);
507 dst_reset8820(state); 716
508 retval = write_dst(state, txbuf, 8); 717 if (write_dst(state, device_type, FIXED_COMM))
509 if (retval < 0) { 718 return -1; /* Write failed */
510 dst_i2c_disable(state); 719
511 dprintk("%s: write not successful, maybe no card?\n", __FUNCTION__); 720 if ((dst_pio_disable(state)) < 0)
512 return retval; 721 return -1;
513 } 722
514 msleep(3); 723 if (read_dst(state, &reply, GET_ACK))
515 retval = read_dst(state, rxbuf, 1); 724 return -1; /* Read failure */
516 dst_i2c_disable(state); 725
517 if (retval < 0) { 726 if (reply != ACK) {
518 dprintk("%s: read not successful, maybe no card?\n", __FUNCTION__); 727 dprintk("%s: Write not Acknowledged! [Reply=0x%02x]\n", __FUNCTION__, reply);
519 return retval; 728 return -1; /* Unack'd write */
520 }
521 if (rxbuf[0] != 0xff) {
522 dprintk("%s: write reply not 0xff, not ci (%02x)\n", __FUNCTION__, rxbuf[0]);
523 return retval;
524 }
525 if (!dst_wait_dst_ready(state))
526 return 0;
527 // dst_i2c_enable(i2c); Dimitri
528 retval = read_dst(state, rxbuf, 8);
529 dst_i2c_disable(state);
530 if (retval < 0) {
531 dprintk("%s: read not successful\n", __FUNCTION__);
532 return retval;
533 } 729 }
534 if (rxbuf[7] != dst_check_sum(rxbuf, 7)) { 730
535 dprintk("%s: checksum failure\n", __FUNCTION__); 731 if (!dst_wait_dst_ready(state, DEVICE_INIT))
536 return retval; 732 return -1; /* DST not ready yet */
733
734 if (read_dst(state, state->rxbuffer, FIXED_COMM))
735 return -1;
736
737 dst_pio_disable(state);
738
739 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
740 dprintk("%s: Checksum failure! \n", __FUNCTION__);
741 return -1; /* Checksum failure */
537 } 742 }
538 rxbuf[7] = '\0'; 743
539 for (i = 0, dsp = &dst_tlist[0]; i < sizeof(dst_tlist) / sizeof(dst_tlist[0]); i++, dsp++) { 744 state->rxbuffer[7] = '\0';
540 if (!strncmp(&rxbuf[dsp->offs], dsp->mstr, strlen(dsp->mstr))) { 745
541 use_type_flags = dsp->type_flags; 746 for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE (dst_tlist); i++, p_dst_type++) {
542 use_dst_type = dsp->dst_type; 747 if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) {
543 printk("%s: recognize %s\n", __FUNCTION__, dsp->mstr); 748 use_type_flags = p_dst_type->type_flags;
749 use_dst_type = p_dst_type->dst_type;
750
751 /* Card capabilities */
752 state->dst_hw_cap = p_dst_type->dst_feature;
753 printk ("%s: Recognise [%s]\n", __FUNCTION__, p_dst_type->device_id);
754
544 break; 755 break;
545 } 756 }
546 } 757 }
547 if (i >= sizeof(dst_tlist) / sizeof(dst_tlist[0])) { 758
548 printk("%s: unable to recognize %s or %s\n", __FUNCTION__, &rxbuf[0], &rxbuf[1]); 759 if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) {
549 printk("%s please email linux-dvb@linuxtv.org with this type in\n", __FUNCTION__); 760 printk("%s: Unable to recognize %s or %s\n", __FUNCTION__, &state->rxbuffer[0], &state->rxbuffer[1]);
761 printk("%s: please email linux-dvb@linuxtv.org with this type in\n", __FUNCTION__);
550 use_dst_type = DST_TYPE_IS_SAT; 762 use_dst_type = DST_TYPE_IS_SAT;
551 use_type_flags = DST_TYPE_HAS_SYMDIV; 763 use_type_flags = DST_TYPE_HAS_SYMDIV;
552 } 764 }
553 dst_type_print(use_dst_type);
554 765
766 dst_type_print(use_dst_type);
555 state->type_flags = use_type_flags; 767 state->type_flags = use_type_flags;
556 state->dst_type = use_dst_type; 768 state->dst_type = use_dst_type;
557 dst_type_flags_print(state->type_flags); 769 dst_type_flags_print(state->type_flags);
@@ -559,50 +771,102 @@ static int dst_check_ci(struct dst_state *state)
559 if (state->type_flags & DST_TYPE_HAS_TS204) { 771 if (state->type_flags & DST_TYPE_HAS_TS204) {
560 dst_packsize(state, 204); 772 dst_packsize(state, 204);
561 } 773 }
774
562 return 0; 775 return 0;
563} 776}
564 777
565static int dst_command(struct dst_state* state, u8 * data, u8 len) 778static int dst_probe(struct dst_state *state)
779{
780 if ((rdc_8820_reset(state)) < 0) {
781 dprintk("%s: RDC 8820 RESET Failed.\n", __FUNCTION__);
782 return -1;
783 }
784 if (dst_addons & DST_TYPE_HAS_CA)
785 msleep(4000);
786 else
787 msleep(100);
788
789 if ((dst_comm_init(state)) < 0) {
790 dprintk("%s: DST Initialization Failed.\n", __FUNCTION__);
791 return -1;
792 }
793 msleep(100);
794 if (dst_get_device_id(state) < 0) {
795 dprintk("%s: unknown device.\n", __FUNCTION__);
796 return -1;
797 }
798
799 return 0;
800}
801
802int dst_command(struct dst_state* state, u8 * data, u8 len)
566{ 803{
567 int retval;
568 u8 reply; 804 u8 reply;
805 if ((dst_comm_init(state)) < 0) {
806 dprintk("%s: DST Communication Initialization Failed.\n", __FUNCTION__);
807 return -1;
808 }
569 809
570 dst_i2c_enable(state); 810 if (write_dst(state, data, len)) {
571 dst_reset8820(state); 811 if (verbose > 1)
572 retval = write_dst(state, data, len); 812 dprintk("%s: Tring to recover.. \n", __FUNCTION__);
573 if (retval < 0) { 813 if ((dst_error_recovery(state)) < 0) {
574 dst_i2c_disable(state); 814 dprintk("%s: Recovery Failed.\n", __FUNCTION__);
575 dprintk("%s: write not successful\n", __FUNCTION__); 815 return -1;
576 return retval; 816 }
817 return -1;
577 } 818 }
578 msleep(33); 819 if ((dst_pio_disable(state)) < 0) {
579 retval = read_dst(state, &reply, 1); 820 dprintk("%s: PIO Disable Failed.\n", __FUNCTION__);
580 dst_i2c_disable(state); 821 return -1;
581 if (retval < 0) {
582 dprintk("%s: read verify not successful\n", __FUNCTION__);
583 return retval;
584 } 822 }
585 if (reply != 0xff) { 823 if (state->type_flags & DST_TYPE_HAS_FW_1)
586 dprintk("%s: write reply not 0xff 0x%02x \n", __FUNCTION__, reply); 824 udelay(3000);
587 return 0; 825
826 if (read_dst(state, &reply, GET_ACK)) {
827 if (verbose > 1)
828 dprintk("%s: Trying to recover.. \n", __FUNCTION__);
829 if ((dst_error_recovery(state)) < 0) {
830 dprintk("%s: Recovery Failed.\n", __FUNCTION__);
831 return -1;
832 }
833 return -1;
834 }
835
836 if (reply != ACK) {
837 dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply);
838 return -1;
588 } 839 }
589 if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) 840 if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3))
590 return 0; 841 return 0;
591 if (!dst_wait_dst_ready(state)) 842
592 return 0; 843// udelay(3000);
593 // dst_i2c_enable(i2c); Per dimitri 844 if (state->type_flags & DST_TYPE_HAS_FW_1)
594 retval = read_dst(state, state->rxbuffer, 8); 845 udelay(3000);
595 dst_i2c_disable(state); 846 else
596 if (retval < 0) { 847 udelay(2000);
597 dprintk("%s: read not successful\n", __FUNCTION__); 848
598 return 0; 849 if (!dst_wait_dst_ready(state, NO_DELAY))
850 return -1;
851
852 if (read_dst(state, state->rxbuffer, FIXED_COMM)) {
853 if (verbose > 1)
854 dprintk("%s: Trying to recover.. \n", __FUNCTION__);
855 if ((dst_error_recovery(state)) < 0) {
856 dprintk("%s: Recovery failed.\n", __FUNCTION__);
857 return -1;
858 }
859 return -1;
599 } 860 }
861
600 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { 862 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
601 dprintk("%s: checksum failure\n", __FUNCTION__); 863 dprintk("%s: checksum failure\n", __FUNCTION__);
602 return 0; 864 return -1;
603 } 865 }
866
604 return 0; 867 return 0;
605} 868}
869EXPORT_SYMBOL(dst_command);
606 870
607static int dst_get_signal(struct dst_state* state) 871static int dst_get_signal(struct dst_state* state)
608{ 872{
@@ -646,11 +910,17 @@ static int dst_tone_power_cmd(struct dst_state* state)
646 paket[4] = 0; 910 paket[4] = 0;
647 else 911 else
648 paket[4] = 1; 912 paket[4] = 1;
913
649 if (state->tone == SEC_TONE_ON) 914 if (state->tone == SEC_TONE_ON)
650 paket[2] = state->k22; 915 paket[2] = 0x02;
651 else 916 else
652 paket[2] = 0; 917 paket[2] = 0;
653 paket[7] = dst_check_sum(&paket[0], 7); 918 if (state->minicmd == SEC_MINI_A)
919 paket[3] = 0x02;
920 else
921 paket[3] = 0;
922
923 paket[7] = dst_check_sum (paket, 7);
654 dst_command(state, paket, 8); 924 dst_command(state, paket, 8);
655 return 0; 925 return 0;
656} 926}
@@ -658,21 +928,26 @@ static int dst_tone_power_cmd(struct dst_state* state)
658static int dst_get_tuna(struct dst_state* state) 928static int dst_get_tuna(struct dst_state* state)
659{ 929{
660 int retval; 930 int retval;
931
661 if ((state->diseq_flags & ATTEMPT_TUNE) == 0) 932 if ((state->diseq_flags & ATTEMPT_TUNE) == 0)
662 return 0; 933 return 0;
934
663 state->diseq_flags &= ~(HAS_LOCK); 935 state->diseq_flags &= ~(HAS_LOCK);
664 if (!dst_wait_dst_ready(state)) 936 if (!dst_wait_dst_ready(state, NO_DELAY))
665 return 0; 937 return 0;
938
666 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { 939 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
667 /* how to get variable length reply ???? */ 940 /* how to get variable length reply ???? */
668 retval = read_dst(state, state->rx_tuna, 10); 941 retval = read_dst(state, state->rx_tuna, 10);
669 } else { 942 } else {
670 retval = read_dst(state, &state->rx_tuna[2], 8); 943 retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM);
671 } 944 }
945
672 if (retval < 0) { 946 if (retval < 0) {
673 dprintk("%s: read not successful\n", __FUNCTION__); 947 dprintk("%s: read not successful\n", __FUNCTION__);
674 return 0; 948 return 0;
675 } 949 }
950
676 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { 951 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
677 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { 952 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) {
678 dprintk("%s: checksum failure?\n", __FUNCTION__); 953 dprintk("%s: checksum failure?\n", __FUNCTION__);
@@ -709,7 +984,9 @@ static int dst_write_tuna(struct dvb_frontend* fe)
709 int retval; 984 int retval;
710 u8 reply; 985 u8 reply;
711 986
712 dprintk("%s: type_flags 0x%x \n", __FUNCTION__, state->type_flags); 987 if (debug > 4)
988 dprintk("%s: type_flags 0x%x \n", __FUNCTION__, state->type_flags);
989
713 state->decode_freq = 0; 990 state->decode_freq = 0;
714 state->decode_lock = state->decode_strength = state->decode_snr = 0; 991 state->decode_lock = state->decode_strength = state->decode_snr = 0;
715 if (state->dst_type == DST_TYPE_IS_SAT) { 992 if (state->dst_type == DST_TYPE_IS_SAT) {
@@ -717,32 +994,41 @@ static int dst_write_tuna(struct dvb_frontend* fe)
717 dst_set_voltage(fe, SEC_VOLTAGE_13); 994 dst_set_voltage(fe, SEC_VOLTAGE_13);
718 } 995 }
719 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); 996 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
720 dst_i2c_enable(state); 997
998 if ((dst_comm_init(state)) < 0) {
999 dprintk("%s: DST Communication initialization failed.\n", __FUNCTION__);
1000 return -1;
1001 }
1002
721 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { 1003 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
722 dst_reset8820(state);
723 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); 1004 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9);
724 retval = write_dst(state, &state->tx_tuna[0], 10); 1005 retval = write_dst(state, &state->tx_tuna[0], 10);
1006
725 } else { 1007 } else {
726 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7); 1008 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7);
727 retval = write_dst(state, &state->tx_tuna[2], 8); 1009 retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM);
728 } 1010 }
729 if (retval < 0) { 1011 if (retval < 0) {
730 dst_i2c_disable(state); 1012 dst_pio_disable(state);
731 dprintk("%s: write not successful\n", __FUNCTION__); 1013 dprintk("%s: write not successful\n", __FUNCTION__);
732 return retval; 1014 return retval;
733 } 1015 }
734 msleep(3); 1016
735 retval = read_dst(state, &reply, 1); 1017 if ((dst_pio_disable(state)) < 0) {
736 dst_i2c_disable(state); 1018 dprintk("%s: DST PIO disable failed !\n", __FUNCTION__);
737 if (retval < 0) { 1019 return -1;
738 dprintk("%s: read verify not successful\n", __FUNCTION__); 1020 }
739 return retval; 1021
1022 if ((read_dst(state, &reply, GET_ACK) < 0)) {
1023 dprintk("%s: read verify not successful.\n", __FUNCTION__);
1024 return -1;
740 } 1025 }
741 if (reply != 0xff) { 1026 if (reply != ACK) {
742 dprintk("%s: write reply not 0xff 0x%02x \n", __FUNCTION__, reply); 1027 dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply);
743 return 0; 1028 return 0;
744 } 1029 }
745 state->diseq_flags |= ATTEMPT_TUNE; 1030 state->diseq_flags |= ATTEMPT_TUNE;
1031
746 return dst_get_tuna(state); 1032 return dst_get_tuna(state);
747} 1033}
748 1034
@@ -796,22 +1082,25 @@ static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
796 need_cmd = 1; 1082 need_cmd = 1;
797 state->diseq_flags |= HAS_POWER; 1083 state->diseq_flags |= HAS_POWER;
798 break; 1084 break;
1085
799 case SEC_VOLTAGE_18: 1086 case SEC_VOLTAGE_18:
800 if ((state->diseq_flags & HAS_POWER) == 0) 1087 if ((state->diseq_flags & HAS_POWER) == 0)
801 need_cmd = 1; 1088 need_cmd = 1;
802 state->diseq_flags |= HAS_POWER; 1089 state->diseq_flags |= HAS_POWER;
803 val[8] |= 0x40; 1090 val[8] |= 0x40;
804 break; 1091 break;
1092
805 case SEC_VOLTAGE_OFF: 1093 case SEC_VOLTAGE_OFF:
806 need_cmd = 1; 1094 need_cmd = 1;
807 state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); 1095 state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE);
808 break; 1096 break;
1097
809 default: 1098 default:
810 return -EINVAL; 1099 return -EINVAL;
811 } 1100 }
812 if (need_cmd) { 1101 if (need_cmd)
813 dst_tone_power_cmd(state); 1102 dst_tone_power_cmd(state);
814 } 1103
815 return 0; 1104 return 0;
816} 1105}
817 1106
@@ -832,13 +1121,16 @@ static int dst_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
832 switch (tone) { 1121 switch (tone) {
833 case SEC_TONE_OFF: 1122 case SEC_TONE_OFF:
834 break; 1123 break;
1124
835 case SEC_TONE_ON: 1125 case SEC_TONE_ON:
836 val[8] |= 1; 1126 val[8] |= 1;
837 break; 1127 break;
1128
838 default: 1129 default:
839 return -EINVAL; 1130 return -EINVAL;
840 } 1131 }
841 dst_tone_power_cmd(state); 1132 dst_tone_power_cmd(state);
1133
842 return 0; 1134 return 0;
843} 1135}
844 1136
@@ -913,10 +1205,16 @@ static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet
913 struct dst_state* state = (struct dst_state*) fe->demodulator_priv; 1205 struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
914 1206
915 dst_set_freq(state, p->frequency); 1207 dst_set_freq(state, p->frequency);
1208 if (verbose > 4)
1209 dprintk("Set Frequency = [%d]\n", p->frequency);
1210
916 dst_set_inversion(state, p->inversion); 1211 dst_set_inversion(state, p->inversion);
917 if (state->dst_type == DST_TYPE_IS_SAT) { 1212 if (state->dst_type == DST_TYPE_IS_SAT) {
918 dst_set_fec(state, p->u.qpsk.fec_inner); 1213 dst_set_fec(state, p->u.qpsk.fec_inner);
919 dst_set_symbolrate(state, p->u.qpsk.symbol_rate); 1214 dst_set_symbolrate(state, p->u.qpsk.symbol_rate);
1215 if (verbose > 4)
1216 dprintk("Set Symbolrate = [%d]\n", p->u.qpsk.symbol_rate);
1217
920 } else if (state->dst_type == DST_TYPE_IS_TERR) { 1218 } else if (state->dst_type == DST_TYPE_IS_TERR) {
921 dst_set_bandwidth(state, p->u.ofdm.bandwidth); 1219 dst_set_bandwidth(state, p->u.ofdm.bandwidth);
922 } else if (state->dst_type == DST_TYPE_IS_CABLE) { 1220 } else if (state->dst_type == DST_TYPE_IS_CABLE) {
@@ -958,50 +1256,47 @@ static struct dvb_frontend_ops dst_dvbt_ops;
958static struct dvb_frontend_ops dst_dvbs_ops; 1256static struct dvb_frontend_ops dst_dvbs_ops;
959static struct dvb_frontend_ops dst_dvbc_ops; 1257static struct dvb_frontend_ops dst_dvbc_ops;
960 1258
961struct dvb_frontend* dst_attach(const struct dst_config* config, 1259struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter)
962 struct i2c_adapter* i2c,
963 struct bt878 *bt)
964{ 1260{
965 struct dst_state* state = NULL;
966
967 /* allocate memory for the internal state */
968 state = (struct dst_state*) kmalloc(sizeof(struct dst_state), GFP_KERNEL);
969 if (state == NULL) goto error;
970 1261
971 /* setup the state */ 1262 /* check if the ASIC is there */
972 state->config = config; 1263 if (dst_probe(state) < 0) {
973 state->i2c = i2c; 1264 if (state)
974 state->bt = bt; 1265 kfree(state);
975
976 /* check if the demod is there */
977 if (dst_check_ci(state) < 0) goto error;
978 1266
1267 return NULL;
1268 }
979 /* determine settings based on type */ 1269 /* determine settings based on type */
980 switch (state->dst_type) { 1270 switch (state->dst_type) {
981 case DST_TYPE_IS_TERR: 1271 case DST_TYPE_IS_TERR:
982 memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops)); 1272 memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops));
983 break; 1273 break;
1274
984 case DST_TYPE_IS_CABLE: 1275 case DST_TYPE_IS_CABLE:
985 memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops)); 1276 memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops));
986 break; 1277 break;
1278
987 case DST_TYPE_IS_SAT: 1279 case DST_TYPE_IS_SAT:
988 memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops)); 1280 memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops));
989 break; 1281 break;
1282
990 default: 1283 default:
991 printk("dst: unknown frontend type. please report to the LinuxTV.org DVB mailinglist.\n"); 1284 printk("%s: unknown DST type. please report to the LinuxTV.org DVB mailinglist.\n", __FUNCTION__);
992 goto error; 1285 if (state)
1286 kfree(state);
1287
1288 return NULL;
993 } 1289 }
994 1290
995 /* create dvb_frontend */ 1291 /* create dvb_frontend */
996 state->frontend.ops = &state->ops; 1292 state->frontend.ops = &state->ops;
997 state->frontend.demodulator_priv = state; 1293 state->frontend.demodulator_priv = state;
998 return &state->frontend;
999 1294
1000error: 1295 return state; /* Manu (DST is a card not a frontend) */
1001 kfree(state);
1002 return NULL;
1003} 1296}
1004 1297
1298EXPORT_SYMBOL(dst_attach);
1299
1005static struct dvb_frontend_ops dst_dvbt_ops = { 1300static struct dvb_frontend_ops dst_dvbt_ops = {
1006 1301
1007 .info = { 1302 .info = {
@@ -1051,6 +1346,7 @@ static struct dvb_frontend_ops dst_dvbs_ops = {
1051 .read_signal_strength = dst_read_signal_strength, 1346 .read_signal_strength = dst_read_signal_strength,
1052 .read_snr = dst_read_snr, 1347 .read_snr = dst_read_snr,
1053 1348
1349 .diseqc_send_burst = dst_set_tone,
1054 .diseqc_send_master_cmd = dst_set_diseqc, 1350 .diseqc_send_master_cmd = dst_set_diseqc,
1055 .set_voltage = dst_set_voltage, 1351 .set_voltage = dst_set_voltage,
1056 .set_tone = dst_set_tone, 1352 .set_tone = dst_set_tone,
@@ -1082,8 +1378,7 @@ static struct dvb_frontend_ops dst_dvbc_ops = {
1082 .read_snr = dst_read_snr, 1378 .read_snr = dst_read_snr,
1083}; 1379};
1084 1380
1381
1085MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver"); 1382MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver");
1086MODULE_AUTHOR("Jamie Honan"); 1383MODULE_AUTHOR("Jamie Honan, Manu Abraham");
1087MODULE_LICENSE("GPL"); 1384MODULE_LICENSE("GPL");
1088
1089EXPORT_SYMBOL(dst_attach);
diff --git a/drivers/media/dvb/bt8xx/dst.h b/drivers/media/dvb/bt8xx/dst.h
deleted file mode 100644
index bcb418c5c121..000000000000
--- a/drivers/media/dvb/bt8xx/dst.h
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 Frontend-driver for TwinHan DST Frontend
3
4 Copyright (C) 2003 Jamie Honan
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21*/
22
23#ifndef DST_H
24#define DST_H
25
26#include <linux/dvb/frontend.h>
27#include <linux/device.h>
28#include "bt878.h"
29
30struct dst_config
31{
32 /* the demodulator's i2c address */
33 u8 demod_address;
34};
35
36extern struct dvb_frontend* dst_attach(const struct dst_config* config,
37 struct i2c_adapter* i2c,
38 struct bt878 *bt);
39
40#endif // DST_H
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
new file mode 100644
index 000000000000..d781504cc2fa
--- /dev/null
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -0,0 +1,861 @@
1/*
2 CA-driver for TwinHan DST Frontend/Card
3
4 Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.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; 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., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/string.h>
27
28#include <linux/dvb/ca.h>
29#include "dvbdev.h"
30#include "dvb_frontend.h"
31
32#include "dst_ca.h"
33#include "dst_common.h"
34
35static unsigned int verbose = 1;
36module_param(verbose, int, 0644);
37MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
38
39static unsigned int debug = 1;
40module_param(debug, int, 0644);
41MODULE_PARM_DESC(debug, "debug messages, default is 1 (yes)");
42
43#define dprintk if (debug) printk
44
45/* Need some more work */
46static int ca_set_slot_descr(void)
47{
48 /* We could make this more graceful ? */
49 return -EOPNOTSUPP;
50}
51
52/* Need some more work */
53static int ca_set_pid(void)
54{
55 /* We could make this more graceful ? */
56 return -EOPNOTSUPP;
57}
58
59
60static int put_checksum(u8 *check_string, int length)
61{
62 u8 i = 0, checksum = 0;
63
64 if (verbose > 3) {
65 dprintk("%s: ========================= Checksum calculation ===========================\n", __FUNCTION__);
66 dprintk("%s: String Length=[0x%02x]\n", __FUNCTION__, length);
67
68 dprintk("%s: String=[", __FUNCTION__);
69 }
70 while (i < length) {
71 if (verbose > 3)
72 dprintk(" %02x", check_string[i]);
73 checksum += check_string[i];
74 i++;
75 }
76 if (verbose > 3) {
77 dprintk(" ]\n");
78 dprintk("%s: Sum=[%02x]\n", __FUNCTION__, checksum);
79 }
80 check_string[length] = ~checksum + 1;
81 if (verbose > 3) {
82 dprintk("%s: Checksum=[%02x]\n", __FUNCTION__, check_string[length]);
83 dprintk("%s: ==========================================================================\n", __FUNCTION__);
84 }
85
86 return 0;
87}
88
89static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8 len, int read)
90{
91 u8 reply;
92
93 dst_comm_init(state);
94 msleep(65);
95
96 if (write_dst(state, data, len)) {
97 dprintk("%s: Write not successful, trying to recover\n", __FUNCTION__);
98 dst_error_recovery(state);
99 return -1;
100 }
101
102 if ((dst_pio_disable(state)) < 0) {
103 dprintk("%s: DST PIO disable failed.\n", __FUNCTION__);
104 return -1;
105 }
106
107 if (read_dst(state, &reply, GET_ACK) < 0) {
108 dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__);
109 dst_error_recovery(state);
110 return -1;
111 }
112
113 if (read) {
114 if (! dst_wait_dst_ready(state, LONG_DELAY)) {
115 dprintk("%s: 8820 not ready\n", __FUNCTION__);
116 return -1;
117 }
118
119 if (read_dst(state, ca_string, 128) < 0) { /* Try to make this dynamic */
120 dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__);
121 dst_error_recovery(state);
122 return -1;
123 }
124 }
125
126 return 0;
127}
128
129
130static int dst_put_ci(struct dst_state *state, u8 *data, int len, u8 *ca_string, int read)
131{
132 u8 dst_ca_comm_err = 0;
133
134 while (dst_ca_comm_err < RETRIES) {
135 dst_comm_init(state);
136 if (verbose > 2)
137 dprintk("%s: Put Command\n", __FUNCTION__);
138 if (dst_ci_command(state, data, ca_string, len, read)) { // If error
139 dst_error_recovery(state);
140 dst_ca_comm_err++; // work required here.
141 }
142 break;
143 }
144
145 return 0;
146}
147
148
149
150static int ca_get_app_info(struct dst_state *state)
151{
152 static u8 command[8] = {0x07, 0x40, 0x01, 0x00, 0x01, 0x00, 0x00, 0xff};
153
154 put_checksum(&command[0], command[0]);
155 if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) {
156 dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__);
157 return -1;
158 }
159 if (verbose > 1) {
160 dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__);
161
162 dprintk("%s: ================================ CI Module Application Info ======================================\n", __FUNCTION__);
163 dprintk("%s: Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]\n",
164 __FUNCTION__, state->messages[7], (state->messages[8] << 8) | state->messages[9],
165 (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12]));
166 dprintk("%s: ==================================================================================================\n", __FUNCTION__);
167 }
168
169 return 0;
170}
171
172static int ca_get_slot_caps(struct dst_state *state, struct ca_caps *p_ca_caps, void *arg)
173{
174 int i;
175 u8 slot_cap[256];
176 static u8 slot_command[8] = {0x07, 0x40, 0x02, 0x00, 0x02, 0x00, 0x00, 0xff};
177
178 put_checksum(&slot_command[0], slot_command[0]);
179 if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) {
180 dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__);
181 return -1;
182 }
183 if (verbose > 1)
184 dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__);
185
186 /* Will implement the rest soon */
187
188 if (verbose > 1) {
189 dprintk("%s: Slot cap = [%d]\n", __FUNCTION__, slot_cap[7]);
190 dprintk("===================================\n");
191 for (i = 0; i < 8; i++)
192 dprintk(" %d", slot_cap[i]);
193 dprintk("\n");
194 }
195
196 p_ca_caps->slot_num = 1;
197 p_ca_caps->slot_type = 1;
198 p_ca_caps->descr_num = slot_cap[7];
199 p_ca_caps->descr_type = 1;
200
201
202 if (copy_to_user((struct ca_caps *)arg, p_ca_caps, sizeof (struct ca_caps))) {
203 return -EFAULT;
204 }
205
206 return 0;
207}
208
209/* Need some more work */
210static int ca_get_slot_descr(struct dst_state *state, struct ca_msg *p_ca_message, void *arg)
211{
212 return -EOPNOTSUPP;
213}
214
215
216static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_slot_info, void *arg)
217{
218 int i;
219 static u8 slot_command[8] = {0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff};
220
221 u8 *slot_info = state->rxbuffer;
222
223 put_checksum(&slot_command[0], 7);
224 if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) {
225 dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__);
226 return -1;
227 }
228 if (verbose > 1)
229 dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__);
230
231 /* Will implement the rest soon */
232
233 if (verbose > 1) {
234 dprintk("%s: Slot info = [%d]\n", __FUNCTION__, slot_info[3]);
235 dprintk("===================================\n");
236 for (i = 0; i < 8; i++)
237 dprintk(" %d", slot_info[i]);
238 dprintk("\n");
239 }
240
241 if (slot_info[4] & 0x80) {
242 p_ca_slot_info->flags = CA_CI_MODULE_PRESENT;
243 p_ca_slot_info->num = 1;
244 p_ca_slot_info->type = CA_CI;
245 }
246 else if (slot_info[4] & 0x40) {
247 p_ca_slot_info->flags = CA_CI_MODULE_READY;
248 p_ca_slot_info->num = 1;
249 p_ca_slot_info->type = CA_CI;
250 }
251 else {
252 p_ca_slot_info->flags = 0;
253 }
254
255 if (copy_to_user((struct ca_slot_info *)arg, p_ca_slot_info, sizeof (struct ca_slot_info))) {
256 return -EFAULT;
257 }
258
259 return 0;
260}
261
262
263
264
265static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, void *arg)
266{
267 u8 i = 0;
268 u32 command = 0;
269
270 if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg)))
271 return -EFAULT;
272
273
274 if (p_ca_message->msg) {
275 if (verbose > 3)
276 dprintk("Message = [%02x %02x %02x]\n", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]);
277
278 for (i = 0; i < 3; i++) {
279 command = command | p_ca_message->msg[i];
280 if (i < 2)
281 command = command << 8;
282 }
283 if (verbose > 3)
284 dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command);
285
286 switch (command) {
287 case CA_APP_INFO:
288 memcpy(p_ca_message->msg, state->messages, 128);
289 if (copy_to_user((void *)arg, p_ca_message, sizeof (struct ca_msg)) )
290 return -EFAULT;
291 break;
292 }
293 }
294
295 return 0;
296}
297
298static int handle_en50221_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer)
299{
300 if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) {
301 hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */
302 hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */
303 }
304 else {
305 hw_buffer->msg[2] = 0x03;
306 hw_buffer->msg[3] = 0x00;
307 }
308 return 0;
309}
310
311static int debug_8820_buffer(struct ca_msg *hw_buffer)
312{
313 unsigned int i;
314
315 dprintk("%s:Debug=[", __FUNCTION__);
316 for (i = 0; i < (hw_buffer->msg[0] + 1); i++)
317 dprintk(" %02x", hw_buffer->msg[i]);
318 dprintk("]\n");
319
320 return 0;
321}
322
323static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 reply)
324{
325 if ((dst_put_ci(state, hw_buffer->msg, (hw_buffer->length + 1), hw_buffer->msg, reply)) < 0) {
326 dprintk("%s: DST-CI Command failed.\n", __FUNCTION__);
327 dprintk("%s: Resetting DST.\n", __FUNCTION__);
328 rdc_reset_state(state);
329 return -1;
330 }
331 if (verbose > 2)
332 dprintk("%s: DST-CI Command succes.\n", __FUNCTION__);
333
334 return 0;
335}
336
337
338static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query)
339{
340 u32 hw_offset, buf_offset, i, k;
341 u32 program_info_length = 0, es_info_length = 0, length = 0, words = 0;
342 u8 found_prog_ca_desc = 0, found_stream_ca_desc = 0, error_condition = 0, hw_buffer_length = 0;
343
344 if (verbose > 3)
345 dprintk("%s, p_ca_message length %d (0x%x)\n", __FUNCTION__,p_ca_message->length,p_ca_message->length );
346
347 handle_en50221_tag(state, p_ca_message, hw_buffer); /* EN50221 tag */
348
349 /* Handle the length field (variable) */
350 if (!(p_ca_message->msg[3] & 0x80)) { /* Length = 1 */
351 length = p_ca_message->msg[3] & 0x7f;
352 words = 0; /* domi's suggestion */
353 }
354 else { /* Length = words */
355 words = p_ca_message->msg[3] & 0x7f;
356 for (i = 0; i < words; i++) {
357 length = length << 8;
358 length = length | p_ca_message->msg[4 + i];
359 }
360 }
361 if (verbose > 4) {
362 dprintk("%s:Length=[%d (0x%x)], Words=[%d]\n", __FUNCTION__, length,length, words);
363
364 /* Debug Input string */
365 for (i = 0; i < length; i++)
366 dprintk(" %02x", p_ca_message->msg[i]);
367 dprintk("]\n");
368 }
369
370 hw_offset = 7;
371 buf_offset = words + 4;
372
373 /* Program Header */
374 if (verbose > 4)
375 dprintk("\n%s:Program Header=[", __FUNCTION__);
376 for (i = 0; i < 6; i++) {
377 hw_buffer->msg[hw_offset] = p_ca_message->msg[buf_offset];
378 if (verbose > 4)
379 dprintk(" %02x", p_ca_message->msg[buf_offset]);
380 hw_offset++, buf_offset++, hw_buffer_length++;
381 }
382 if (verbose > 4)
383 dprintk("]\n");
384
385 program_info_length = 0;
386 program_info_length = (((program_info_length | p_ca_message->msg[words + 8]) & 0x0f) << 8) | p_ca_message->msg[words + 9];
387 if (verbose > 4)
388 dprintk("%s:Program info Length=[%d][%02x], hw_offset=[%d], buf_offset=[%d] \n",
389 __FUNCTION__, program_info_length, program_info_length, hw_offset, buf_offset);
390
391 if (program_info_length && (program_info_length < 256)) { /* If program_info_length */
392 hw_buffer->msg[11] = hw_buffer->msg[11] & 0x0f; /* req only 4 bits */
393 hw_buffer->msg[12] = hw_buffer->msg[12] + 1; /* increment! ASIC bug! */
394
395 if (p_ca_message->msg[buf_offset + 1] == 0x09) { /* Check CA descriptor */
396 found_prog_ca_desc = 1;
397 if (verbose > 4)
398 dprintk("%s: Found CA descriptor @ Program level\n", __FUNCTION__);
399 }
400
401 if (found_prog_ca_desc) { /* Command only if CA descriptor */
402 hw_buffer->msg[13] = p_ca_message->msg[buf_offset]; /* CA PMT command ID */
403 hw_offset++, buf_offset++, hw_buffer_length++;
404 }
405
406 /* Program descriptors */
407 if (verbose > 4) {
408 dprintk("%s:**********>buf_offset=[%d], hw_offset=[%d]\n", __FUNCTION__, buf_offset, hw_offset);
409 dprintk("%s:Program descriptors=[", __FUNCTION__);
410 }
411 while (program_info_length && !error_condition) { /* Copy prog descriptors */
412 if (program_info_length > p_ca_message->length) { /* Error situation */
413 dprintk ("%s:\"WARNING\" Length error, line=[%d], prog_info_length=[%d]\n",
414 __FUNCTION__, __LINE__, program_info_length);
415 dprintk("%s:\"WARNING\" Bailing out of possible loop\n", __FUNCTION__);
416 error_condition = 1;
417 break;
418 }
419
420 hw_buffer->msg[hw_offset] = p_ca_message->msg[buf_offset];
421 dprintk(" %02x", p_ca_message->msg[buf_offset]);
422 hw_offset++, buf_offset++, hw_buffer_length++, program_info_length--;
423 }
424 if (verbose > 4) {
425 dprintk("]\n");
426 dprintk("%s:**********>buf_offset=[%d], hw_offset=[%d]\n", __FUNCTION__, buf_offset, hw_offset);
427 }
428 if (found_prog_ca_desc) {
429 if (!reply) {
430 hw_buffer->msg[13] = 0x01; /* OK descrambling */
431 if (verbose > 1)
432 dprintk("CA PMT Command = OK Descrambling\n");
433 }
434 else {
435 hw_buffer->msg[13] = 0x02; /* Ok MMI */
436 if (verbose > 1)
437 dprintk("CA PMT Command = Ok MMI\n");
438 }
439 if (query) {
440 hw_buffer->msg[13] = 0x03; /* Query */
441 if (verbose > 1)
442 dprintk("CA PMT Command = CA PMT query\n");
443 }
444 }
445 }
446 else {
447 hw_buffer->msg[11] = hw_buffer->msg[11] & 0xf0; /* Don't write to ASIC */
448 hw_buffer->msg[12] = hw_buffer->msg[12] = 0x00;
449 }
450 if (verbose > 4)
451 dprintk("%s:**********>p_ca_message->length=[%d], buf_offset=[%d], hw_offset=[%d]\n",
452 __FUNCTION__, p_ca_message->length, buf_offset, hw_offset);
453
454 while ((buf_offset < p_ca_message->length) && !error_condition) {
455 /* Bail out in case of an indefinite loop */
456 if ((es_info_length > p_ca_message->length) || (buf_offset > p_ca_message->length)) {
457 dprintk("%s:\"WARNING\" Length error, line=[%d], prog_info_length=[%d], buf_offset=[%d]\n",
458 __FUNCTION__, __LINE__, program_info_length, buf_offset);
459
460 dprintk("%s:\"WARNING\" Bailing out of possible loop\n", __FUNCTION__);
461 error_condition = 1;
462 break;
463 }
464
465 /* Stream Header */
466
467 for (k = 0; k < 5; k++) {
468 hw_buffer->msg[hw_offset + k] = p_ca_message->msg[buf_offset + k];
469 }
470
471 es_info_length = 0;
472 es_info_length = (es_info_length | (p_ca_message->msg[buf_offset + 3] & 0x0f)) << 8 | p_ca_message->msg[buf_offset + 4];
473
474 if (verbose > 4) {
475 dprintk("\n%s:----->Stream header=[%02x %02x %02x %02x %02x]\n", __FUNCTION__,
476 p_ca_message->msg[buf_offset + 0], p_ca_message->msg[buf_offset + 1],
477 p_ca_message->msg[buf_offset + 2], p_ca_message->msg[buf_offset + 3],
478 p_ca_message->msg[buf_offset + 4]);
479
480 dprintk("%s:----->Stream type=[%02x], es length=[%d (0x%x)], Chars=[%02x] [%02x], buf_offset=[%d]\n", __FUNCTION__,
481 p_ca_message->msg[buf_offset + 0], es_info_length, es_info_length,
482 p_ca_message->msg[buf_offset + 3], p_ca_message->msg[buf_offset + 4], buf_offset);
483 }
484
485 hw_buffer->msg[hw_offset + 3] &= 0x0f; /* req only 4 bits */
486
487 if (found_prog_ca_desc) {
488 hw_buffer->msg[hw_offset + 3] = 0x00;
489 hw_buffer->msg[hw_offset + 4] = 0x00;
490 }
491
492 hw_offset += 5, buf_offset += 5, hw_buffer_length += 5;
493
494 /* Check for CA descriptor */
495 if (p_ca_message->msg[buf_offset + 1] == 0x09) {
496 if (verbose > 4)
497 dprintk("%s:Found CA descriptor @ Stream level\n", __FUNCTION__);
498 found_stream_ca_desc = 1;
499 }
500
501 /* ES descriptors */
502
503 if (es_info_length && !error_condition && !found_prog_ca_desc && found_stream_ca_desc) {
504// if (!ca_pmt_done) {
505 hw_buffer->msg[hw_offset] = p_ca_message->msg[buf_offset]; /* CA PMT cmd(es) */
506 if (verbose > 4)
507 printk("%s:----->CA PMT Command ID=[%02x]\n", __FUNCTION__, p_ca_message->msg[buf_offset]);
508// hw_offset++, buf_offset++, hw_buffer_length++, es_info_length--, ca_pmt_done = 1;
509 hw_offset++, buf_offset++, hw_buffer_length++, es_info_length--;
510// }
511 if (verbose > 4)
512 dprintk("%s:----->ES descriptors=[", __FUNCTION__);
513
514 while (es_info_length && !error_condition) { /* ES descriptors */
515 if ((es_info_length > p_ca_message->length) || (buf_offset > p_ca_message->length)) {
516 if (verbose > 4) {
517 dprintk("%s:\"WARNING\" ES Length error, line=[%d], es_info_length=[%d], buf_offset=[%d]\n",
518 __FUNCTION__, __LINE__, es_info_length, buf_offset);
519
520 dprintk("%s:\"WARNING\" Bailing out of possible loop\n", __FUNCTION__);
521 }
522 error_condition = 1;
523 break;
524 }
525
526 hw_buffer->msg[hw_offset] = p_ca_message->msg[buf_offset];
527 if (verbose > 3)
528 dprintk("%02x ", hw_buffer->msg[hw_offset]);
529 hw_offset++, buf_offset++, hw_buffer_length++, es_info_length--;
530 }
531 found_stream_ca_desc = 0; /* unset for new streams */
532 dprintk("]\n");
533 }
534 }
535
536 /* MCU Magic words */
537
538 hw_buffer_length += 7;
539 hw_buffer->msg[0] = hw_buffer_length;
540 hw_buffer->msg[1] = 64;
541 hw_buffer->msg[4] = 3;
542 hw_buffer->msg[5] = hw_buffer->msg[0] - 7;
543 hw_buffer->msg[6] = 0;
544
545
546 /* Fix length */
547 hw_buffer->length = hw_buffer->msg[0];
548
549 put_checksum(&hw_buffer->msg[0], hw_buffer->msg[0]);
550 /* Do the actual write */
551 if (verbose > 4) {
552 dprintk("%s:======================DEBUGGING================================\n", __FUNCTION__);
553 dprintk("%s: Actual Length=[%d]\n", __FUNCTION__, hw_buffer_length);
554 }
555 /* Only for debugging! */
556 if (verbose > 2)
557 debug_8820_buffer(hw_buffer);
558 if (verbose > 3)
559 dprintk("%s: Reply = [%d]\n", __FUNCTION__, reply);
560 write_to_8820(state, hw_buffer, reply);
561
562 return 0;
563}
564
565/* Board supports CA PMT reply ? */
566static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer)
567{
568 int ca_pmt_reply_test = 0;
569
570 /* Do test board */
571 /* Not there yet but soon */
572
573
574 /* CA PMT Reply capable */
575 if (ca_pmt_reply_test) {
576 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 1, GET_REPLY)) < 0) {
577 dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__);
578 return -1;
579 }
580
581 /* Process CA PMT Reply */
582 /* will implement soon */
583 dprintk("%s: Not there yet\n", __FUNCTION__);
584 }
585 /* CA PMT Reply not capable */
586 if (!ca_pmt_reply_test) {
587 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, NO_REPLY)) < 0) {
588 dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__);
589 return -1;
590 }
591 if (verbose > 3)
592 dprintk("%s: ca_set_pmt.. success !\n", __FUNCTION__);
593 /* put a dummy message */
594
595 }
596 return 0;
597}
598
599static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, void *arg)
600{
601 int i = 0;
602 unsigned int ca_message_header_len;
603
604 u32 command = 0;
605 struct ca_msg *hw_buffer;
606
607 if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) {
608 printk("%s: Memory allocation failure\n", __FUNCTION__);
609 return -ENOMEM;
610 }
611 if (verbose > 3)
612 dprintk("%s\n", __FUNCTION__);
613
614 if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg)))
615 return -EFAULT;
616
617 if (p_ca_message->msg) {
618 ca_message_header_len = p_ca_message->length; /* Restore it back when you are done */
619 /* EN50221 tag */
620 command = 0;
621
622 for (i = 0; i < 3; i++) {
623 command = command | p_ca_message->msg[i];
624 if (i < 2)
625 command = command << 8;
626 }
627 if (verbose > 3)
628 dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command);
629
630 switch (command) {
631 case CA_PMT:
632 if (verbose > 3)
633 dprintk("Command = SEND_CA_PMT\n");
634 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) {
635 dprintk("%s: -->CA_PMT Failed !\n", __FUNCTION__);
636 return -1;
637 }
638 if (verbose > 3)
639 dprintk("%s: -->CA_PMT Success !\n", __FUNCTION__);
640// retval = dummy_set_pmt(state, p_ca_message, hw_buffer, 0, 0);
641
642 break;
643
644 case CA_PMT_REPLY:
645 if (verbose > 3)
646 dprintk("Command = CA_PMT_REPLY\n");
647 /* Have to handle the 2 basic types of cards here */
648 if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) {
649 dprintk("%s: -->CA_PMT_REPLY Failed !\n", __FUNCTION__);
650 return -1;
651 }
652 if (verbose > 3)
653 dprintk("%s: -->CA_PMT_REPLY Success !\n", __FUNCTION__);
654
655 /* Certain boards do behave different ? */
656// retval = ca_set_pmt(state, p_ca_message, hw_buffer, 1, 1);
657
658 case CA_APP_INFO_ENQUIRY: // only for debugging
659 if (verbose > 3)
660 dprintk("%s: Getting Cam Application information\n", __FUNCTION__);
661
662 if ((ca_get_app_info(state)) < 0) {
663 dprintk("%s: -->CA_APP_INFO_ENQUIRY Failed !\n", __FUNCTION__);
664 return -1;
665 }
666 if (verbose > 3)
667 printk("%s: -->CA_APP_INFO_ENQUIRY Success !\n", __FUNCTION__);
668
669 break;
670 }
671 }
672 return 0;
673}
674
675static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg)
676{
677 struct dvb_device* dvbdev = (struct dvb_device*) file->private_data;
678 struct dst_state* state = (struct dst_state*) dvbdev->priv;
679 struct ca_slot_info *p_ca_slot_info;
680 struct ca_caps *p_ca_caps;
681 struct ca_msg *p_ca_message;
682
683 if ((p_ca_message = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) {
684 printk("%s: Memory allocation failure\n", __FUNCTION__);
685 return -ENOMEM;
686 }
687
688 if ((p_ca_slot_info = (struct ca_slot_info *) kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL)) == NULL) {
689 printk("%s: Memory allocation failure\n", __FUNCTION__);
690 return -ENOMEM;
691 }
692
693 if ((p_ca_caps = (struct ca_caps *) kmalloc(sizeof (struct ca_caps), GFP_KERNEL)) == NULL) {
694 printk("%s: Memory allocation failure\n", __FUNCTION__);
695 return -ENOMEM;
696 }
697
698 /* We have now only the standard ioctl's, the driver is upposed to handle internals. */
699 switch (cmd) {
700 case CA_SEND_MSG:
701 if (verbose > 1)
702 dprintk("%s: Sending message\n", __FUNCTION__);
703 if ((ca_send_message(state, p_ca_message, arg)) < 0) {
704 dprintk("%s: -->CA_SEND_MSG Failed !\n", __FUNCTION__);
705 return -1;
706 }
707
708 break;
709
710 case CA_GET_MSG:
711 if (verbose > 1)
712 dprintk("%s: Getting message\n", __FUNCTION__);
713 if ((ca_get_message(state, p_ca_message, arg)) < 0) {
714 dprintk("%s: -->CA_GET_MSG Failed !\n", __FUNCTION__);
715 return -1;
716 }
717 if (verbose > 1)
718 dprintk("%s: -->CA_GET_MSG Success !\n", __FUNCTION__);
719
720 break;
721
722 case CA_RESET:
723 if (verbose > 1)
724 dprintk("%s: Resetting DST\n", __FUNCTION__);
725 dst_error_bailout(state);
726 msleep(4000);
727
728 break;
729
730 case CA_GET_SLOT_INFO:
731 if (verbose > 1)
732 dprintk("%s: Getting Slot info\n", __FUNCTION__);
733 if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) {
734 dprintk("%s: -->CA_GET_SLOT_INFO Failed !\n", __FUNCTION__);
735 return -1;
736 }
737 if (verbose > 1)
738 dprintk("%s: -->CA_GET_SLOT_INFO Success !\n", __FUNCTION__);
739
740 break;
741
742 case CA_GET_CAP:
743 if (verbose > 1)
744 dprintk("%s: Getting Slot capabilities\n", __FUNCTION__);
745 if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) {
746 dprintk("%s: -->CA_GET_CAP Failed !\n", __FUNCTION__);
747 return -1;
748 }
749 if (verbose > 1)
750 dprintk("%s: -->CA_GET_CAP Success !\n", __FUNCTION__);
751
752 break;
753
754 case CA_GET_DESCR_INFO:
755 if (verbose > 1)
756 dprintk("%s: Getting descrambler description\n", __FUNCTION__);
757 if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) {
758 dprintk("%s: -->CA_GET_DESCR_INFO Failed !\n", __FUNCTION__);
759 return -1;
760 }
761 if (verbose > 1)
762 dprintk("%s: -->CA_GET_DESCR_INFO Success !\n", __FUNCTION__);
763
764 break;
765
766 case CA_SET_DESCR:
767 if (verbose > 1)
768 dprintk("%s: Setting descrambler\n", __FUNCTION__);
769 if ((ca_set_slot_descr()) < 0) {
770 dprintk("%s: -->CA_SET_DESCR Failed !\n", __FUNCTION__);
771 return -1;
772 }
773 if (verbose > 1)
774 dprintk("%s: -->CA_SET_DESCR Success !\n", __FUNCTION__);
775
776 break;
777
778 case CA_SET_PID:
779 if (verbose > 1)
780 dprintk("%s: Setting PID\n", __FUNCTION__);
781 if ((ca_set_pid()) < 0) {
782 dprintk("%s: -->CA_SET_PID Failed !\n", __FUNCTION__);
783 return -1;
784 }
785 if (verbose > 1)
786 dprintk("%s: -->CA_SET_PID Success !\n", __FUNCTION__);
787
788 default:
789 return -EOPNOTSUPP;
790 };
791
792 return 0;
793}
794
795static int dst_ca_open(struct inode *inode, struct file *file)
796{
797 if (verbose > 4)
798 dprintk("%s:Device opened [%p]\n", __FUNCTION__, file);
799 try_module_get(THIS_MODULE);
800
801 return 0;
802}
803
804static int dst_ca_release(struct inode *inode, struct file *file)
805{
806 if (verbose > 4)
807 dprintk("%s:Device closed.\n", __FUNCTION__);
808 module_put(THIS_MODULE);
809
810 return 0;
811}
812
813static int dst_ca_read(struct file *file, char __user * buffer, size_t length, loff_t * offset)
814{
815 int bytes_read = 0;
816
817 if (verbose > 4)
818 dprintk("%s:Device read.\n", __FUNCTION__);
819
820 return bytes_read;
821}
822
823static int dst_ca_write(struct file *file, const char __user * buffer, size_t length, loff_t * offset)
824{
825 if (verbose > 4)
826 dprintk("%s:Device write.\n", __FUNCTION__);
827
828 return 0;
829}
830
831static struct file_operations dst_ca_fops = {
832 .owner = THIS_MODULE,
833 .ioctl = (void *)dst_ca_ioctl,
834 .open = dst_ca_open,
835 .release = dst_ca_release,
836 .read = dst_ca_read,
837 .write = dst_ca_write
838};
839
840static struct dvb_device dvbdev_ca = {
841 .priv = NULL,
842 .users = 1,
843 .readers = 1,
844 .writers = 1,
845 .fops = &dst_ca_fops
846};
847
848int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter)
849{
850 struct dvb_device *dvbdev;
851 if (verbose > 4)
852 dprintk("%s:registering DST-CA device\n", __FUNCTION__);
853 dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA);
854 return 0;
855}
856
857EXPORT_SYMBOL(dst_ca_attach);
858
859MODULE_DESCRIPTION("DST DVB-S/T/C Combo CA driver");
860MODULE_AUTHOR("Manu Abraham");
861MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/bt8xx/dst_ca.h b/drivers/media/dvb/bt8xx/dst_ca.h
new file mode 100644
index 000000000000..59cd0ddd6d8e
--- /dev/null
+++ b/drivers/media/dvb/bt8xx/dst_ca.h
@@ -0,0 +1,58 @@
1/*
2 CA-driver for TwinHan DST Frontend/Card
3
4 Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.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; 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., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#ifndef _DST_CA_H_
22#define _DST_CA_H_
23
24#define RETRIES 5
25
26
27#define CA_APP_INFO_ENQUIRY 0x9f8020
28#define CA_APP_INFO 0x9f8021
29#define CA_ENTER_MENU 0x9f8022
30#define CA_INFO_ENQUIRY 0x9f8030
31#define CA_INFO 0x9f8031
32#define CA_PMT 0x9f8032
33#define CA_PMT_REPLY 0x9f8033
34
35#define CA_CLOSE_MMI 0x9f8800
36#define CA_DISPLAY_CONTROL 0x9f8801
37#define CA_DISPLAY_REPLY 0x9f8802
38#define CA_TEXT_LAST 0x9f8803
39#define CA_TEXT_MORE 0x9f8804
40#define CA_KEYPAD_CONTROL 0x9f8805
41#define CA_KEYPRESS 0x9f8806
42
43#define CA_ENQUIRY 0x9f8807
44#define CA_ANSWER 0x9f8808
45#define CA_MENU_LAST 0x9f8809
46#define CA_MENU_MORE 0x9f880a
47#define CA_MENU_ANSWER 0x9f880b
48#define CA_LIST_LAST 0x9f880c
49#define CA_LIST_MORE 0x9f880d
50
51
52struct dst_ca_private {
53 struct dst_state *dst;
54 struct dvb_device *dvbdev;
55};
56
57
58#endif
diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h
new file mode 100644
index 000000000000..0b3da29245fb
--- /dev/null
+++ b/drivers/media/dvb/bt8xx/dst_common.h
@@ -0,0 +1,153 @@
1/*
2 Frontend-driver for TwinHan DST Frontend
3
4 Copyright (C) 2003 Jamie Honan
5 Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com)
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License 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
22#ifndef DST_COMMON_H
23#define DST_COMMON_H
24
25#include <linux/dvb/frontend.h>
26#include <linux/device.h>
27#include "bt878.h"
28
29#include "dst_ca.h"
30
31
32#define NO_DELAY 0
33#define LONG_DELAY 1
34#define DEVICE_INIT 2
35
36#define DELAY 1
37
38#define DST_TYPE_IS_SAT 0
39#define DST_TYPE_IS_TERR 1
40#define DST_TYPE_IS_CABLE 2
41#define DST_TYPE_IS_ATSC 3
42
43#define DST_TYPE_HAS_NEWTUNE 1
44#define DST_TYPE_HAS_TS204 2
45#define DST_TYPE_HAS_SYMDIV 4
46#define DST_TYPE_HAS_FW_1 8
47#define DST_TYPE_HAS_FW_2 16
48#define DST_TYPE_HAS_FW_3 32
49#define DST_TYPE_HAS_FW_BUILD 64
50
51/* Card capability list */
52
53#define DST_TYPE_HAS_MAC 1
54#define DST_TYPE_HAS_DISEQC3 2
55#define DST_TYPE_HAS_DISEQC4 4
56#define DST_TYPE_HAS_DISEQC5 8
57#define DST_TYPE_HAS_MOTO 16
58#define DST_TYPE_HAS_CA 32
59#define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */
60#define DST_TYPE_HAS_SESSION 128
61
62
63#define RDC_8820_PIO_0_DISABLE 0
64#define RDC_8820_PIO_0_ENABLE 1
65#define RDC_8820_INT 2
66#define RDC_8820_RESET 4
67
68/* DST Communication */
69#define GET_REPLY 1
70#define NO_REPLY 0
71
72#define GET_ACK 1
73#define FIXED_COMM 8
74
75#define ACK 0xff
76
77struct dst_state {
78
79 struct i2c_adapter* i2c;
80
81 struct bt878* bt;
82
83 struct dvb_frontend_ops ops;
84
85 /* configuration settings */
86 const struct dst_config* config;
87
88 struct dvb_frontend frontend;
89
90 /* private ASIC data */
91 u8 tx_tuna[10];
92 u8 rx_tuna[10];
93 u8 rxbuffer[10];
94 u8 diseq_flags;
95 u8 dst_type;
96 u32 type_flags;
97 u32 frequency; /* intermediate frequency in kHz for QPSK */
98 fe_spectral_inversion_t inversion;
99 u32 symbol_rate; /* symbol rate in Symbols per second */
100 fe_code_rate_t fec;
101 fe_sec_voltage_t voltage;
102 fe_sec_tone_mode_t tone;
103 u32 decode_freq;
104 u8 decode_lock;
105 u16 decode_strength;
106 u16 decode_snr;
107 unsigned long cur_jiff;
108 u8 k22;
109 fe_bandwidth_t bandwidth;
110 u32 dst_hw_cap;
111 u8 dst_fw_version;
112 fe_sec_mini_cmd_t minicmd;
113 u8 messages[256];
114};
115
116struct dst_types {
117 char *device_id;
118 int offset;
119 u8 dst_type;
120 u32 type_flags;
121 u32 dst_feature;
122};
123
124
125
126struct dst_config
127{
128 /* the ASIC i2c address */
129 u8 demod_address;
130};
131
132
133int rdc_reset_state(struct dst_state *state);
134int rdc_8820_reset(struct dst_state *state);
135
136int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode);
137int dst_pio_enable(struct dst_state *state);
138int dst_pio_disable(struct dst_state *state);
139int dst_error_recovery(struct dst_state* state);
140int dst_error_bailout(struct dst_state *state);
141int dst_comm_init(struct dst_state* state);
142
143int write_dst(struct dst_state *state, u8 * data, u8 len);
144int read_dst(struct dst_state *state, u8 * ret, u8 len);
145u8 dst_check_sum(u8 * buf, u32 len);
146struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter);
147int dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter);
148int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay);
149
150int dst_command(struct dst_state* state, u8 * data, u8 len);
151
152
153#endif // DST_COMMON_H
diff --git a/drivers/media/dvb/bt8xx/dst_priv.h b/drivers/media/dvb/bt8xx/dst_priv.h
index 80488aa628b4..3974a4c6ebe7 100644
--- a/drivers/media/dvb/bt8xx/dst_priv.h
+++ b/drivers/media/dvb/bt8xx/dst_priv.h
@@ -33,4 +33,3 @@ union dst_gpio_packet {
33struct bt878; 33struct bt878;
34 34
35int bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *mp); 35int bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *mp);
36
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index b735397f59aa..6f857c6091f3 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -142,7 +142,7 @@ static int thomson_dtt7579_demod_init(struct dvb_frontend* fe)
142 mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg)); 142 mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
143 143
144 mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg)); 144 mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
145 mt352_write(fe, mt352_gpp_ctl_cfg, sizeof(mt352_gpp_ctl_cfg)); 145 mt352_write(fe, mt352_gpp_ctl_cfg, sizeof(mt352_gpp_ctl_cfg));
146 mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg)); 146 mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
147 147
148 return 0; 148 return 0;
@@ -161,7 +161,7 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_
161 else if (params->frequency < 771000000) cp = 0xbc; 161 else if (params->frequency < 771000000) cp = 0xbc;
162 else cp = 0xf4; 162 else cp = 0xf4;
163 163
164 if (params->frequency == 0) bs = 0x03; 164 if (params->frequency == 0) bs = 0x03;
165 else if (params->frequency < 443250000) bs = 0x02; 165 else if (params->frequency < 443250000) bs = 0x02;
166 else bs = 0x08; 166 else bs = 0x08;
167 167
@@ -190,44 +190,44 @@ static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_paramete
190 190
191 191
192 u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000, 192 u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
193 1576000,1718000,1856000,2036000,2150000}; 193 1576000,1718000,1856000,2036000,2150000};
194 u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000, 194 u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
195 0x00102000,0x00104000,0x00108000,0x00110000, 195 0x00102000,0x00104000,0x00108000,0x00110000,
196 0x00120000,0x00140000}; 196 0x00120000,0x00140000};
197 197
198#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */ 198#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
199 printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq); 199 printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq);
200 200
201 /* This is really the bit driving the tuner chip cx24108 */ 201 /* This is really the bit driving the tuner chip cx24108 */
202 202
203 if(freq<950000) freq=950000; /* kHz */ 203 if(freq<950000) freq=950000; /* kHz */
204 if(freq>2150000) freq=2150000; /* satellite IF is 950..2150MHz */ 204 if(freq>2150000) freq=2150000; /* satellite IF is 950..2150MHz */
205 205
206 /* decide which VCO to use for the input frequency */ 206 /* decide which VCO to use for the input frequency */
207 for(i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++); 207 for(i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++);
208 printk("cx24108 debug: select vco #%d (f=%d)\n",i,freq); 208 printk("cx24108 debug: select vco #%d (f=%d)\n",i,freq);
209 band=bandsel[i]; 209 band=bandsel[i];
210 /* the gain values must be set by SetSymbolrate */ 210 /* the gain values must be set by SetSymbolrate */
211 /* compute the pll divider needed, from Conexant data sheet, 211 /* compute the pll divider needed, from Conexant data sheet,
212 resolved for (n*32+a), remember f(vco) is f(receive) *2 or *4, 212 resolved for (n*32+a), remember f(vco) is f(receive) *2 or *4,
213 depending on the divider bit. It is set to /4 on the 2 lowest 213 depending on the divider bit. It is set to /4 on the 2 lowest
214 bands */ 214 bands */
215 n=((i<=2?2:1)*freq*10L)/(XTAL/100); 215 n=((i<=2?2:1)*freq*10L)/(XTAL/100);
216 a=n%32; n/=32; if(a==0) n--; 216 a=n%32; n/=32; if(a==0) n--;
217 pump=(freq<(osci[i-1]+osci[i])/2); 217 pump=(freq<(osci[i-1]+osci[i])/2);
218 pll=0xf8000000| 218 pll=0xf8000000|
219 ((pump?1:2)<<(14+11))| 219 ((pump?1:2)<<(14+11))|
220 ((n&0x1ff)<<(5+11))| 220 ((n&0x1ff)<<(5+11))|
221 ((a&0x1f)<<11); 221 ((a&0x1f)<<11);
222 /* everything is shifted left 11 bits to left-align the bits in the 222 /* everything is shifted left 11 bits to left-align the bits in the
223 32bit word. Output to the tuner goes MSB-aligned, after all */ 223 32bit word. Output to the tuner goes MSB-aligned, after all */
224 printk("cx24108 debug: pump=%d, n=%d, a=%d\n",pump,n,a); 224 printk("cx24108 debug: pump=%d, n=%d, a=%d\n",pump,n,a);
225 cx24110_pll_write(fe,band); 225 cx24110_pll_write(fe,band);
226 /* set vga and vca to their widest-band settings, as a precaution. 226 /* set vga and vca to their widest-band settings, as a precaution.
227 SetSymbolrate might not be called to set this up */ 227 SetSymbolrate might not be called to set this up */
228 cx24110_pll_write(fe,0x500c0000); 228 cx24110_pll_write(fe,0x500c0000);
229 cx24110_pll_write(fe,0x83f1f800); 229 cx24110_pll_write(fe,0x83f1f800);
230 cx24110_pll_write(fe,pll); 230 cx24110_pll_write(fe,pll);
231/* writereg(client,0x56,0x7f);*/ 231/* writereg(client,0x56,0x7f);*/
232 232
233 return 0; 233 return 0;
@@ -299,7 +299,7 @@ static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
299 static u8 mt352_reset [] = { 0x50, 0x80 }; 299 static u8 mt352_reset [] = { 0x50, 0x80 };
300 static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 }; 300 static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
301 static u8 mt352_agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF, 301 static u8 mt352_agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
302 0x00, 0xFF, 0x00, 0x40, 0x40 }; 302 0x00, 0xFF, 0x00, 0x40, 0x40 };
303 static u8 mt352_av771_extra[] = { 0xB5, 0x7A }; 303 static u8 mt352_av771_extra[] = { 0xB5, 0x7A };
304 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; 304 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
305 305
@@ -463,6 +463,9 @@ static struct nxt6000_config vp3021_alps_tded4_config = {
463 463
464static void frontend_init(struct dvb_bt8xx_card *card, u32 type) 464static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
465{ 465{
466 int ret;
467 struct dst_state* state = NULL;
468
466 switch(type) { 469 switch(type) {
467#ifdef BTTV_DVICO_DVBT_LITE 470#ifdef BTTV_DVICO_DVBT_LITE
468 case BTTV_DVICO_DVBT_LITE: 471 case BTTV_DVICO_DVBT_LITE:
@@ -503,7 +506,25 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
503 break; 506 break;
504 507
505 case BTTV_TWINHAN_DST: 508 case BTTV_TWINHAN_DST:
506 card->fe = dst_attach(&dst_config, card->i2c_adapter, card->bt); 509 /* DST is not a frontend driver !!! */
510 state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
511 /* Setup the Card */
512 state->config = &dst_config;
513 state->i2c = card->i2c_adapter;
514 state->bt = card->bt;
515
516 /* DST is not a frontend, attaching the ASIC */
517 if ((dst_attach(state, &card->dvb_adapter)) == NULL) {
518 printk("%s: Could not find a Twinhan DST.\n", __FUNCTION__);
519 break;
520 }
521 card->fe = &state->frontend;
522
523 /* Attach other DST peripherals if any */
524 /* Conditional Access device */
525 if (state->dst_hw_cap & DST_TYPE_HAS_CA) {
526 ret = dst_ca_attach(state, &card->dvb_adapter);
527 }
507 if (card->fe != NULL) { 528 if (card->fe != NULL) {
508 break; 529 break;
509 } 530 }
@@ -531,7 +552,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
531 card->bt->dev->subsystem_vendor, 552 card->bt->dev->subsystem_vendor,
532 card->bt->dev->subsystem_device); 553 card->bt->dev->subsystem_device);
533 } else { 554 } else {
534 if (dvb_register_frontend(card->dvb_adapter, card->fe)) { 555 if (dvb_register_frontend(&card->dvb_adapter, card->fe)) {
535 printk("dvb-bt8xx: Frontend registration failed!\n"); 556 printk("dvb-bt8xx: Frontend registration failed!\n");
536 if (card->fe->ops->release) 557 if (card->fe->ops->release)
537 card->fe->ops->release(card->fe); 558 card->fe->ops->release(card->fe);
@@ -550,7 +571,7 @@ static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
550 return result; 571 return result;
551 572
552 } 573 }
553 card->dvb_adapter->priv = card; 574 card->dvb_adapter.priv = card;
554 575
555 card->bt->adapter = card->i2c_adapter; 576 card->bt->adapter = card->i2c_adapter;
556 577
@@ -568,7 +589,7 @@ static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
568 if ((result = dvb_dmx_init(&card->demux)) < 0) { 589 if ((result = dvb_dmx_init(&card->demux)) < 0) {
569 printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result); 590 printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result);
570 591
571 dvb_unregister_adapter(card->dvb_adapter); 592 dvb_unregister_adapter(&card->dvb_adapter);
572 return result; 593 return result;
573 } 594 }
574 595
@@ -576,11 +597,11 @@ static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
576 card->dmxdev.demux = &card->demux.dmx; 597 card->dmxdev.demux = &card->demux.dmx;
577 card->dmxdev.capabilities = 0; 598 card->dmxdev.capabilities = 0;
578 599
579 if ((result = dvb_dmxdev_init(&card->dmxdev, card->dvb_adapter)) < 0) { 600 if ((result = dvb_dmxdev_init(&card->dmxdev, &card->dvb_adapter)) < 0) {
580 printk("dvb_bt8xx: dvb_dmxdev_init failed (errno = %d)\n", result); 601 printk("dvb_bt8xx: dvb_dmxdev_init failed (errno = %d)\n", result);
581 602
582 dvb_dmx_release(&card->demux); 603 dvb_dmx_release(&card->demux);
583 dvb_unregister_adapter(card->dvb_adapter); 604 dvb_unregister_adapter(&card->dvb_adapter);
584 return result; 605 return result;
585 } 606 }
586 607
@@ -591,7 +612,7 @@ static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
591 612
592 dvb_dmxdev_release(&card->dmxdev); 613 dvb_dmxdev_release(&card->dmxdev);
593 dvb_dmx_release(&card->demux); 614 dvb_dmx_release(&card->demux);
594 dvb_unregister_adapter(card->dvb_adapter); 615 dvb_unregister_adapter(&card->dvb_adapter);
595 return result; 616 return result;
596 } 617 }
597 618
@@ -603,7 +624,7 @@ static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
603 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); 624 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
604 dvb_dmxdev_release(&card->dmxdev); 625 dvb_dmxdev_release(&card->dmxdev);
605 dvb_dmx_release(&card->demux); 626 dvb_dmx_release(&card->demux);
606 dvb_unregister_adapter(card->dvb_adapter); 627 dvb_unregister_adapter(&card->dvb_adapter);
607 return result; 628 return result;
608 } 629 }
609 630
@@ -614,11 +635,11 @@ static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
614 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); 635 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
615 dvb_dmxdev_release(&card->dmxdev); 636 dvb_dmxdev_release(&card->dmxdev);
616 dvb_dmx_release(&card->demux); 637 dvb_dmx_release(&card->demux);
617 dvb_unregister_adapter(card->dvb_adapter); 638 dvb_unregister_adapter(&card->dvb_adapter);
618 return result; 639 return result;
619 } 640 }
620 641
621 dvb_net_init(card->dvb_adapter, &card->dvbnet, &card->demux.dmx); 642 dvb_net_init(&card->dvb_adapter, &card->dvbnet, &card->demux.dmx);
622 643
623 tasklet_init(&card->bt->tasklet, dvb_bt8xx_task, (unsigned long) card); 644 tasklet_init(&card->bt->tasklet, dvb_bt8xx_task, (unsigned long) card);
624 645
@@ -648,7 +669,7 @@ static int dvb_bt8xx_probe(struct device *dev)
648 case BTTV_PINNACLESAT: 669 case BTTV_PINNACLESAT:
649 card->gpio_mode = 0x0400c060; 670 card->gpio_mode = 0x0400c060;
650 /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR, 671 /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR,
651 BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */ 672 BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */
652 card->op_sync_orin = 0; 673 card->op_sync_orin = 0;
653 card->irq_err_ignore = 0; 674 card->irq_err_ignore = 0;
654 break; 675 break;
@@ -759,7 +780,7 @@ static int dvb_bt8xx_remove(struct device *dev)
759 dvb_dmxdev_release(&card->dmxdev); 780 dvb_dmxdev_release(&card->dmxdev);
760 dvb_dmx_release(&card->demux); 781 dvb_dmx_release(&card->demux);
761 if (card->fe) dvb_unregister_frontend(card->fe); 782 if (card->fe) dvb_unregister_frontend(card->fe);
762 dvb_unregister_adapter(card->dvb_adapter); 783 dvb_unregister_adapter(&card->dvb_adapter);
763 784
764 kfree(card); 785 kfree(card);
765 786
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.h b/drivers/media/dvb/bt8xx/dvb-bt8xx.h
index 80ef189f930f..2923b3b0dd3c 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.h
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.h
@@ -31,7 +31,7 @@
31#include "bttv.h" 31#include "bttv.h"
32#include "mt352.h" 32#include "mt352.h"
33#include "sp887x.h" 33#include "sp887x.h"
34#include "dst.h" 34#include "dst_common.h"
35#include "nxt6000.h" 35#include "nxt6000.h"
36#include "cx24110.h" 36#include "cx24110.h"
37#include "or51211.h" 37#include "or51211.h"
@@ -40,7 +40,7 @@ struct dvb_bt8xx_card {
40 struct semaphore lock; 40 struct semaphore lock;
41 int nfeeds; 41 int nfeeds;
42 char card_name[32]; 42 char card_name[32];
43 struct dvb_adapter *dvb_adapter; 43 struct dvb_adapter dvb_adapter;
44 struct bt878 *bt; 44 struct bt878 *bt;
45 unsigned int bttv_nr; 45 unsigned int bttv_nr;
46 struct dvb_demux demux; 46 struct dvb_demux demux;
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index 28d4d926de3e..96c57fde95a0 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -119,7 +119,7 @@ struct cinergyt2 {
119 struct dvb_demux demux; 119 struct dvb_demux demux;
120 struct usb_device *udev; 120 struct usb_device *udev;
121 struct semaphore sem; 121 struct semaphore sem;
122 struct dvb_adapter *adapter; 122 struct dvb_adapter adapter;
123 struct dvb_device *fedev; 123 struct dvb_device *fedev;
124 struct dmxdev dmxdev; 124 struct dmxdev dmxdev;
125 struct dvb_net dvbnet; 125 struct dvb_net dvbnet;
@@ -813,15 +813,15 @@ static int cinergyt2_probe (struct usb_interface *intf,
813 cinergyt2->dmxdev.demux = &cinergyt2->demux.dmx; 813 cinergyt2->dmxdev.demux = &cinergyt2->demux.dmx;
814 cinergyt2->dmxdev.capabilities = 0; 814 cinergyt2->dmxdev.capabilities = 0;
815 815
816 if ((err = dvb_dmxdev_init(&cinergyt2->dmxdev, cinergyt2->adapter)) < 0) { 816 if ((err = dvb_dmxdev_init(&cinergyt2->dmxdev, &cinergyt2->adapter)) < 0) {
817 dprintk(1, "dvb_dmxdev_init() failed (err = %d)\n", err); 817 dprintk(1, "dvb_dmxdev_init() failed (err = %d)\n", err);
818 goto bailout; 818 goto bailout;
819 } 819 }
820 820
821 if (dvb_net_init(cinergyt2->adapter, &cinergyt2->dvbnet, &cinergyt2->demux.dmx)) 821 if (dvb_net_init(&cinergyt2->adapter, &cinergyt2->dvbnet, &cinergyt2->demux.dmx))
822 dprintk(1, "dvb_net_init() failed!\n"); 822 dprintk(1, "dvb_net_init() failed!\n");
823 823
824 dvb_register_device(cinergyt2->adapter, &cinergyt2->fedev, 824 dvb_register_device(&cinergyt2->adapter, &cinergyt2->fedev,
825 &cinergyt2_fe_template, cinergyt2, 825 &cinergyt2_fe_template, cinergyt2,
826 DVB_DEVICE_FRONTEND); 826 DVB_DEVICE_FRONTEND);
827 827
@@ -848,7 +848,7 @@ static int cinergyt2_probe (struct usb_interface *intf,
848bailout: 848bailout:
849 dvb_dmxdev_release(&cinergyt2->dmxdev); 849 dvb_dmxdev_release(&cinergyt2->dmxdev);
850 dvb_dmx_release(&cinergyt2->demux); 850 dvb_dmx_release(&cinergyt2->demux);
851 dvb_unregister_adapter (cinergyt2->adapter); 851 dvb_unregister_adapter (&cinergyt2->adapter);
852 cinergyt2_free_stream_urbs (cinergyt2); 852 cinergyt2_free_stream_urbs (cinergyt2);
853 kfree(cinergyt2); 853 kfree(cinergyt2);
854 return -ENOMEM; 854 return -ENOMEM;
@@ -872,7 +872,7 @@ static void cinergyt2_disconnect (struct usb_interface *intf)
872 dvb_dmxdev_release(&cinergyt2->dmxdev); 872 dvb_dmxdev_release(&cinergyt2->dmxdev);
873 dvb_dmx_release(&cinergyt2->demux); 873 dvb_dmx_release(&cinergyt2->demux);
874 dvb_unregister_device(cinergyt2->fedev); 874 dvb_unregister_device(cinergyt2->fedev);
875 dvb_unregister_adapter(cinergyt2->adapter); 875 dvb_unregister_adapter(&cinergyt2->adapter);
876 876
877 cinergyt2_free_stream_urbs(cinergyt2); 877 cinergyt2_free_stream_urbs(cinergyt2);
878 up(&cinergyt2->sem); 878 up(&cinergyt2->sem);
diff --git a/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c b/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c
index 04e54ec093f0..400b439e804e 100644
--- a/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c
+++ b/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c
@@ -131,7 +131,7 @@ int dibusb_dvb_init(struct usb_dibusb *dib)
131 deb_info("dvb_register_adapter failed: error %d", ret); 131 deb_info("dvb_register_adapter failed: error %d", ret);
132 goto err; 132 goto err;
133 } 133 }
134 dib->adapter->priv = dib; 134 dib->adapter.priv = dib;
135 135
136/* i2c is done in dibusb_i2c_init */ 136/* i2c is done in dibusb_i2c_init */
137 137
@@ -151,18 +151,18 @@ int dibusb_dvb_init(struct usb_dibusb *dib)
151 dib->dmxdev.filternum = dib->demux.filternum; 151 dib->dmxdev.filternum = dib->demux.filternum;
152 dib->dmxdev.demux = &dib->demux.dmx; 152 dib->dmxdev.demux = &dib->demux.dmx;
153 dib->dmxdev.capabilities = 0; 153 dib->dmxdev.capabilities = 0;
154 if ((ret = dvb_dmxdev_init(&dib->dmxdev, dib->adapter)) < 0) { 154 if ((ret = dvb_dmxdev_init(&dib->dmxdev, &dib->adapter)) < 0) {
155 err("dvb_dmxdev_init failed: error %d",ret); 155 err("dvb_dmxdev_init failed: error %d",ret);
156 goto err_dmx_dev; 156 goto err_dmx_dev;
157 } 157 }
158 158
159 dvb_net_init(dib->adapter, &dib->dvb_net, &dib->demux.dmx); 159 dvb_net_init(&dib->adapter, &dib->dvb_net, &dib->demux.dmx);
160 160
161 goto success; 161 goto success;
162err_dmx_dev: 162err_dmx_dev:
163 dvb_dmx_release(&dib->demux); 163 dvb_dmx_release(&dib->demux);
164err_dmx: 164err_dmx:
165 dvb_unregister_adapter(dib->adapter); 165 dvb_unregister_adapter(&dib->adapter);
166err: 166err:
167 return ret; 167 return ret;
168success: 168success:
@@ -179,7 +179,7 @@ int dibusb_dvb_exit(struct usb_dibusb *dib)
179 dib->demux.dmx.close(&dib->demux.dmx); 179 dib->demux.dmx.close(&dib->demux.dmx);
180 dvb_dmxdev_release(&dib->dmxdev); 180 dvb_dmxdev_release(&dib->dmxdev);
181 dvb_dmx_release(&dib->demux); 181 dvb_dmx_release(&dib->demux);
182 dvb_unregister_adapter(dib->adapter); 182 dvb_unregister_adapter(&dib->adapter);
183 } 183 }
184 return 0; 184 return 0;
185} 185}
diff --git a/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c b/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c
index 2ed89488c7c4..5a71b88797d9 100644
--- a/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c
+++ b/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c
@@ -183,7 +183,7 @@ int dibusb_fe_init(struct usb_dibusb* dib)
183 dib->dibdev->name); 183 dib->dibdev->name);
184 return -ENODEV; 184 return -ENODEV;
185 } else { 185 } else {
186 if (dvb_register_frontend(dib->adapter, dib->fe)) { 186 if (dvb_register_frontend(&dib->adapter, dib->fe)) {
187 err("Frontend registration failed."); 187 err("Frontend registration failed.");
188 if (dib->fe->ops->release) 188 if (dib->fe->ops->release)
189 dib->fe->ops->release(dib->fe); 189 dib->fe->ops->release(dib->fe);
@@ -206,7 +206,7 @@ int dibusb_i2c_init(struct usb_dibusb *dib)
206{ 206{
207 int ret = 0; 207 int ret = 0;
208 208
209 dib->adapter->priv = dib; 209 dib->adapter.priv = dib;
210 210
211 strncpy(dib->i2c_adap.name,dib->dibdev->name,I2C_NAME_SIZE); 211 strncpy(dib->i2c_adap.name,dib->dibdev->name,I2C_NAME_SIZE);
212#ifdef I2C_ADAP_CLASS_TV_DIGITAL 212#ifdef I2C_ADAP_CLASS_TV_DIGITAL
diff --git a/drivers/media/dvb/dibusb/dvb-dibusb.h b/drivers/media/dvb/dibusb/dvb-dibusb.h
index 52cd35dd9d83..c965b64fb1ab 100644
--- a/drivers/media/dvb/dibusb/dvb-dibusb.h
+++ b/drivers/media/dvb/dibusb/dvb-dibusb.h
@@ -181,7 +181,7 @@ struct usb_dibusb {
181 struct semaphore i2c_sem; 181 struct semaphore i2c_sem;
182 182
183 /* dvb */ 183 /* dvb */
184 struct dvb_adapter *adapter; 184 struct dvb_adapter adapter;
185 struct dmxdev dmxdev; 185 struct dmxdev dmxdev;
186 struct dvb_demux demux; 186 struct dvb_demux demux;
187 struct dvb_net dvb_net; 187 struct dvb_net dvb_net;
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 1863f1dfb00c..c225de7ffd82 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -175,8 +175,8 @@ static inline void dvb_dmxdev_dvr_state_set(struct dmxdev_dvr *dmxdevdvr, int st
175 175
176static int dvb_dvr_open(struct inode *inode, struct file *file) 176static int dvb_dvr_open(struct inode *inode, struct file *file)
177{ 177{
178 struct dvb_device *dvbdev=(struct dvb_device *) file->private_data; 178 struct dvb_device *dvbdev = file->private_data;
179 struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv; 179 struct dmxdev *dmxdev = dvbdev->priv;
180 struct dmx_frontend *front; 180 struct dmx_frontend *front;
181 181
182 dprintk ("function : %s\n", __FUNCTION__); 182 dprintk ("function : %s\n", __FUNCTION__);
@@ -224,8 +224,8 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
224 224
225static int dvb_dvr_release(struct inode *inode, struct file *file) 225static int dvb_dvr_release(struct inode *inode, struct file *file)
226{ 226{
227 struct dvb_device *dvbdev=(struct dvb_device *) file->private_data; 227 struct dvb_device *dvbdev = file->private_data;
228 struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv; 228 struct dmxdev *dmxdev = dvbdev->priv;
229 229
230 if (down_interruptible (&dmxdev->mutex)) 230 if (down_interruptible (&dmxdev->mutex))
231 return -ERESTARTSYS; 231 return -ERESTARTSYS;
@@ -252,8 +252,8 @@ static int dvb_dvr_release(struct inode *inode, struct file *file)
252static ssize_t dvb_dvr_write(struct file *file, const char __user *buf, 252static ssize_t dvb_dvr_write(struct file *file, const char __user *buf,
253 size_t count, loff_t *ppos) 253 size_t count, loff_t *ppos)
254{ 254{
255 struct dvb_device *dvbdev=(struct dvb_device *) file->private_data; 255 struct dvb_device *dvbdev = file->private_data;
256 struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv; 256 struct dmxdev *dmxdev = dvbdev->priv;
257 int ret; 257 int ret;
258 258
259 if (!dmxdev->demux->write) 259 if (!dmxdev->demux->write)
@@ -270,8 +270,8 @@ static ssize_t dvb_dvr_write(struct file *file, const char __user *buf,
270static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count, 270static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count,
271 loff_t *ppos) 271 loff_t *ppos)
272{ 272{
273 struct dvb_device *dvbdev=(struct dvb_device *) file->private_data; 273 struct dvb_device *dvbdev = file->private_data;
274 struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv; 274 struct dmxdev *dmxdev = dvbdev->priv;
275 int ret; 275 int ret;
276 276
277 //down(&dmxdev->mutex); 277 //down(&dmxdev->mutex);
@@ -345,7 +345,7 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
345 const u8 *buffer2, size_t buffer2_len, 345 const u8 *buffer2, size_t buffer2_len,
346 struct dmx_section_filter *filter, enum dmx_success success) 346 struct dmx_section_filter *filter, enum dmx_success success)
347{ 347{
348 struct dmxdev_filter *dmxdevfilter=(struct dmxdev_filter *) filter->priv; 348 struct dmxdev_filter *dmxdevfilter = filter->priv;
349 int ret; 349 int ret;
350 350
351 if (dmxdevfilter->buffer.error) { 351 if (dmxdevfilter->buffer.error) {
@@ -381,7 +381,7 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
381 const u8 *buffer2, size_t buffer2_len, 381 const u8 *buffer2, size_t buffer2_len,
382 struct dmx_ts_feed *feed, enum dmx_success success) 382 struct dmx_ts_feed *feed, enum dmx_success success)
383{ 383{
384 struct dmxdev_filter *dmxdevfilter=(struct dmxdev_filter *) feed->priv; 384 struct dmxdev_filter *dmxdevfilter = feed->priv;
385 struct dmxdev_buffer *buffer; 385 struct dmxdev_buffer *buffer;
386 int ret; 386 int ret;
387 387
@@ -684,8 +684,8 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
684 684
685static int dvb_demux_open(struct inode *inode, struct file *file) 685static int dvb_demux_open(struct inode *inode, struct file *file)
686{ 686{
687 struct dvb_device *dvbdev=(struct dvb_device *) file->private_data; 687 struct dvb_device *dvbdev = file->private_data;
688 struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv; 688 struct dmxdev *dmxdev = dvbdev->priv;
689 int i; 689 int i;
690 struct dmxdev_filter *dmxdevfilter; 690 struct dmxdev_filter *dmxdevfilter;
691 691
@@ -1013,8 +1013,8 @@ static struct dvb_device dvbdev_demux = {
1013static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file, 1013static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
1014 unsigned int cmd, void *parg) 1014 unsigned int cmd, void *parg)
1015{ 1015{
1016 struct dvb_device *dvbdev=(struct dvb_device *) file->private_data; 1016 struct dvb_device *dvbdev = file->private_data;
1017 struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv; 1017 struct dmxdev *dmxdev = dvbdev->priv;
1018 1018
1019 int ret=0; 1019 int ret=0;
1020 1020
@@ -1044,8 +1044,8 @@ static int dvb_dvr_ioctl(struct inode *inode, struct file *file,
1044 1044
1045static unsigned int dvb_dvr_poll (struct file *file, poll_table *wait) 1045static unsigned int dvb_dvr_poll (struct file *file, poll_table *wait)
1046{ 1046{
1047 struct dvb_device *dvbdev = (struct dvb_device *) file->private_data; 1047 struct dvb_device *dvbdev = file->private_data;
1048 struct dmxdev *dmxdev = (struct dmxdev *) dvbdev->priv; 1048 struct dmxdev *dmxdev = dvbdev->priv;
1049 unsigned int mask = 0; 1049 unsigned int mask = 0;
1050 1050
1051 dprintk ("function : %s\n", __FUNCTION__); 1051 dprintk ("function : %s\n", __FUNCTION__);
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index c1ea89f2880c..0eb9aa711fb0 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -829,7 +829,7 @@ EXPORT_SYMBOL(dvb_ca_en50221_camready_irq);
829 */ 829 */
830void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot, int change_type) 830void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot, int change_type)
831{ 831{
832 struct dvb_ca_private *ca = (struct dvb_ca_private *) pubca->private; 832 struct dvb_ca_private *ca = pubca->private;
833 833
834 dprintk("CAMCHANGE IRQ slot:%i change_type:%i\n", slot, change_type); 834 dprintk("CAMCHANGE IRQ slot:%i change_type:%i\n", slot, change_type);
835 835
@@ -857,7 +857,7 @@ EXPORT_SYMBOL(dvb_ca_en50221_frda_irq);
857 */ 857 */
858void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot) 858void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot)
859{ 859{
860 struct dvb_ca_private *ca = (struct dvb_ca_private *) pubca->private; 860 struct dvb_ca_private *ca = pubca->private;
861 861
862 dprintk("CAMREADY IRQ slot:%i\n", slot); 862 dprintk("CAMREADY IRQ slot:%i\n", slot);
863 863
@@ -876,7 +876,7 @@ void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot)
876 */ 876 */
877void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot) 877void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
878{ 878{
879 struct dvb_ca_private *ca = (struct dvb_ca_private *) pubca->private; 879 struct dvb_ca_private *ca = pubca->private;
880 int flags; 880 int flags;
881 881
882 dprintk("FR/DA IRQ slot:%i\n", slot); 882 dprintk("FR/DA IRQ slot:%i\n", slot);
@@ -993,7 +993,7 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
993 */ 993 */
994static int dvb_ca_en50221_thread(void *data) 994static int dvb_ca_en50221_thread(void *data)
995{ 995{
996 struct dvb_ca_private *ca = (struct dvb_ca_private *) data; 996 struct dvb_ca_private *ca = data;
997 char name[15]; 997 char name[15];
998 int slot; 998 int slot;
999 int flags; 999 int flags;
@@ -1202,8 +1202,8 @@ static int dvb_ca_en50221_thread(void *data)
1202static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file, 1202static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
1203 unsigned int cmd, void *parg) 1203 unsigned int cmd, void *parg)
1204{ 1204{
1205 struct dvb_device *dvbdev = (struct dvb_device *) file->private_data; 1205 struct dvb_device *dvbdev = file->private_data;
1206 struct dvb_ca_private *ca = (struct dvb_ca_private *) dvbdev->priv; 1206 struct dvb_ca_private *ca = dvbdev->priv;
1207 int err = 0; 1207 int err = 0;
1208 int slot; 1208 int slot;
1209 1209
@@ -1225,7 +1225,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
1225 break; 1225 break;
1226 1226
1227 case CA_GET_CAP: { 1227 case CA_GET_CAP: {
1228 struct ca_caps *caps = (struct ca_caps *) parg; 1228 struct ca_caps *caps = parg;
1229 1229
1230 caps->slot_num = ca->slot_count; 1230 caps->slot_num = ca->slot_count;
1231 caps->slot_type = CA_CI_LINK; 1231 caps->slot_type = CA_CI_LINK;
@@ -1235,7 +1235,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
1235 } 1235 }
1236 1236
1237 case CA_GET_SLOT_INFO: { 1237 case CA_GET_SLOT_INFO: {
1238 struct ca_slot_info *info = (struct ca_slot_info *) parg; 1238 struct ca_slot_info *info = parg;
1239 1239
1240 if ((info->num > ca->slot_count) || (info->num < 0)) 1240 if ((info->num > ca->slot_count) || (info->num < 0))
1241 return -EINVAL; 1241 return -EINVAL;
@@ -1291,8 +1291,8 @@ static int dvb_ca_en50221_io_ioctl(struct inode *inode, struct file *file,
1291static ssize_t dvb_ca_en50221_io_write(struct file *file, 1291static ssize_t dvb_ca_en50221_io_write(struct file *file,
1292 const char __user * buf, size_t count, loff_t * ppos) 1292 const char __user * buf, size_t count, loff_t * ppos)
1293{ 1293{
1294 struct dvb_device *dvbdev = (struct dvb_device *) file->private_data; 1294 struct dvb_device *dvbdev = file->private_data;
1295 struct dvb_ca_private *ca = (struct dvb_ca_private *) dvbdev->priv; 1295 struct dvb_ca_private *ca = dvbdev->priv;
1296 u8 slot, connection_id; 1296 u8 slot, connection_id;
1297 int status; 1297 int status;
1298 char fragbuf[HOST_LINK_BUF_SIZE]; 1298 char fragbuf[HOST_LINK_BUF_SIZE];
@@ -1428,8 +1428,8 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca, int *resu
1428static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf, 1428static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
1429 size_t count, loff_t * ppos) 1429 size_t count, loff_t * ppos)
1430{ 1430{
1431 struct dvb_device *dvbdev = (struct dvb_device *) file->private_data; 1431 struct dvb_device *dvbdev = file->private_data;
1432 struct dvb_ca_private *ca = (struct dvb_ca_private *) dvbdev->priv; 1432 struct dvb_ca_private *ca = dvbdev->priv;
1433 int status; 1433 int status;
1434 int result = 0; 1434 int result = 0;
1435 u8 hdr[2]; 1435 u8 hdr[2];
@@ -1526,8 +1526,8 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
1526 */ 1526 */
1527static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file) 1527static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
1528{ 1528{
1529 struct dvb_device *dvbdev = (struct dvb_device *) file->private_data; 1529 struct dvb_device *dvbdev = file->private_data;
1530 struct dvb_ca_private *ca = (struct dvb_ca_private *) dvbdev->priv; 1530 struct dvb_ca_private *ca = dvbdev->priv;
1531 int err; 1531 int err;
1532 int i; 1532 int i;
1533 1533
@@ -1569,8 +1569,8 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
1569 */ 1569 */
1570static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file) 1570static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file)
1571{ 1571{
1572 struct dvb_device *dvbdev = (struct dvb_device *) file->private_data; 1572 struct dvb_device *dvbdev = file->private_data;
1573 struct dvb_ca_private *ca = (struct dvb_ca_private *) dvbdev->priv; 1573 struct dvb_ca_private *ca = dvbdev->priv;
1574 int err = 0; 1574 int err = 0;
1575 1575
1576 dprintk("%s\n", __FUNCTION__); 1576 dprintk("%s\n", __FUNCTION__);
@@ -1597,8 +1597,8 @@ static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file)
1597 */ 1597 */
1598static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait) 1598static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait)
1599{ 1599{
1600 struct dvb_device *dvbdev = (struct dvb_device *) file->private_data; 1600 struct dvb_device *dvbdev = file->private_data;
1601 struct dvb_ca_private *ca = (struct dvb_ca_private *) dvbdev->priv; 1601 struct dvb_ca_private *ca = dvbdev->priv;
1602 unsigned int mask = 0; 1602 unsigned int mask = 0;
1603 int slot; 1603 int slot;
1604 int result = 0; 1604 int result = 0;
@@ -1750,7 +1750,7 @@ EXPORT_SYMBOL(dvb_ca_en50221_release);
1750 */ 1750 */
1751void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca) 1751void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca)
1752{ 1752{
1753 struct dvb_ca_private *ca = (struct dvb_ca_private *) pubca->private; 1753 struct dvb_ca_private *ca = pubca->private;
1754 int i; 1754 int i;
1755 1755
1756 dprintk("%s\n", __FUNCTION__); 1756 dprintk("%s\n", __FUNCTION__);
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 59a9adfae1eb..d19301d90a09 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -48,7 +48,7 @@ static int dvb_override_tune_delay;
48static int dvb_powerdown_on_sleep = 1; 48static int dvb_powerdown_on_sleep = 1;
49 49
50module_param_named(frontend_debug, dvb_frontend_debug, int, 0644); 50module_param_named(frontend_debug, dvb_frontend_debug, int, 0644);
51MODULE_PARM_DESC(dvb_frontend_debug, "Turn on/off frontend core debugging (default:off)."); 51MODULE_PARM_DESC(frontend_debug, "Turn on/off frontend core debugging (default:off).");
52module_param(dvb_shutdown_timeout, int, 0444); 52module_param(dvb_shutdown_timeout, int, 0444);
53MODULE_PARM_DESC(dvb_shutdown_timeout, "wait <shutdown_timeout> seconds after close() before suspending hardware"); 53MODULE_PARM_DESC(dvb_shutdown_timeout, "wait <shutdown_timeout> seconds after close() before suspending hardware");
54module_param(dvb_force_auto_inversion, int, 0444); 54module_param(dvb_force_auto_inversion, int, 0444);
@@ -117,7 +117,7 @@ struct dvb_frontend_private {
117 117
118static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) 118static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
119{ 119{
120 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 120 struct dvb_frontend_private *fepriv = fe->frontend_priv;
121 struct dvb_fe_events *events = &fepriv->events; 121 struct dvb_fe_events *events = &fepriv->events;
122 struct dvb_frontend_event *e; 122 struct dvb_frontend_event *e;
123 int wp; 123 int wp;
@@ -155,7 +155,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
155static int dvb_frontend_get_event(struct dvb_frontend *fe, 155static int dvb_frontend_get_event(struct dvb_frontend *fe,
156 struct dvb_frontend_event *event, int flags) 156 struct dvb_frontend_event *event, int flags)
157{ 157{
158 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 158 struct dvb_frontend_private *fepriv = fe->frontend_priv;
159 struct dvb_fe_events *events = &fepriv->events; 159 struct dvb_fe_events *events = &fepriv->events;
160 160
161 dprintk ("%s\n", __FUNCTION__); 161 dprintk ("%s\n", __FUNCTION__);
@@ -234,7 +234,7 @@ static int dvb_frontend_autotune(struct dvb_frontend *fe, int check_wrapped)
234{ 234{
235 int autoinversion; 235 int autoinversion;
236 int ready = 0; 236 int ready = 0;
237 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 237 struct dvb_frontend_private *fepriv = fe->frontend_priv;
238 int original_inversion = fepriv->parameters.inversion; 238 int original_inversion = fepriv->parameters.inversion;
239 u32 original_frequency = fepriv->parameters.frequency; 239 u32 original_frequency = fepriv->parameters.frequency;
240 240
@@ -321,7 +321,7 @@ static int dvb_frontend_autotune(struct dvb_frontend *fe, int check_wrapped)
321 321
322static int dvb_frontend_is_exiting(struct dvb_frontend *fe) 322static int dvb_frontend_is_exiting(struct dvb_frontend *fe)
323{ 323{
324 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 324 struct dvb_frontend_private *fepriv = fe->frontend_priv;
325 325
326 if (fepriv->exit) 326 if (fepriv->exit)
327 return 1; 327 return 1;
@@ -335,7 +335,7 @@ static int dvb_frontend_is_exiting(struct dvb_frontend *fe)
335 335
336static int dvb_frontend_should_wakeup(struct dvb_frontend *fe) 336static int dvb_frontend_should_wakeup(struct dvb_frontend *fe)
337{ 337{
338 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 338 struct dvb_frontend_private *fepriv = fe->frontend_priv;
339 339
340 if (fepriv->wakeup) { 340 if (fepriv->wakeup) {
341 fepriv->wakeup = 0; 341 fepriv->wakeup = 0;
@@ -346,7 +346,7 @@ static int dvb_frontend_should_wakeup(struct dvb_frontend *fe)
346 346
347static void dvb_frontend_wakeup(struct dvb_frontend *fe) 347static void dvb_frontend_wakeup(struct dvb_frontend *fe)
348{ 348{
349 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 349 struct dvb_frontend_private *fepriv = fe->frontend_priv;
350 350
351 fepriv->wakeup = 1; 351 fepriv->wakeup = 1;
352 wake_up_interruptible(&fepriv->wait_queue); 352 wake_up_interruptible(&fepriv->wait_queue);
@@ -357,8 +357,8 @@ static void dvb_frontend_wakeup(struct dvb_frontend *fe)
357 */ 357 */
358static int dvb_frontend_thread(void *data) 358static int dvb_frontend_thread(void *data)
359{ 359{
360 struct dvb_frontend *fe = (struct dvb_frontend *) data; 360 struct dvb_frontend *fe = data;
361 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 361 struct dvb_frontend_private *fepriv = fe->frontend_priv;
362 unsigned long timeout; 362 unsigned long timeout;
363 char name [15]; 363 char name [15];
364 int quality = 0, delay = 3*HZ; 364 int quality = 0, delay = 3*HZ;
@@ -520,7 +520,7 @@ static int dvb_frontend_thread(void *data)
520static void dvb_frontend_stop(struct dvb_frontend *fe) 520static void dvb_frontend_stop(struct dvb_frontend *fe)
521{ 521{
522 unsigned long ret; 522 unsigned long ret;
523 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 523 struct dvb_frontend_private *fepriv = fe->frontend_priv;
524 524
525 dprintk ("%s\n", __FUNCTION__); 525 dprintk ("%s\n", __FUNCTION__);
526 526
@@ -559,7 +559,7 @@ static void dvb_frontend_stop(struct dvb_frontend *fe)
559static int dvb_frontend_start(struct dvb_frontend *fe) 559static int dvb_frontend_start(struct dvb_frontend *fe)
560{ 560{
561 int ret; 561 int ret;
562 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 562 struct dvb_frontend_private *fepriv = fe->frontend_priv;
563 563
564 dprintk ("%s\n", __FUNCTION__); 564 dprintk ("%s\n", __FUNCTION__);
565 565
@@ -597,7 +597,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
597{ 597{
598 struct dvb_device *dvbdev = file->private_data; 598 struct dvb_device *dvbdev = file->private_data;
599 struct dvb_frontend *fe = dvbdev->priv; 599 struct dvb_frontend *fe = dvbdev->priv;
600 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 600 struct dvb_frontend_private *fepriv = fe->frontend_priv;
601 int err = -EOPNOTSUPP; 601 int err = -EOPNOTSUPP;
602 602
603 dprintk ("%s\n", __FUNCTION__); 603 dprintk ("%s\n", __FUNCTION__);
@@ -615,7 +615,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
615 615
616 switch (cmd) { 616 switch (cmd) {
617 case FE_GET_INFO: { 617 case FE_GET_INFO: {
618 struct dvb_frontend_info* info = (struct dvb_frontend_info*) parg; 618 struct dvb_frontend_info* info = parg;
619 memcpy(info, &fe->ops->info, sizeof(struct dvb_frontend_info)); 619 memcpy(info, &fe->ops->info, sizeof(struct dvb_frontend_info));
620 620
621 /* Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't 621 /* Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't
@@ -793,7 +793,7 @@ static unsigned int dvb_frontend_poll(struct file *file, struct poll_table_struc
793{ 793{
794 struct dvb_device *dvbdev = file->private_data; 794 struct dvb_device *dvbdev = file->private_data;
795 struct dvb_frontend *fe = dvbdev->priv; 795 struct dvb_frontend *fe = dvbdev->priv;
796 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 796 struct dvb_frontend_private *fepriv = fe->frontend_priv;
797 797
798 dprintk ("%s\n", __FUNCTION__); 798 dprintk ("%s\n", __FUNCTION__);
799 799
@@ -809,7 +809,7 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
809{ 809{
810 struct dvb_device *dvbdev = file->private_data; 810 struct dvb_device *dvbdev = file->private_data;
811 struct dvb_frontend *fe = dvbdev->priv; 811 struct dvb_frontend *fe = dvbdev->priv;
812 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 812 struct dvb_frontend_private *fepriv = fe->frontend_priv;
813 int ret; 813 int ret;
814 814
815 dprintk ("%s\n", __FUNCTION__); 815 dprintk ("%s\n", __FUNCTION__);
@@ -833,7 +833,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
833{ 833{
834 struct dvb_device *dvbdev = file->private_data; 834 struct dvb_device *dvbdev = file->private_data;
835 struct dvb_frontend *fe = dvbdev->priv; 835 struct dvb_frontend *fe = dvbdev->priv;
836 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 836 struct dvb_frontend_private *fepriv = fe->frontend_priv;
837 837
838 dprintk ("%s\n", __FUNCTION__); 838 dprintk ("%s\n", __FUNCTION__);
839 839
@@ -873,7 +873,7 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
873 up(&frontend_mutex); 873 up(&frontend_mutex);
874 return -ENOMEM; 874 return -ENOMEM;
875 } 875 }
876 fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 876 fepriv = fe->frontend_priv;
877 memset(fe->frontend_priv, 0, sizeof(struct dvb_frontend_private)); 877 memset(fe->frontend_priv, 0, sizeof(struct dvb_frontend_private));
878 878
879 init_MUTEX (&fepriv->sem); 879 init_MUTEX (&fepriv->sem);
@@ -897,7 +897,7 @@ EXPORT_SYMBOL(dvb_register_frontend);
897 897
898int dvb_unregister_frontend(struct dvb_frontend* fe) 898int dvb_unregister_frontend(struct dvb_frontend* fe)
899{ 899{
900 struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv; 900 struct dvb_frontend_private *fepriv = fe->frontend_priv;
901 dprintk ("%s\n", __FUNCTION__); 901 dprintk ("%s\n", __FUNCTION__);
902 902
903 down (&frontend_mutex); 903 down (&frontend_mutex);
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 44892e7abd3d..6a968c346a36 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -315,7 +315,7 @@ static inline void reset_ule( struct dvb_net_priv *p )
315 */ 315 */
316static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) 316static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
317{ 317{
318 struct dvb_net_priv *priv = (struct dvb_net_priv *)dev->priv; 318 struct dvb_net_priv *priv = dev->priv;
319 unsigned long skipped = 0L; 319 unsigned long skipped = 0L;
320 u8 *ts, *ts_end, *from_where = NULL, ts_remain = 0, how_much = 0, new_ts = 1; 320 u8 *ts, *ts_end, *from_where = NULL, ts_remain = 0, how_much = 0, new_ts = 1;
321 struct ethhdr *ethh = NULL; 321 struct ethhdr *ethh = NULL;
@@ -709,7 +709,7 @@ static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
709 const u8 *buffer2, size_t buffer2_len, 709 const u8 *buffer2, size_t buffer2_len,
710 struct dmx_ts_feed *feed, enum dmx_success success) 710 struct dmx_ts_feed *feed, enum dmx_success success)
711{ 711{
712 struct net_device *dev = (struct net_device *)feed->priv; 712 struct net_device *dev = feed->priv;
713 713
714 if (buffer2 != 0) 714 if (buffer2 != 0)
715 printk(KERN_WARNING "buffer2 not 0: %p.\n", buffer2); 715 printk(KERN_WARNING "buffer2 not 0: %p.\n", buffer2);
@@ -727,6 +727,7 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
727 u8 *eth; 727 u8 *eth;
728 struct sk_buff *skb; 728 struct sk_buff *skb;
729 struct net_device_stats *stats = &(((struct dvb_net_priv *) dev->priv)->stats); 729 struct net_device_stats *stats = &(((struct dvb_net_priv *) dev->priv)->stats);
730 int snap = 0;
730 731
731 /* note: pkt_len includes a 32bit checksum */ 732 /* note: pkt_len includes a 32bit checksum */
732 if (pkt_len < 16) { 733 if (pkt_len < 16) {
@@ -750,9 +751,12 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
750 return; 751 return;
751 } 752 }
752 if (pkt[5] & 0x02) { 753 if (pkt[5] & 0x02) {
753 //FIXME: handle LLC/SNAP 754 /* handle LLC/SNAP, see rfc-1042 */
754 stats->rx_dropped++; 755 if (pkt_len < 24 || memcmp(&pkt[12], "\xaa\xaa\x03\0\0\0", 6)) {
755 return; 756 stats->rx_dropped++;
757 return;
758 }
759 snap = 8;
756 } 760 }
757 if (pkt[7]) { 761 if (pkt[7]) {
758 /* FIXME: assemble datagram from multiple sections */ 762 /* FIXME: assemble datagram from multiple sections */
@@ -762,9 +766,9 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
762 } 766 }
763 767
764 /* we have 14 byte ethernet header (ip header follows); 768 /* we have 14 byte ethernet header (ip header follows);
765 * 12 byte MPE header; 4 byte checksum; + 2 byte alignment 769 * 12 byte MPE header; 4 byte checksum; + 2 byte alignment, 8 byte LLC/SNAP
766 */ 770 */
767 if (!(skb = dev_alloc_skb(pkt_len - 4 - 12 + 14 + 2))) { 771 if (!(skb = dev_alloc_skb(pkt_len - 4 - 12 + 14 + 2 - snap))) {
768 //printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name); 772 //printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
769 stats->rx_dropped++; 773 stats->rx_dropped++;
770 return; 774 return;
@@ -773,8 +777,8 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
773 skb->dev = dev; 777 skb->dev = dev;
774 778
775 /* copy L3 payload */ 779 /* copy L3 payload */
776 eth = (u8 *) skb_put(skb, pkt_len - 12 - 4 + 14); 780 eth = (u8 *) skb_put(skb, pkt_len - 12 - 4 + 14 - snap);
777 memcpy(eth + 14, pkt + 12, pkt_len - 12 - 4); 781 memcpy(eth + 14, pkt + 12 + snap, pkt_len - 12 - 4 - snap);
778 782
779 /* create ethernet header: */ 783 /* create ethernet header: */
780 eth[0]=pkt[0x0b]; 784 eth[0]=pkt[0x0b];
@@ -786,8 +790,21 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
786 790
787 eth[6]=eth[7]=eth[8]=eth[9]=eth[10]=eth[11]=0; 791 eth[6]=eth[7]=eth[8]=eth[9]=eth[10]=eth[11]=0;
788 792
789 eth[12] = 0x08; /* ETH_P_IP */ 793 if (snap) {
790 eth[13] = 0x00; 794 eth[12] = pkt[18];
795 eth[13] = pkt[19];
796 } else {
797 /* protocol numbers are from rfc-1700 or
798 * http://www.iana.org/assignments/ethernet-numbers
799 */
800 if (pkt[12] >> 4 == 6) { /* version field from IP header */
801 eth[12] = 0x86; /* IPv6 */
802 eth[13] = 0xdd;
803 } else {
804 eth[12] = 0x08; /* IPv4 */
805 eth[13] = 0x00;
806 }
807 }
791 808
792 skb->protocol = dvb_net_eth_type_trans(skb, dev); 809 skb->protocol = dvb_net_eth_type_trans(skb, dev);
793 810
@@ -801,7 +818,7 @@ static int dvb_net_sec_callback(const u8 *buffer1, size_t buffer1_len,
801 struct dmx_section_filter *filter, 818 struct dmx_section_filter *filter,
802 enum dmx_success success) 819 enum dmx_success success)
803{ 820{
804 struct net_device *dev=(struct net_device *) filter->priv; 821 struct net_device *dev = filter->priv;
805 822
806 /** 823 /**
807 * we rely on the DVB API definition where exactly one complete 824 * we rely on the DVB API definition where exactly one complete
@@ -826,7 +843,7 @@ static int dvb_net_filter_sec_set(struct net_device *dev,
826 struct dmx_section_filter **secfilter, 843 struct dmx_section_filter **secfilter,
827 u8 *mac, u8 *mac_mask) 844 u8 *mac, u8 *mac_mask)
828{ 845{
829 struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; 846 struct dvb_net_priv *priv = dev->priv;
830 int ret; 847 int ret;
831 848
832 *secfilter=NULL; 849 *secfilter=NULL;
@@ -870,7 +887,7 @@ static int dvb_net_filter_sec_set(struct net_device *dev,
870static int dvb_net_feed_start(struct net_device *dev) 887static int dvb_net_feed_start(struct net_device *dev)
871{ 888{
872 int ret, i; 889 int ret, i;
873 struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; 890 struct dvb_net_priv *priv = dev->priv;
874 struct dmx_demux *demux = priv->demux; 891 struct dmx_demux *demux = priv->demux;
875 unsigned char *mac = (unsigned char *) dev->dev_addr; 892 unsigned char *mac = (unsigned char *) dev->dev_addr;
876 893
@@ -965,7 +982,7 @@ static int dvb_net_feed_start(struct net_device *dev)
965 982
966static int dvb_net_feed_stop(struct net_device *dev) 983static int dvb_net_feed_stop(struct net_device *dev)
967{ 984{
968 struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; 985 struct dvb_net_priv *priv = dev->priv;
969 int i; 986 int i;
970 987
971 dprintk("%s\n", __FUNCTION__); 988 dprintk("%s\n", __FUNCTION__);
@@ -1016,7 +1033,7 @@ static int dvb_net_feed_stop(struct net_device *dev)
1016 1033
1017static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc) 1034static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc)
1018{ 1035{
1019 struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; 1036 struct dvb_net_priv *priv = dev->priv;
1020 1037
1021 if (priv->multi_num == DVB_NET_MULTICAST_MAX) 1038 if (priv->multi_num == DVB_NET_MULTICAST_MAX)
1022 return -ENOMEM; 1039 return -ENOMEM;
@@ -1031,7 +1048,7 @@ static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc)
1031static void wq_set_multicast_list (void *data) 1048static void wq_set_multicast_list (void *data)
1032{ 1049{
1033 struct net_device *dev = data; 1050 struct net_device *dev = data;
1034 struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; 1051 struct dvb_net_priv *priv = dev->priv;
1035 1052
1036 dvb_net_feed_stop(dev); 1053 dvb_net_feed_stop(dev);
1037 1054
@@ -1066,7 +1083,7 @@ static void wq_set_multicast_list (void *data)
1066 1083
1067static void dvb_net_set_multicast_list (struct net_device *dev) 1084static void dvb_net_set_multicast_list (struct net_device *dev)
1068{ 1085{
1069 struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; 1086 struct dvb_net_priv *priv = dev->priv;
1070 schedule_work(&priv->set_multicast_list_wq); 1087 schedule_work(&priv->set_multicast_list_wq);
1071} 1088}
1072 1089
@@ -1084,7 +1101,7 @@ static void wq_restart_net_feed (void *data)
1084 1101
1085static int dvb_net_set_mac (struct net_device *dev, void *p) 1102static int dvb_net_set_mac (struct net_device *dev, void *p)
1086{ 1103{
1087 struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; 1104 struct dvb_net_priv *priv = dev->priv;
1088 struct sockaddr *addr=p; 1105 struct sockaddr *addr=p;
1089 1106
1090 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 1107 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
@@ -1098,7 +1115,7 @@ static int dvb_net_set_mac (struct net_device *dev, void *p)
1098 1115
1099static int dvb_net_open(struct net_device *dev) 1116static int dvb_net_open(struct net_device *dev)
1100{ 1117{
1101 struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; 1118 struct dvb_net_priv *priv = dev->priv;
1102 1119
1103 priv->in_use++; 1120 priv->in_use++;
1104 dvb_net_feed_start(dev); 1121 dvb_net_feed_start(dev);
@@ -1108,7 +1125,7 @@ static int dvb_net_open(struct net_device *dev)
1108 1125
1109static int dvb_net_stop(struct net_device *dev) 1126static int dvb_net_stop(struct net_device *dev)
1110{ 1127{
1111 struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; 1128 struct dvb_net_priv *priv = dev->priv;
1112 1129
1113 priv->in_use--; 1130 priv->in_use--;
1114 return dvb_net_feed_stop(dev); 1131 return dvb_net_feed_stop(dev);
@@ -1228,8 +1245,8 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned int num)
1228static int dvb_net_do_ioctl(struct inode *inode, struct file *file, 1245static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
1229 unsigned int cmd, void *parg) 1246 unsigned int cmd, void *parg)
1230{ 1247{
1231 struct dvb_device *dvbdev = (struct dvb_device *) file->private_data; 1248 struct dvb_device *dvbdev = file->private_data;
1232 struct dvb_net *dvbnet = (struct dvb_net *) dvbdev->priv; 1249 struct dvb_net *dvbnet = dvbdev->priv;
1233 1250
1234 if (((file->f_flags&O_ACCMODE)==O_RDONLY)) 1251 if (((file->f_flags&O_ACCMODE)==O_RDONLY))
1235 return -EPERM; 1252 return -EPERM;
@@ -1237,7 +1254,7 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
1237 switch (cmd) { 1254 switch (cmd) {
1238 case NET_ADD_IF: 1255 case NET_ADD_IF:
1239 { 1256 {
1240 struct dvb_net_if *dvbnetif=(struct dvb_net_if *)parg; 1257 struct dvb_net_if *dvbnetif = parg;
1241 int result; 1258 int result;
1242 1259
1243 if (!capable(CAP_SYS_ADMIN)) 1260 if (!capable(CAP_SYS_ADMIN))
@@ -1258,7 +1275,7 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
1258 { 1275 {
1259 struct net_device *netdev; 1276 struct net_device *netdev;
1260 struct dvb_net_priv *priv_data; 1277 struct dvb_net_priv *priv_data;
1261 struct dvb_net_if *dvbnetif=(struct dvb_net_if *)parg; 1278 struct dvb_net_if *dvbnetif = parg;
1262 1279
1263 if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX || 1280 if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX ||
1264 !dvbnet->state[dvbnetif->if_num]) 1281 !dvbnet->state[dvbnetif->if_num])
@@ -1266,7 +1283,7 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
1266 1283
1267 netdev = dvbnet->device[dvbnetif->if_num]; 1284 netdev = dvbnet->device[dvbnetif->if_num];
1268 1285
1269 priv_data=(struct dvb_net_priv*)netdev->priv; 1286 priv_data = netdev->priv;
1270 dvbnetif->pid=priv_data->pid; 1287 dvbnetif->pid=priv_data->pid;
1271 dvbnetif->feedtype=priv_data->feedtype; 1288 dvbnetif->feedtype=priv_data->feedtype;
1272 break; 1289 break;
@@ -1288,7 +1305,7 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
1288 /* binary compatiblity cruft */ 1305 /* binary compatiblity cruft */
1289 case __NET_ADD_IF_OLD: 1306 case __NET_ADD_IF_OLD:
1290 { 1307 {
1291 struct __dvb_net_if_old *dvbnetif=(struct __dvb_net_if_old *)parg; 1308 struct __dvb_net_if_old *dvbnetif = parg;
1292 int result; 1309 int result;
1293 1310
1294 if (!capable(CAP_SYS_ADMIN)) 1311 if (!capable(CAP_SYS_ADMIN))
@@ -1309,7 +1326,7 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
1309 { 1326 {
1310 struct net_device *netdev; 1327 struct net_device *netdev;
1311 struct dvb_net_priv *priv_data; 1328 struct dvb_net_priv *priv_data;
1312 struct __dvb_net_if_old *dvbnetif=(struct __dvb_net_if_old *)parg; 1329 struct __dvb_net_if_old *dvbnetif = parg;
1313 1330
1314 if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX || 1331 if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX ||
1315 !dvbnet->state[dvbnetif->if_num]) 1332 !dvbnet->state[dvbnetif->if_num])
@@ -1317,7 +1334,7 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
1317 1334
1318 netdev = dvbnet->device[dvbnetif->if_num]; 1335 netdev = dvbnet->device[dvbnetif->if_num];
1319 1336
1320 priv_data=(struct dvb_net_priv*)netdev->priv; 1337 priv_data = netdev->priv;
1321 dvbnetif->pid=priv_data->pid; 1338 dvbnetif->pid=priv_data->pid;
1322 break; 1339 break;
1323 } 1340 }
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index cf4ffe38fda3..9d9662f4b8e6 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -286,9 +286,8 @@ skip:
286} 286}
287 287
288 288
289int dvb_register_adapter(struct dvb_adapter **padap, const char *name, struct module *module) 289int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct module *module)
290{ 290{
291 struct dvb_adapter *adap;
292 int num; 291 int num;
293 292
294 if (down_interruptible (&dvbdev_register_lock)) 293 if (down_interruptible (&dvbdev_register_lock))
@@ -299,11 +298,6 @@ int dvb_register_adapter(struct dvb_adapter **padap, const char *name, struct mo
299 return -ENFILE; 298 return -ENFILE;
300 } 299 }
301 300
302 if (!(*padap = adap = kmalloc(sizeof(struct dvb_adapter), GFP_KERNEL))) {
303 up(&dvbdev_register_lock);
304 return -ENOMEM;
305 }
306
307 memset (adap, 0, sizeof(struct dvb_adapter)); 301 memset (adap, 0, sizeof(struct dvb_adapter));
308 INIT_LIST_HEAD (&adap->device_list); 302 INIT_LIST_HEAD (&adap->device_list);
309 303
@@ -331,7 +325,6 @@ int dvb_unregister_adapter(struct dvb_adapter *adap)
331 return -ERESTARTSYS; 325 return -ERESTARTSYS;
332 list_del (&adap->list_head); 326 list_del (&adap->list_head);
333 up (&dvbdev_register_lock); 327 up (&dvbdev_register_lock);
334 kfree (adap);
335 return 0; 328 return 0;
336} 329}
337EXPORT_SYMBOL(dvb_unregister_adapter); 330EXPORT_SYMBOL(dvb_unregister_adapter);
diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
index 184edba3caa7..a251867f30f1 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.h
+++ b/drivers/media/dvb/dvb-core/dvbdev.h
@@ -76,7 +76,7 @@ struct dvb_device {
76}; 76};
77 77
78 78
79extern int dvb_register_adapter (struct dvb_adapter **padap, const char *name, struct module *module); 79extern int dvb_register_adapter (struct dvb_adapter *adap, const char *name, struct module *module);
80extern int dvb_unregister_adapter (struct dvb_adapter *adap); 80extern int dvb_unregister_adapter (struct dvb_adapter *adap);
81 81
82extern int dvb_register_device (struct dvb_adapter *adap, 82extern int dvb_register_device (struct dvb_adapter *adap,
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index 0bfd4df17d08..75fb556ec01f 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -12,10 +12,10 @@ config DVB_STV0299
12 12
13config DVB_CX24110 13config DVB_CX24110
14 tristate "Conexant CX24110 based" 14 tristate "Conexant CX24110 based"
15 depends on DVB_CORE 15 depends on DVB_CORE
16 help 16 help
17 A DVB-S tuner module. Say Y when you want to support this frontend. 17 A DVB-S tuner module. Say Y when you want to support this frontend.
18 18
19config DVB_TDA8083 19config DVB_TDA8083
20 tristate "Philips TDA8083 based" 20 tristate "Philips TDA8083 based"
21 depends on DVB_CORE 21 depends on DVB_CORE
@@ -127,8 +127,8 @@ comment "DVB-C (cable) frontends"
127config DVB_ATMEL_AT76C651 127config DVB_ATMEL_AT76C651
128 tristate "Atmel AT76C651 based" 128 tristate "Atmel AT76C651 based"
129 depends on DVB_CORE 129 depends on DVB_CORE
130 help 130 help
131 A DVB-C tuner module. Say Y when you want to support this frontend. 131 A DVB-C tuner module. Say Y when you want to support this frontend.
132 132
133config DVB_VES1820 133config DVB_VES1820
134 tristate "VLSI VES1820 based" 134 tristate "VLSI VES1820 based"
@@ -158,10 +158,6 @@ config DVB_NXT2002
158 help 158 help
159 An ATSC 8VSB tuner module. Say Y when you want to support this frontend. 159 An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
160 160
161config DVB_OR51132
162 tristate "OR51132 based (pcHDTV)"
163 depends on DVB_CORE
164
165config DVB_OR51211 161config DVB_OR51211
166 tristate "or51211 based (pcHDTV HD2000 card)" 162 tristate "or51211 based (pcHDTV HD2000 card)"
167 depends on DVB_CORE 163 depends on DVB_CORE
@@ -169,4 +165,12 @@ config DVB_OR51211
169 help 165 help
170 An ATSC 8VSB tuner module. Say Y when you want to support this frontend. 166 An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
171 167
168config DVB_OR51132
169 tristate "OR51132 based (pcHDTV HD3000 card)"
170 depends on DVB_CORE
171 select FW_LOADER
172 help
173 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
174 to support this frontend.
175
172endmenu 176endmenu
diff --git a/drivers/media/dvb/frontends/at76c651.c b/drivers/media/dvb/frontends/at76c651.c
index ce2eaa1640e8..72a2b5455b0b 100644
--- a/drivers/media/dvb/frontends/at76c651.c
+++ b/drivers/media/dvb/frontends/at76c651.c
@@ -259,7 +259,7 @@ static int at76c651_set_parameters(struct dvb_frontend* fe,
259 struct dvb_frontend_parameters *p) 259 struct dvb_frontend_parameters *p)
260{ 260{
261 int ret; 261 int ret;
262 struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv; 262 struct at76c651_state* state = fe->demodulator_priv;
263 263
264 at76c651_writereg(state, 0x0c, 0xc3); 264 at76c651_writereg(state, 0x0c, 0xc3);
265 state->config->pll_set(fe, p); 265 state->config->pll_set(fe, p);
@@ -276,7 +276,7 @@ static int at76c651_set_parameters(struct dvb_frontend* fe,
276 276
277static int at76c651_set_defaults(struct dvb_frontend* fe) 277static int at76c651_set_defaults(struct dvb_frontend* fe)
278{ 278{
279 struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv; 279 struct at76c651_state* state = fe->demodulator_priv;
280 280
281 at76c651_set_symbol_rate(state, 6900000); 281 at76c651_set_symbol_rate(state, 6900000);
282 at76c651_set_qam(state, QAM_64); 282 at76c651_set_qam(state, QAM_64);
@@ -294,7 +294,7 @@ static int at76c651_set_defaults(struct dvb_frontend* fe)
294 294
295static int at76c651_read_status(struct dvb_frontend* fe, fe_status_t* status) 295static int at76c651_read_status(struct dvb_frontend* fe, fe_status_t* status)
296{ 296{
297 struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv; 297 struct at76c651_state* state = fe->demodulator_priv;
298 u8 sync; 298 u8 sync;
299 299
300 /* 300 /*
@@ -319,7 +319,7 @@ static int at76c651_read_status(struct dvb_frontend* fe, fe_status_t* status)
319 319
320static int at76c651_read_ber(struct dvb_frontend* fe, u32* ber) 320static int at76c651_read_ber(struct dvb_frontend* fe, u32* ber)
321{ 321{
322 struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv; 322 struct at76c651_state* state = fe->demodulator_priv;
323 323
324 *ber = (at76c651_readreg(state, 0x81) & 0x0F) << 16; 324 *ber = (at76c651_readreg(state, 0x81) & 0x0F) << 16;
325 *ber |= at76c651_readreg(state, 0x82) << 8; 325 *ber |= at76c651_readreg(state, 0x82) << 8;
@@ -331,7 +331,7 @@ static int at76c651_read_ber(struct dvb_frontend* fe, u32* ber)
331 331
332static int at76c651_read_signal_strength(struct dvb_frontend* fe, u16* strength) 332static int at76c651_read_signal_strength(struct dvb_frontend* fe, u16* strength)
333{ 333{
334 struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv; 334 struct at76c651_state* state = fe->demodulator_priv;
335 335
336 u8 gain = ~at76c651_readreg(state, 0x91); 336 u8 gain = ~at76c651_readreg(state, 0x91);
337 *strength = (gain << 8) | gain; 337 *strength = (gain << 8) | gain;
@@ -341,7 +341,7 @@ static int at76c651_read_signal_strength(struct dvb_frontend* fe, u16* strength)
341 341
342static int at76c651_read_snr(struct dvb_frontend* fe, u16* snr) 342static int at76c651_read_snr(struct dvb_frontend* fe, u16* snr)
343{ 343{
344 struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv; 344 struct at76c651_state* state = fe->demodulator_priv;
345 345
346 *snr = 0xFFFF - 346 *snr = 0xFFFF -
347 ((at76c651_readreg(state, 0x8F) << 8) | 347 ((at76c651_readreg(state, 0x8F) << 8) |
@@ -352,7 +352,7 @@ static int at76c651_read_snr(struct dvb_frontend* fe, u16* snr)
352 352
353static int at76c651_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 353static int at76c651_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
354{ 354{
355 struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv; 355 struct at76c651_state* state = fe->demodulator_priv;
356 356
357 *ucblocks = at76c651_readreg(state, 0x82); 357 *ucblocks = at76c651_readreg(state, 0x82);
358 358
@@ -369,7 +369,7 @@ static int at76c651_get_tune_settings(struct dvb_frontend* fe, struct dvb_fronte
369 369
370static void at76c651_release(struct dvb_frontend* fe) 370static void at76c651_release(struct dvb_frontend* fe)
371{ 371{
372 struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv; 372 struct at76c651_state* state = fe->demodulator_priv;
373 kfree(state); 373 kfree(state);
374} 374}
375 375
@@ -381,7 +381,7 @@ struct dvb_frontend* at76c651_attach(const struct at76c651_config* config,
381 struct at76c651_state* state = NULL; 381 struct at76c651_state* state = NULL;
382 382
383 /* allocate memory for the internal state */ 383 /* allocate memory for the internal state */
384 state = (struct at76c651_state*) kmalloc(sizeof(struct at76c651_state), GFP_KERNEL); 384 state = kmalloc(sizeof(struct at76c651_state), GFP_KERNEL);
385 if (state == NULL) goto error; 385 if (state == NULL) goto error;
386 386
387 /* setup the state */ 387 /* setup the state */
diff --git a/drivers/media/dvb/frontends/cx22700.c b/drivers/media/dvb/frontends/cx22700.c
index a212279042b8..0c2ed4438618 100644
--- a/drivers/media/dvb/frontends/cx22700.c
+++ b/drivers/media/dvb/frontends/cx22700.c
@@ -232,7 +232,7 @@ static int cx22700_get_tps (struct cx22700_state* state, struct dvb_ofdm_paramet
232 232
233static int cx22700_init (struct dvb_frontend* fe) 233static int cx22700_init (struct dvb_frontend* fe)
234 234
235{ struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv; 235{ struct cx22700_state* state = fe->demodulator_priv;
236 int i; 236 int i;
237 237
238 dprintk("cx22700_init: init chip\n"); 238 dprintk("cx22700_init: init chip\n");
@@ -258,7 +258,7 @@ static int cx22700_init (struct dvb_frontend* fe)
258 258
259static int cx22700_read_status(struct dvb_frontend* fe, fe_status_t* status) 259static int cx22700_read_status(struct dvb_frontend* fe, fe_status_t* status)
260{ 260{
261 struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv; 261 struct cx22700_state* state = fe->demodulator_priv;
262 262
263 u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9) 263 u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
264 | (cx22700_readreg (state, 0x0e) << 1); 264 | (cx22700_readreg (state, 0x0e) << 1);
@@ -286,7 +286,7 @@ static int cx22700_read_status(struct dvb_frontend* fe, fe_status_t* status)
286 286
287static int cx22700_read_ber(struct dvb_frontend* fe, u32* ber) 287static int cx22700_read_ber(struct dvb_frontend* fe, u32* ber)
288{ 288{
289 struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv; 289 struct cx22700_state* state = fe->demodulator_priv;
290 290
291 *ber = cx22700_readreg (state, 0x0c) & 0x7f; 291 *ber = cx22700_readreg (state, 0x0c) & 0x7f;
292 cx22700_writereg (state, 0x0c, 0x00); 292 cx22700_writereg (state, 0x0c, 0x00);
@@ -296,7 +296,7 @@ static int cx22700_read_ber(struct dvb_frontend* fe, u32* ber)
296 296
297static int cx22700_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) 297static int cx22700_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
298{ 298{
299 struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv; 299 struct cx22700_state* state = fe->demodulator_priv;
300 300
301 u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9) 301 u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
302 | (cx22700_readreg (state, 0x0e) << 1); 302 | (cx22700_readreg (state, 0x0e) << 1);
@@ -307,7 +307,7 @@ static int cx22700_read_signal_strength(struct dvb_frontend* fe, u16* signal_str
307 307
308static int cx22700_read_snr(struct dvb_frontend* fe, u16* snr) 308static int cx22700_read_snr(struct dvb_frontend* fe, u16* snr)
309{ 309{
310 struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv; 310 struct cx22700_state* state = fe->demodulator_priv;
311 311
312 u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9) 312 u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
313 | (cx22700_readreg (state, 0x0e) << 1); 313 | (cx22700_readreg (state, 0x0e) << 1);
@@ -318,7 +318,7 @@ static int cx22700_read_snr(struct dvb_frontend* fe, u16* snr)
318 318
319static int cx22700_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 319static int cx22700_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
320{ 320{
321 struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv; 321 struct cx22700_state* state = fe->demodulator_priv;
322 322
323 *ucblocks = cx22700_readreg (state, 0x0f); 323 *ucblocks = cx22700_readreg (state, 0x0f);
324 cx22700_writereg (state, 0x0f, 0x00); 324 cx22700_writereg (state, 0x0f, 0x00);
@@ -328,7 +328,7 @@ static int cx22700_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
328 328
329static int cx22700_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 329static int cx22700_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
330{ 330{
331 struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv; 331 struct cx22700_state* state = fe->demodulator_priv;
332 332
333 cx22700_writereg (state, 0x00, 0x02); /* XXX CHECKME: soft reset*/ 333 cx22700_writereg (state, 0x00, 0x02); /* XXX CHECKME: soft reset*/
334 cx22700_writereg (state, 0x00, 0x00); 334 cx22700_writereg (state, 0x00, 0x00);
@@ -346,7 +346,7 @@ static int cx22700_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
346 346
347static int cx22700_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 347static int cx22700_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
348{ 348{
349 struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv; 349 struct cx22700_state* state = fe->demodulator_priv;
350 u8 reg09 = cx22700_readreg (state, 0x09); 350 u8 reg09 = cx22700_readreg (state, 0x09);
351 351
352 p->inversion = reg09 & 0x1 ? INVERSION_ON : INVERSION_OFF; 352 p->inversion = reg09 & 0x1 ? INVERSION_ON : INVERSION_OFF;
@@ -363,7 +363,7 @@ static int cx22700_get_tune_settings(struct dvb_frontend* fe, struct dvb_fronten
363 363
364static void cx22700_release(struct dvb_frontend* fe) 364static void cx22700_release(struct dvb_frontend* fe)
365{ 365{
366 struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv; 366 struct cx22700_state* state = fe->demodulator_priv;
367 kfree(state); 367 kfree(state);
368} 368}
369 369
@@ -375,7 +375,7 @@ struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
375 struct cx22700_state* state = NULL; 375 struct cx22700_state* state = NULL;
376 376
377 /* allocate memory for the internal state */ 377 /* allocate memory for the internal state */
378 state = (struct cx22700_state*) kmalloc(sizeof(struct cx22700_state), GFP_KERNEL); 378 state = kmalloc(sizeof(struct cx22700_state), GFP_KERNEL);
379 if (state == NULL) goto error; 379 if (state == NULL) goto error;
380 380
381 /* setup the state */ 381 /* setup the state */
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
index 011860ce36cc..f4aa44136c7c 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -200,7 +200,7 @@ static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_paramet
200static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 200static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
201{ 201{
202 u8 val; 202 u8 val;
203 struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv; 203 struct cx22702_state* state = fe->demodulator_priv;
204 204
205 /* set PLL */ 205 /* set PLL */
206 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe); 206 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe);
@@ -338,7 +338,7 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet
338static int cx22702_init (struct dvb_frontend* fe) 338static int cx22702_init (struct dvb_frontend* fe)
339{ 339{
340 int i; 340 int i;
341 struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv; 341 struct cx22702_state* state = fe->demodulator_priv;
342 342
343 cx22702_writereg (state, 0x00, 0x02); 343 cx22702_writereg (state, 0x00, 0x02);
344 344
@@ -360,7 +360,7 @@ static int cx22702_init (struct dvb_frontend* fe)
360 360
361static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status) 361static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status)
362{ 362{
363 struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv; 363 struct cx22702_state* state = fe->demodulator_priv;
364 u8 reg0A; 364 u8 reg0A;
365 u8 reg23; 365 u8 reg23;
366 366
@@ -389,7 +389,7 @@ static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status)
389 389
390static int cx22702_read_ber(struct dvb_frontend* fe, u32* ber) 390static int cx22702_read_ber(struct dvb_frontend* fe, u32* ber)
391{ 391{
392 struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv; 392 struct cx22702_state* state = fe->demodulator_priv;
393 393
394 if(cx22702_readreg (state, 0xE4) & 0x02) { 394 if(cx22702_readreg (state, 0xE4) & 0x02) {
395 /* Realtime statistics */ 395 /* Realtime statistics */
@@ -406,7 +406,7 @@ static int cx22702_read_ber(struct dvb_frontend* fe, u32* ber)
406 406
407static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) 407static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
408{ 408{
409 struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv; 409 struct cx22702_state* state = fe->demodulator_priv;
410 410
411 *signal_strength = cx22702_readreg (state, 0x23); 411 *signal_strength = cx22702_readreg (state, 0x23);
412 412
@@ -415,7 +415,7 @@ static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* signal_str
415 415
416static int cx22702_read_snr(struct dvb_frontend* fe, u16* snr) 416static int cx22702_read_snr(struct dvb_frontend* fe, u16* snr)
417{ 417{
418 struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv; 418 struct cx22702_state* state = fe->demodulator_priv;
419 419
420 u16 rs_ber=0; 420 u16 rs_ber=0;
421 if(cx22702_readreg (state, 0xE4) & 0x02) { 421 if(cx22702_readreg (state, 0xE4) & 0x02) {
@@ -434,7 +434,7 @@ static int cx22702_read_snr(struct dvb_frontend* fe, u16* snr)
434 434
435static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 435static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
436{ 436{
437 struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv; 437 struct cx22702_state* state = fe->demodulator_priv;
438 438
439 u8 _ucblocks; 439 u8 _ucblocks;
440 440
@@ -449,7 +449,7 @@ static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
449 449
450static int cx22702_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 450static int cx22702_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
451{ 451{
452 struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv; 452 struct cx22702_state* state = fe->demodulator_priv;
453 453
454 u8 reg0C = cx22702_readreg (state, 0x0C); 454 u8 reg0C = cx22702_readreg (state, 0x0C);
455 455
@@ -459,7 +459,7 @@ static int cx22702_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
459 459
460static void cx22702_release(struct dvb_frontend* fe) 460static void cx22702_release(struct dvb_frontend* fe)
461{ 461{
462 struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv; 462 struct cx22702_state* state = fe->demodulator_priv;
463 kfree(state); 463 kfree(state);
464} 464}
465 465
@@ -471,7 +471,7 @@ struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
471 struct cx22702_state* state = NULL; 471 struct cx22702_state* state = NULL;
472 472
473 /* allocate memory for the internal state */ 473 /* allocate memory for the internal state */
474 state = (struct cx22702_state*) kmalloc(sizeof(struct cx22702_state), GFP_KERNEL); 474 state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL);
475 if (state == NULL) goto error; 475 if (state == NULL) goto error;
476 476
477 /* setup the state */ 477 /* setup the state */
diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c
index ae16112a0653..8222b88cb486 100644
--- a/drivers/media/dvb/frontends/cx24110.c
+++ b/drivers/media/dvb/frontends/cx24110.c
@@ -315,7 +315,7 @@ dprintk("cx24110 debug: entering %s(%d)\n",__FUNCTION__,srate);
315 315
316int cx24110_pll_write (struct dvb_frontend* fe, u32 data) 316int cx24110_pll_write (struct dvb_frontend* fe, u32 data)
317{ 317{
318 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 318 struct cx24110_state *state = fe->demodulator_priv;
319 319
320/* tuner data is 21 bits long, must be left-aligned in data */ 320/* tuner data is 21 bits long, must be left-aligned in data */
321/* tuner cx24108 is written through a dedicated 3wire interface on the demod chip */ 321/* tuner cx24108 is written through a dedicated 3wire interface on the demod chip */
@@ -356,7 +356,7 @@ int cx24110_pll_write (struct dvb_frontend* fe, u32 data)
356 356
357static int cx24110_initfe(struct dvb_frontend* fe) 357static int cx24110_initfe(struct dvb_frontend* fe)
358{ 358{
359 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 359 struct cx24110_state *state = fe->demodulator_priv;
360/* fixme (low): error handling */ 360/* fixme (low): error handling */
361 int i; 361 int i;
362 362
@@ -373,7 +373,7 @@ static int cx24110_initfe(struct dvb_frontend* fe)
373 373
374static int cx24110_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage) 374static int cx24110_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
375{ 375{
376 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 376 struct cx24110_state *state = fe->demodulator_priv;
377 377
378 switch (voltage) { 378 switch (voltage) {
379 case SEC_VOLTAGE_13: 379 case SEC_VOLTAGE_13:
@@ -385,8 +385,7 @@ static int cx24110_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag
385 }; 385 };
386} 386}
387 387
388static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, 388static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
389 fe_sec_mini_cmd_t burst)
390{ 389{
391 int rv, bit, i; 390 int rv, bit, i;
392 struct cx24110_state *state = fe->demodulator_priv; 391 struct cx24110_state *state = fe->demodulator_priv;
@@ -413,7 +412,7 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe,
413 struct dvb_diseqc_master_cmd *cmd) 412 struct dvb_diseqc_master_cmd *cmd)
414{ 413{
415 int i, rv; 414 int i, rv;
416 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 415 struct cx24110_state *state = fe->demodulator_priv;
417 416
418 for (i = 0; i < cmd->msg_len; i++) 417 for (i = 0; i < cmd->msg_len; i++)
419 cx24110_writereg(state, 0x79 + i, cmd->msg[i]); 418 cx24110_writereg(state, 0x79 + i, cmd->msg[i]);
@@ -432,7 +431,7 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe,
432 431
433static int cx24110_read_status(struct dvb_frontend* fe, fe_status_t* status) 432static int cx24110_read_status(struct dvb_frontend* fe, fe_status_t* status)
434{ 433{
435 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 434 struct cx24110_state *state = fe->demodulator_priv;
436 435
437 int sync = cx24110_readreg (state, 0x55); 436 int sync = cx24110_readreg (state, 0x55);
438 437
@@ -460,7 +459,7 @@ static int cx24110_read_status(struct dvb_frontend* fe, fe_status_t* status)
460 459
461static int cx24110_read_ber(struct dvb_frontend* fe, u32* ber) 460static int cx24110_read_ber(struct dvb_frontend* fe, u32* ber)
462{ 461{
463 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 462 struct cx24110_state *state = fe->demodulator_priv;
464 463
465 /* fixme (maybe): value range is 16 bit. Scale? */ 464 /* fixme (maybe): value range is 16 bit. Scale? */
466 if(cx24110_readreg(state,0x24)&0x10) { 465 if(cx24110_readreg(state,0x24)&0x10) {
@@ -478,7 +477,7 @@ static int cx24110_read_ber(struct dvb_frontend* fe, u32* ber)
478 477
479static int cx24110_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) 478static int cx24110_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
480{ 479{
481 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 480 struct cx24110_state *state = fe->demodulator_priv;
482 481
483/* no provision in hardware. Read the frontend AGC accumulator. No idea how to scale this, but I know it is 2s complement */ 482/* no provision in hardware. Read the frontend AGC accumulator. No idea how to scale this, but I know it is 2s complement */
484 u8 signal = cx24110_readreg (state, 0x27)+128; 483 u8 signal = cx24110_readreg (state, 0x27)+128;
@@ -489,7 +488,7 @@ static int cx24110_read_signal_strength(struct dvb_frontend* fe, u16* signal_str
489 488
490static int cx24110_read_snr(struct dvb_frontend* fe, u16* snr) 489static int cx24110_read_snr(struct dvb_frontend* fe, u16* snr)
491{ 490{
492 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 491 struct cx24110_state *state = fe->demodulator_priv;
493 492
494 /* no provision in hardware. Can be computed from the Es/N0 estimator, but I don't know how. */ 493 /* no provision in hardware. Can be computed from the Es/N0 estimator, but I don't know how. */
495 if(cx24110_readreg(state,0x6a)&0x80) { 494 if(cx24110_readreg(state,0x6a)&0x80) {
@@ -505,7 +504,7 @@ static int cx24110_read_snr(struct dvb_frontend* fe, u16* snr)
505 504
506static int cx24110_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 505static int cx24110_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
507{ 506{
508 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 507 struct cx24110_state *state = fe->demodulator_priv;
509 u32 lastbyer; 508 u32 lastbyer;
510 509
511 if(cx24110_readreg(state,0x10)&0x40) { 510 if(cx24110_readreg(state,0x10)&0x40) {
@@ -527,7 +526,7 @@ static int cx24110_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
527 526
528static int cx24110_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 527static int cx24110_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
529{ 528{
530 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 529 struct cx24110_state *state = fe->demodulator_priv;
531 530
532 state->config->pll_set(fe, p); 531 state->config->pll_set(fe, p);
533 cx24110_set_inversion (state, p->inversion); 532 cx24110_set_inversion (state, p->inversion);
@@ -540,7 +539,7 @@ static int cx24110_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
540 539
541static int cx24110_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 540static int cx24110_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
542{ 541{
543 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 542 struct cx24110_state *state = fe->demodulator_priv;
544 s32 afc; unsigned sclk; 543 s32 afc; unsigned sclk;
545 544
546/* cannot read back tuner settings (freq). Need to have some private storage */ 545/* cannot read back tuner settings (freq). Need to have some private storage */
@@ -567,14 +566,14 @@ static int cx24110_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
567 566
568static int cx24110_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 567static int cx24110_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
569{ 568{
570 struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv; 569 struct cx24110_state *state = fe->demodulator_priv;
571 570
572 return cx24110_writereg(state,0x76,(cx24110_readreg(state,0x76)&~0x10)|(((tone==SEC_TONE_ON))?0x10:0)); 571 return cx24110_writereg(state,0x76,(cx24110_readreg(state,0x76)&~0x10)|(((tone==SEC_TONE_ON))?0x10:0));
573} 572}
574 573
575static void cx24110_release(struct dvb_frontend* fe) 574static void cx24110_release(struct dvb_frontend* fe)
576{ 575{
577 struct cx24110_state* state = (struct cx24110_state*) fe->demodulator_priv; 576 struct cx24110_state* state = fe->demodulator_priv;
578 kfree(state); 577 kfree(state);
579} 578}
580 579
@@ -587,7 +586,7 @@ struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
587 int ret; 586 int ret;
588 587
589 /* allocate memory for the internal state */ 588 /* allocate memory for the internal state */
590 state = (struct cx24110_state*) kmalloc(sizeof(struct cx24110_state), GFP_KERNEL); 589 state = kmalloc(sizeof(struct cx24110_state), GFP_KERNEL);
591 if (state == NULL) goto error; 590 if (state == NULL) goto error;
592 591
593 /* setup the state */ 592 /* setup the state */
diff --git a/drivers/media/dvb/frontends/dib3000mb.c b/drivers/media/dvb/frontends/dib3000mb.c
index a853d12a26f1..6f52d649e97e 100644
--- a/drivers/media/dvb/frontends/dib3000mb.c
+++ b/drivers/media/dvb/frontends/dib3000mb.c
@@ -56,12 +56,12 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
56static int dib3000mb_set_frontend(struct dvb_frontend* fe, 56static int dib3000mb_set_frontend(struct dvb_frontend* fe,
57 struct dvb_frontend_parameters *fep, int tuner) 57 struct dvb_frontend_parameters *fep, int tuner)
58{ 58{
59 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 59 struct dib3000_state* state = fe->demodulator_priv;
60 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm; 60 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
61 fe_code_rate_t fe_cr = FEC_NONE; 61 fe_code_rate_t fe_cr = FEC_NONE;
62 int search_state, seq; 62 int search_state, seq;
63 63
64 if (tuner) { 64 if (tuner && state->config.pll_addr && state->config.pll_set) {
65 dib3000mb_tuner_pass_ctrl(fe,1,state->config.pll_addr(fe)); 65 dib3000mb_tuner_pass_ctrl(fe,1,state->config.pll_addr(fe));
66 state->config.pll_set(fe, fep, NULL); 66 state->config.pll_set(fe, fep, NULL);
67 dib3000mb_tuner_pass_ctrl(fe,0,state->config.pll_addr(fe)); 67 dib3000mb_tuner_pass_ctrl(fe,0,state->config.pll_addr(fe));
@@ -317,7 +317,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
317 317
318static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode) 318static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode)
319{ 319{
320 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 320 struct dib3000_state* state = fe->demodulator_priv;
321 321
322 deb_info("dib3000mb is getting up.\n"); 322 deb_info("dib3000mb is getting up.\n");
323 wr(DIB3000MB_REG_POWER_CONTROL, DIB3000MB_POWER_UP); 323 wr(DIB3000MB_REG_POWER_CONTROL, DIB3000MB_POWER_UP);
@@ -401,7 +401,7 @@ static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode)
401static int dib3000mb_get_frontend(struct dvb_frontend* fe, 401static int dib3000mb_get_frontend(struct dvb_frontend* fe,
402 struct dvb_frontend_parameters *fep) 402 struct dvb_frontend_parameters *fep)
403{ 403{
404 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 404 struct dib3000_state* state = fe->demodulator_priv;
405 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm; 405 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
406 fe_code_rate_t *cr; 406 fe_code_rate_t *cr;
407 u16 tps_val; 407 u16 tps_val;
@@ -562,7 +562,7 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
562 562
563static int dib3000mb_read_status(struct dvb_frontend* fe, fe_status_t *stat) 563static int dib3000mb_read_status(struct dvb_frontend* fe, fe_status_t *stat)
564{ 564{
565 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 565 struct dib3000_state* state = fe->demodulator_priv;
566 566
567 *stat = 0; 567 *stat = 0;
568 568
@@ -594,7 +594,7 @@ static int dib3000mb_read_status(struct dvb_frontend* fe, fe_status_t *stat)
594 594
595static int dib3000mb_read_ber(struct dvb_frontend* fe, u32 *ber) 595static int dib3000mb_read_ber(struct dvb_frontend* fe, u32 *ber)
596{ 596{
597 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 597 struct dib3000_state* state = fe->demodulator_priv;
598 598
599 *ber = ((rd(DIB3000MB_REG_BER_MSB) << 16) | rd(DIB3000MB_REG_BER_LSB)); 599 *ber = ((rd(DIB3000MB_REG_BER_MSB) << 16) | rd(DIB3000MB_REG_BER_LSB));
600 return 0; 600 return 0;
@@ -603,7 +603,7 @@ static int dib3000mb_read_ber(struct dvb_frontend* fe, u32 *ber)
603/* see dib3000-watch dvb-apps for exact calcuations of signal_strength and snr */ 603/* see dib3000-watch dvb-apps for exact calcuations of signal_strength and snr */
604static int dib3000mb_read_signal_strength(struct dvb_frontend* fe, u16 *strength) 604static int dib3000mb_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
605{ 605{
606 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 606 struct dib3000_state* state = fe->demodulator_priv;
607 607
608 *strength = rd(DIB3000MB_REG_SIGNAL_POWER) * 0xffff / 0x170; 608 *strength = rd(DIB3000MB_REG_SIGNAL_POWER) * 0xffff / 0x170;
609 return 0; 609 return 0;
@@ -611,7 +611,7 @@ static int dib3000mb_read_signal_strength(struct dvb_frontend* fe, u16 *strength
611 611
612static int dib3000mb_read_snr(struct dvb_frontend* fe, u16 *snr) 612static int dib3000mb_read_snr(struct dvb_frontend* fe, u16 *snr)
613{ 613{
614 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 614 struct dib3000_state* state = fe->demodulator_priv;
615 short sigpow = rd(DIB3000MB_REG_SIGNAL_POWER); 615 short sigpow = rd(DIB3000MB_REG_SIGNAL_POWER);
616 int icipow = ((rd(DIB3000MB_REG_NOISE_POWER_MSB) & 0xff) << 16) | 616 int icipow = ((rd(DIB3000MB_REG_NOISE_POWER_MSB) & 0xff) << 16) |
617 rd(DIB3000MB_REG_NOISE_POWER_LSB); 617 rd(DIB3000MB_REG_NOISE_POWER_LSB);
@@ -621,7 +621,7 @@ static int dib3000mb_read_snr(struct dvb_frontend* fe, u16 *snr)
621 621
622static int dib3000mb_read_unc_blocks(struct dvb_frontend* fe, u32 *unc) 622static int dib3000mb_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
623{ 623{
624 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 624 struct dib3000_state* state = fe->demodulator_priv;
625 625
626 *unc = rd(DIB3000MB_REG_UNC); 626 *unc = rd(DIB3000MB_REG_UNC);
627 return 0; 627 return 0;
@@ -629,7 +629,7 @@ static int dib3000mb_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
629 629
630static int dib3000mb_sleep(struct dvb_frontend* fe) 630static int dib3000mb_sleep(struct dvb_frontend* fe)
631{ 631{
632 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 632 struct dib3000_state* state = fe->demodulator_priv;
633 deb_info("dib3000mb is going to bed.\n"); 633 deb_info("dib3000mb is going to bed.\n");
634 wr(DIB3000MB_REG_POWER_CONTROL, DIB3000MB_POWER_DOWN); 634 wr(DIB3000MB_REG_POWER_CONTROL, DIB3000MB_POWER_DOWN);
635 return 0; 635 return 0;
@@ -656,7 +656,7 @@ static int dib3000mb_set_frontend_and_tuner(struct dvb_frontend* fe, struct dvb_
656 656
657static void dib3000mb_release(struct dvb_frontend* fe) 657static void dib3000mb_release(struct dvb_frontend* fe)
658{ 658{
659 struct dib3000_state *state = (struct dib3000_state*) fe->demodulator_priv; 659 struct dib3000_state *state = fe->demodulator_priv;
660 kfree(state); 660 kfree(state);
661} 661}
662 662
@@ -671,7 +671,7 @@ static int dib3000mb_pid_control(struct dvb_frontend *fe,int index, int pid,int
671 671
672static int dib3000mb_fifo_control(struct dvb_frontend *fe, int onoff) 672static int dib3000mb_fifo_control(struct dvb_frontend *fe, int onoff)
673{ 673{
674 struct dib3000_state *state = (struct dib3000_state*) fe->demodulator_priv; 674 struct dib3000_state *state = fe->demodulator_priv;
675 675
676 deb_xfer("%s fifo\n",onoff ? "enabling" : "disabling"); 676 deb_xfer("%s fifo\n",onoff ? "enabling" : "disabling");
677 if (onoff) { 677 if (onoff) {
@@ -692,7 +692,7 @@ static int dib3000mb_pid_parse(struct dvb_frontend *fe, int onoff)
692 692
693static int dib3000mb_tuner_pass_ctrl(struct dvb_frontend *fe, int onoff, u8 pll_addr) 693static int dib3000mb_tuner_pass_ctrl(struct dvb_frontend *fe, int onoff, u8 pll_addr)
694{ 694{
695 struct dib3000_state *state = (struct dib3000_state*) fe->demodulator_priv; 695 struct dib3000_state *state = fe->demodulator_priv;
696 if (onoff) { 696 if (onoff) {
697 wr(DIB3000MB_REG_TUNER, DIB3000_TUNER_WRITE_ENABLE(pll_addr)); 697 wr(DIB3000MB_REG_TUNER, DIB3000_TUNER_WRITE_ENABLE(pll_addr));
698 } else { 698 } else {
@@ -709,7 +709,7 @@ struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
709 struct dib3000_state* state = NULL; 709 struct dib3000_state* state = NULL;
710 710
711 /* allocate memory for the internal state */ 711 /* allocate memory for the internal state */
712 state = (struct dib3000_state*) kmalloc(sizeof(struct dib3000_state), GFP_KERNEL); 712 state = kmalloc(sizeof(struct dib3000_state), GFP_KERNEL);
713 if (state == NULL) 713 if (state == NULL)
714 goto error; 714 goto error;
715 memset(state,0,sizeof(struct dib3000_state)); 715 memset(state,0,sizeof(struct dib3000_state));
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
index 4a31c05eaecd..888f10a5e96b 100644
--- a/drivers/media/dvb/frontends/dib3000mc.c
+++ b/drivers/media/dvb/frontends/dib3000mc.c
@@ -297,7 +297,7 @@ static int dib3000mc_set_general_cfg(struct dib3000_state *state, struct dvb_fro
297static int dib3000mc_get_frontend(struct dvb_frontend* fe, 297static int dib3000mc_get_frontend(struct dvb_frontend* fe,
298 struct dvb_frontend_parameters *fep) 298 struct dvb_frontend_parameters *fep)
299{ 299{
300 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 300 struct dib3000_state* state = fe->demodulator_priv;
301 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm; 301 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
302 fe_code_rate_t *cr; 302 fe_code_rate_t *cr;
303 u16 tps_val,cr_val; 303 u16 tps_val,cr_val;
@@ -458,12 +458,12 @@ static int dib3000mc_get_frontend(struct dvb_frontend* fe,
458static int dib3000mc_set_frontend(struct dvb_frontend* fe, 458static int dib3000mc_set_frontend(struct dvb_frontend* fe,
459 struct dvb_frontend_parameters *fep, int tuner) 459 struct dvb_frontend_parameters *fep, int tuner)
460{ 460{
461 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 461 struct dib3000_state* state = fe->demodulator_priv;
462 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm; 462 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
463 int search_state,auto_val; 463 int search_state,auto_val;
464 u16 val; 464 u16 val;
465 465
466 if (tuner) { /* initial call from dvb */ 466 if (tuner && state->config.pll_addr && state->config.pll_set) { /* initial call from dvb */
467 dib3000mc_tuner_pass_ctrl(fe,1,state->config.pll_addr(fe)); 467 dib3000mc_tuner_pass_ctrl(fe,1,state->config.pll_addr(fe));
468 state->config.pll_set(fe,fep,NULL); 468 state->config.pll_set(fe,fep,NULL);
469 dib3000mc_tuner_pass_ctrl(fe,0,state->config.pll_addr(fe)); 469 dib3000mc_tuner_pass_ctrl(fe,0,state->config.pll_addr(fe));
@@ -659,7 +659,7 @@ static int dib3000mc_fe_init(struct dvb_frontend* fe, int mobile_mode)
659} 659}
660static int dib3000mc_read_status(struct dvb_frontend* fe, fe_status_t *stat) 660static int dib3000mc_read_status(struct dvb_frontend* fe, fe_status_t *stat)
661{ 661{
662 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 662 struct dib3000_state* state = fe->demodulator_priv;
663 u16 lock = rd(DIB3000MC_REG_LOCKING); 663 u16 lock = rd(DIB3000MC_REG_LOCKING);
664 664
665 *stat = 0; 665 *stat = 0;
@@ -679,14 +679,14 @@ static int dib3000mc_read_status(struct dvb_frontend* fe, fe_status_t *stat)
679 679
680static int dib3000mc_read_ber(struct dvb_frontend* fe, u32 *ber) 680static int dib3000mc_read_ber(struct dvb_frontend* fe, u32 *ber)
681{ 681{
682 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 682 struct dib3000_state* state = fe->demodulator_priv;
683 *ber = ((rd(DIB3000MC_REG_BER_MSB) << 16) | rd(DIB3000MC_REG_BER_LSB)); 683 *ber = ((rd(DIB3000MC_REG_BER_MSB) << 16) | rd(DIB3000MC_REG_BER_LSB));
684 return 0; 684 return 0;
685} 685}
686 686
687static int dib3000mc_read_unc_blocks(struct dvb_frontend* fe, u32 *unc) 687static int dib3000mc_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
688{ 688{
689 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 689 struct dib3000_state* state = fe->demodulator_priv;
690 690
691 *unc = rd(DIB3000MC_REG_PACKET_ERROR_COUNT); 691 *unc = rd(DIB3000MC_REG_PACKET_ERROR_COUNT);
692 return 0; 692 return 0;
@@ -695,7 +695,7 @@ static int dib3000mc_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
695/* see dib3000mb.c for calculation comments */ 695/* see dib3000mb.c for calculation comments */
696static int dib3000mc_read_signal_strength(struct dvb_frontend* fe, u16 *strength) 696static int dib3000mc_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
697{ 697{
698 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 698 struct dib3000_state* state = fe->demodulator_priv;
699 u16 val = rd(DIB3000MC_REG_SIGNAL_NOISE_LSB); 699 u16 val = rd(DIB3000MC_REG_SIGNAL_NOISE_LSB);
700 *strength = (((val >> 6) & 0xff) << 8) + (val & 0x3f); 700 *strength = (((val >> 6) & 0xff) << 8) + (val & 0x3f);
701 701
@@ -706,7 +706,7 @@ static int dib3000mc_read_signal_strength(struct dvb_frontend* fe, u16 *strength
706/* see dib3000mb.c for calculation comments */ 706/* see dib3000mb.c for calculation comments */
707static int dib3000mc_read_snr(struct dvb_frontend* fe, u16 *snr) 707static int dib3000mc_read_snr(struct dvb_frontend* fe, u16 *snr)
708{ 708{
709 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 709 struct dib3000_state* state = fe->demodulator_priv;
710 u16 val = rd(DIB3000MC_REG_SIGNAL_NOISE_LSB), 710 u16 val = rd(DIB3000MC_REG_SIGNAL_NOISE_LSB),
711 val2 = rd(DIB3000MC_REG_SIGNAL_NOISE_MSB); 711 val2 = rd(DIB3000MC_REG_SIGNAL_NOISE_MSB);
712 u16 sig,noise; 712 u16 sig,noise;
@@ -726,7 +726,7 @@ static int dib3000mc_read_snr(struct dvb_frontend* fe, u16 *snr)
726 726
727static int dib3000mc_sleep(struct dvb_frontend* fe) 727static int dib3000mc_sleep(struct dvb_frontend* fe)
728{ 728{
729 struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv; 729 struct dib3000_state* state = fe->demodulator_priv;
730 730
731 set_or(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_PWR_DOWN); 731 set_or(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_PWR_DOWN);
732 wr(DIB3000MC_REG_CLK_CFG_1,DIB3000MC_CLK_CFG_1_POWER_DOWN); 732 wr(DIB3000MC_REG_CLK_CFG_1,DIB3000MC_CLK_CFG_1_POWER_DOWN);
@@ -756,7 +756,7 @@ static int dib3000mc_set_frontend_and_tuner(struct dvb_frontend* fe, struct dvb_
756 756
757static void dib3000mc_release(struct dvb_frontend* fe) 757static void dib3000mc_release(struct dvb_frontend* fe)
758{ 758{
759 struct dib3000_state *state = (struct dib3000_state *) fe->demodulator_priv; 759 struct dib3000_state *state = fe->demodulator_priv;
760 kfree(state); 760 kfree(state);
761} 761}
762 762
@@ -771,7 +771,7 @@ static int dib3000mc_pid_control(struct dvb_frontend *fe,int index, int pid,int
771 771
772static int dib3000mc_fifo_control(struct dvb_frontend *fe, int onoff) 772static int dib3000mc_fifo_control(struct dvb_frontend *fe, int onoff)
773{ 773{
774 struct dib3000_state *state = (struct dib3000_state*) fe->demodulator_priv; 774 struct dib3000_state *state = fe->demodulator_priv;
775 u16 tmp = rd(DIB3000MC_REG_SMO_MODE); 775 u16 tmp = rd(DIB3000MC_REG_SMO_MODE);
776 776
777 deb_xfer("%s fifo\n",onoff ? "enabling" : "disabling"); 777 deb_xfer("%s fifo\n",onoff ? "enabling" : "disabling");
@@ -803,7 +803,7 @@ static int dib3000mc_pid_parse(struct dvb_frontend *fe, int onoff)
803 803
804static int dib3000mc_tuner_pass_ctrl(struct dvb_frontend *fe, int onoff, u8 pll_addr) 804static int dib3000mc_tuner_pass_ctrl(struct dvb_frontend *fe, int onoff, u8 pll_addr)
805{ 805{
806 struct dib3000_state *state = (struct dib3000_state*) fe->demodulator_priv; 806 struct dib3000_state *state = fe->demodulator_priv;
807 if (onoff) { 807 if (onoff) {
808 wr(DIB3000MC_REG_TUNER, DIB3000_TUNER_WRITE_ENABLE(pll_addr)); 808 wr(DIB3000MC_REG_TUNER, DIB3000_TUNER_WRITE_ENABLE(pll_addr));
809 } else { 809 } else {
@@ -844,7 +844,7 @@ struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config,
844 u16 devid; 844 u16 devid;
845 845
846 /* allocate memory for the internal state */ 846 /* allocate memory for the internal state */
847 state = (struct dib3000_state*) kmalloc(sizeof(struct dib3000_state), GFP_KERNEL); 847 state = kmalloc(sizeof(struct dib3000_state), GFP_KERNEL);
848 if (state == NULL) 848 if (state == NULL)
849 goto error; 849 goto error;
850 memset(state,0,sizeof(struct dib3000_state)); 850 memset(state,0,sizeof(struct dib3000_state));
diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h
index 016c794a5677..c4c3c56c4a81 100644
--- a/drivers/media/dvb/frontends/dvb-pll.h
+++ b/drivers/media/dvb/frontends/dvb-pll.h
@@ -2,6 +2,9 @@
2 * $Id: dvb-pll.h,v 1.2 2005/02/10 11:43:41 kraxel Exp $ 2 * $Id: dvb-pll.h,v 1.2 2005/02/10 11:43:41 kraxel Exp $
3 */ 3 */
4 4
5#ifndef __DVB_PLL_H__
6#define __DVB_PLL_H__
7
5struct dvb_pll_desc { 8struct dvb_pll_desc {
6 char *name; 9 char *name;
7 u32 min; 10 u32 min;
@@ -26,9 +29,4 @@ extern struct dvb_pll_desc dvb_pll_unknown_1;
26int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, 29int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
27 u32 freq, int bandwidth); 30 u32 freq, int bandwidth);
28 31
29/* 32#endif
30 * Local variables:
31 * c-basic-offset: 8
32 * compile-command: "make DVB=1"
33 * End:
34 */
diff --git a/drivers/media/dvb/frontends/dvb_dummy_fe.c b/drivers/media/dvb/frontends/dvb_dummy_fe.c
index c05a9b05600c..cff93b9d8ab2 100644
--- a/drivers/media/dvb/frontends/dvb_dummy_fe.c
+++ b/drivers/media/dvb/frontends/dvb_dummy_fe.c
@@ -100,7 +100,7 @@ static int dvb_dummy_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t vo
100 100
101static void dvb_dummy_fe_release(struct dvb_frontend* fe) 101static void dvb_dummy_fe_release(struct dvb_frontend* fe)
102{ 102{
103 struct dvb_dummy_fe_state* state = (struct dvb_dummy_fe_state*) fe->demodulator_priv; 103 struct dvb_dummy_fe_state* state = fe->demodulator_priv;
104 kfree(state); 104 kfree(state);
105} 105}
106 106
@@ -111,7 +111,7 @@ struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
111 struct dvb_dummy_fe_state* state = NULL; 111 struct dvb_dummy_fe_state* state = NULL;
112 112
113 /* allocate memory for the internal state */ 113 /* allocate memory for the internal state */
114 state = (struct dvb_dummy_fe_state*) kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 114 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
115 if (state == NULL) goto error; 115 if (state == NULL) goto error;
116 116
117 /* setup the state */ 117 /* setup the state */
@@ -134,7 +134,7 @@ struct dvb_frontend* dvb_dummy_fe_qpsk_attach()
134 struct dvb_dummy_fe_state* state = NULL; 134 struct dvb_dummy_fe_state* state = NULL;
135 135
136 /* allocate memory for the internal state */ 136 /* allocate memory for the internal state */
137 state = (struct dvb_dummy_fe_state*) kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 137 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
138 if (state == NULL) goto error; 138 if (state == NULL) goto error;
139 139
140 /* setup the state */ 140 /* setup the state */
@@ -157,7 +157,7 @@ struct dvb_frontend* dvb_dummy_fe_qam_attach()
157 struct dvb_dummy_fe_state* state = NULL; 157 struct dvb_dummy_fe_state* state = NULL;
158 158
159 /* allocate memory for the internal state */ 159 /* allocate memory for the internal state */
160 state = (struct dvb_dummy_fe_state*) kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 160 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
161 if (state == NULL) goto error; 161 if (state == NULL) goto error;
162 162
163 /* setup the state */ 163 /* setup the state */
diff --git a/drivers/media/dvb/frontends/l64781.c b/drivers/media/dvb/frontends/l64781.c
index 9ac95de9834d..031a1ddc7d11 100644
--- a/drivers/media/dvb/frontends/l64781.c
+++ b/drivers/media/dvb/frontends/l64781.c
@@ -121,7 +121,7 @@ static int reset_and_configure (struct l64781_state* state)
121 121
122static int apply_frontend_param (struct dvb_frontend* fe, struct dvb_frontend_parameters *param) 122static int apply_frontend_param (struct dvb_frontend* fe, struct dvb_frontend_parameters *param)
123{ 123{
124 struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv; 124 struct l64781_state* state = fe->demodulator_priv;
125 /* The coderates for FEC_NONE, FEC_4_5 and FEC_FEC_6_7 are arbitrary */ 125 /* The coderates for FEC_NONE, FEC_4_5 and FEC_FEC_6_7 are arbitrary */
126 static const u8 fec_tab[] = { 7, 0, 1, 2, 9, 3, 10, 4 }; 126 static const u8 fec_tab[] = { 7, 0, 1, 2, 9, 3, 10, 4 };
127 /* QPSK, QAM_16, QAM_64 */ 127 /* QPSK, QAM_16, QAM_64 */
@@ -234,7 +234,7 @@ static int apply_frontend_param (struct dvb_frontend* fe, struct dvb_frontend_pa
234 234
235static int get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* param) 235static int get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* param)
236{ 236{
237 struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv; 237 struct l64781_state* state = fe->demodulator_priv;
238 int tmp; 238 int tmp;
239 239
240 240
@@ -352,7 +352,7 @@ static int get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters*
352 352
353static int l64781_read_status(struct dvb_frontend* fe, fe_status_t* status) 353static int l64781_read_status(struct dvb_frontend* fe, fe_status_t* status)
354{ 354{
355 struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv; 355 struct l64781_state* state = fe->demodulator_priv;
356 int sync = l64781_readreg (state, 0x32); 356 int sync = l64781_readreg (state, 0x32);
357 int gain = l64781_readreg (state, 0x0e); 357 int gain = l64781_readreg (state, 0x0e);
358 358
@@ -381,7 +381,7 @@ static int l64781_read_status(struct dvb_frontend* fe, fe_status_t* status)
381 381
382static int l64781_read_ber(struct dvb_frontend* fe, u32* ber) 382static int l64781_read_ber(struct dvb_frontend* fe, u32* ber)
383{ 383{
384 struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv; 384 struct l64781_state* state = fe->demodulator_priv;
385 385
386 /* XXX FIXME: set up counting period (reg 0x26...0x28) 386 /* XXX FIXME: set up counting period (reg 0x26...0x28)
387 */ 387 */
@@ -393,7 +393,7 @@ static int l64781_read_ber(struct dvb_frontend* fe, u32* ber)
393 393
394static int l64781_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) 394static int l64781_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
395{ 395{
396 struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv; 396 struct l64781_state* state = fe->demodulator_priv;
397 397
398 u8 gain = l64781_readreg (state, 0x0e); 398 u8 gain = l64781_readreg (state, 0x0e);
399 *signal_strength = (gain << 8) | gain; 399 *signal_strength = (gain << 8) | gain;
@@ -403,7 +403,7 @@ static int l64781_read_signal_strength(struct dvb_frontend* fe, u16* signal_stre
403 403
404static int l64781_read_snr(struct dvb_frontend* fe, u16* snr) 404static int l64781_read_snr(struct dvb_frontend* fe, u16* snr)
405{ 405{
406 struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv; 406 struct l64781_state* state = fe->demodulator_priv;
407 407
408 u8 avg_quality = 0xff - l64781_readreg (state, 0x33); 408 u8 avg_quality = 0xff - l64781_readreg (state, 0x33);
409 *snr = (avg_quality << 8) | avg_quality; /* not exact, but...*/ 409 *snr = (avg_quality << 8) | avg_quality; /* not exact, but...*/
@@ -413,7 +413,7 @@ static int l64781_read_snr(struct dvb_frontend* fe, u16* snr)
413 413
414static int l64781_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 414static int l64781_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
415{ 415{
416 struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv; 416 struct l64781_state* state = fe->demodulator_priv;
417 417
418 *ucblocks = l64781_readreg (state, 0x37) 418 *ucblocks = l64781_readreg (state, 0x37)
419 | (l64781_readreg (state, 0x38) << 8); 419 | (l64781_readreg (state, 0x38) << 8);
@@ -423,7 +423,7 @@ static int l64781_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
423 423
424static int l64781_sleep(struct dvb_frontend* fe) 424static int l64781_sleep(struct dvb_frontend* fe)
425{ 425{
426 struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv; 426 struct l64781_state* state = fe->demodulator_priv;
427 427
428 /* Power down */ 428 /* Power down */
429 return l64781_writereg (state, 0x3e, 0x5a); 429 return l64781_writereg (state, 0x3e, 0x5a);
@@ -431,7 +431,7 @@ static int l64781_sleep(struct dvb_frontend* fe)
431 431
432static int l64781_init(struct dvb_frontend* fe) 432static int l64781_init(struct dvb_frontend* fe)
433{ 433{
434 struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv; 434 struct l64781_state* state = fe->demodulator_priv;
435 435
436 reset_and_configure (state); 436 reset_and_configure (state);
437 437
@@ -484,7 +484,7 @@ static int l64781_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend
484 484
485static void l64781_release(struct dvb_frontend* fe) 485static void l64781_release(struct dvb_frontend* fe)
486{ 486{
487 struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv; 487 struct l64781_state* state = fe->demodulator_priv;
488 kfree(state); 488 kfree(state);
489} 489}
490 490
@@ -501,7 +501,7 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
501 { .addr = config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; 501 { .addr = config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
502 502
503 /* allocate memory for the internal state */ 503 /* allocate memory for the internal state */
504 state = (struct l64781_state*) kmalloc(sizeof(struct l64781_state), GFP_KERNEL); 504 state = kmalloc(sizeof(struct l64781_state), GFP_KERNEL);
505 if (state == NULL) goto error; 505 if (state == NULL) goto error;
506 506
507 /* setup the state */ 507 /* setup the state */
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c
index 176a22e3441b..e455aecd76b2 100644
--- a/drivers/media/dvb/frontends/mt312.c
+++ b/drivers/media/dvb/frontends/mt312.c
@@ -226,7 +226,7 @@ static int mt312_get_code_rate(struct mt312_state* state, fe_code_rate_t *cr)
226 226
227static int mt312_initfe(struct dvb_frontend* fe) 227static int mt312_initfe(struct dvb_frontend* fe)
228{ 228{
229 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 229 struct mt312_state *state = fe->demodulator_priv;
230 int ret; 230 int ret;
231 u8 buf[2]; 231 u8 buf[2];
232 232
@@ -287,7 +287,7 @@ static int mt312_initfe(struct dvb_frontend* fe)
287static int mt312_send_master_cmd(struct dvb_frontend* fe, 287static int mt312_send_master_cmd(struct dvb_frontend* fe,
288 struct dvb_diseqc_master_cmd *c) 288 struct dvb_diseqc_master_cmd *c)
289{ 289{
290 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 290 struct mt312_state *state = fe->demodulator_priv;
291 int ret; 291 int ret;
292 u8 diseqc_mode; 292 u8 diseqc_mode;
293 293
@@ -318,7 +318,7 @@ static int mt312_send_master_cmd(struct dvb_frontend* fe,
318 318
319static int mt312_send_burst(struct dvb_frontend* fe, const fe_sec_mini_cmd_t c) 319static int mt312_send_burst(struct dvb_frontend* fe, const fe_sec_mini_cmd_t c)
320{ 320{
321 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 321 struct mt312_state *state = fe->demodulator_priv;
322 const u8 mini_tab[2] = { 0x02, 0x03 }; 322 const u8 mini_tab[2] = { 0x02, 0x03 };
323 323
324 int ret; 324 int ret;
@@ -340,7 +340,7 @@ static int mt312_send_burst(struct dvb_frontend* fe, const fe_sec_mini_cmd_t c)
340 340
341static int mt312_set_tone(struct dvb_frontend* fe, const fe_sec_tone_mode_t t) 341static int mt312_set_tone(struct dvb_frontend* fe, const fe_sec_tone_mode_t t)
342{ 342{
343 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 343 struct mt312_state *state = fe->demodulator_priv;
344 const u8 tone_tab[2] = { 0x01, 0x00 }; 344 const u8 tone_tab[2] = { 0x01, 0x00 };
345 345
346 int ret; 346 int ret;
@@ -362,7 +362,7 @@ static int mt312_set_tone(struct dvb_frontend* fe, const fe_sec_tone_mode_t t)
362 362
363static int mt312_set_voltage(struct dvb_frontend* fe, const fe_sec_voltage_t v) 363static int mt312_set_voltage(struct dvb_frontend* fe, const fe_sec_voltage_t v)
364{ 364{
365 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 365 struct mt312_state *state = fe->demodulator_priv;
366 const u8 volt_tab[3] = { 0x00, 0x40, 0x00 }; 366 const u8 volt_tab[3] = { 0x00, 0x40, 0x00 };
367 367
368 if (v > SEC_VOLTAGE_OFF) 368 if (v > SEC_VOLTAGE_OFF)
@@ -373,7 +373,7 @@ static int mt312_set_voltage(struct dvb_frontend* fe, const fe_sec_voltage_t v)
373 373
374static int mt312_read_status(struct dvb_frontend* fe, fe_status_t *s) 374static int mt312_read_status(struct dvb_frontend* fe, fe_status_t *s)
375{ 375{
376 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 376 struct mt312_state *state = fe->demodulator_priv;
377 int ret; 377 int ret;
378 u8 status[3]; 378 u8 status[3];
379 379
@@ -400,7 +400,7 @@ static int mt312_read_status(struct dvb_frontend* fe, fe_status_t *s)
400 400
401static int mt312_read_ber(struct dvb_frontend* fe, u32 *ber) 401static int mt312_read_ber(struct dvb_frontend* fe, u32 *ber)
402{ 402{
403 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 403 struct mt312_state *state = fe->demodulator_priv;
404 int ret; 404 int ret;
405 u8 buf[3]; 405 u8 buf[3];
406 406
@@ -414,7 +414,7 @@ static int mt312_read_ber(struct dvb_frontend* fe, u32 *ber)
414 414
415static int mt312_read_signal_strength(struct dvb_frontend* fe, u16 *signal_strength) 415static int mt312_read_signal_strength(struct dvb_frontend* fe, u16 *signal_strength)
416{ 416{
417 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 417 struct mt312_state *state = fe->demodulator_priv;
418 int ret; 418 int ret;
419 u8 buf[3]; 419 u8 buf[3];
420 u16 agc; 420 u16 agc;
@@ -435,7 +435,7 @@ static int mt312_read_signal_strength(struct dvb_frontend* fe, u16 *signal_stren
435 435
436static int mt312_read_snr(struct dvb_frontend* fe, u16 *snr) 436static int mt312_read_snr(struct dvb_frontend* fe, u16 *snr)
437{ 437{
438 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 438 struct mt312_state *state = fe->demodulator_priv;
439 int ret; 439 int ret;
440 u8 buf[2]; 440 u8 buf[2];
441 441
@@ -449,7 +449,7 @@ static int mt312_read_snr(struct dvb_frontend* fe, u16 *snr)
449 449
450static int mt312_read_ucblocks(struct dvb_frontend* fe, u32 *ubc) 450static int mt312_read_ucblocks(struct dvb_frontend* fe, u32 *ubc)
451{ 451{
452 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 452 struct mt312_state *state = fe->demodulator_priv;
453 int ret; 453 int ret;
454 u8 buf[2]; 454 u8 buf[2];
455 455
@@ -464,7 +464,7 @@ static int mt312_read_ucblocks(struct dvb_frontend* fe, u32 *ubc)
464static int mt312_set_frontend(struct dvb_frontend* fe, 464static int mt312_set_frontend(struct dvb_frontend* fe,
465 struct dvb_frontend_parameters *p) 465 struct dvb_frontend_parameters *p)
466{ 466{
467 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 467 struct mt312_state *state = fe->demodulator_priv;
468 int ret; 468 int ret;
469 u8 buf[5], config_val; 469 u8 buf[5], config_val;
470 u16 sr; 470 u16 sr;
@@ -560,7 +560,7 @@ static int mt312_set_frontend(struct dvb_frontend* fe,
560static int mt312_get_frontend(struct dvb_frontend* fe, 560static int mt312_get_frontend(struct dvb_frontend* fe,
561 struct dvb_frontend_parameters *p) 561 struct dvb_frontend_parameters *p)
562{ 562{
563 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 563 struct mt312_state *state = fe->demodulator_priv;
564 int ret; 564 int ret;
565 565
566 if ((ret = mt312_get_inversion(state, &p->inversion)) < 0) 566 if ((ret = mt312_get_inversion(state, &p->inversion)) < 0)
@@ -577,7 +577,7 @@ static int mt312_get_frontend(struct dvb_frontend* fe,
577 577
578static int mt312_sleep(struct dvb_frontend* fe) 578static int mt312_sleep(struct dvb_frontend* fe)
579{ 579{
580 struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv; 580 struct mt312_state *state = fe->demodulator_priv;
581 int ret; 581 int ret;
582 u8 config; 582 u8 config;
583 583
@@ -605,7 +605,7 @@ static int mt312_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_
605 605
606static void mt312_release(struct dvb_frontend* fe) 606static void mt312_release(struct dvb_frontend* fe)
607{ 607{
608 struct mt312_state* state = (struct mt312_state*) fe->demodulator_priv; 608 struct mt312_state* state = fe->demodulator_priv;
609 kfree(state); 609 kfree(state);
610} 610}
611 611
@@ -617,7 +617,7 @@ struct dvb_frontend* vp310_attach(const struct mt312_config* config,
617 struct mt312_state* state = NULL; 617 struct mt312_state* state = NULL;
618 618
619 /* allocate memory for the internal state */ 619 /* allocate memory for the internal state */
620 state = (struct mt312_state*) kmalloc(sizeof(struct mt312_state), GFP_KERNEL); 620 state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
621 if (state == NULL) 621 if (state == NULL)
622 goto error; 622 goto error;
623 623
@@ -651,7 +651,7 @@ struct dvb_frontend* mt312_attach(const struct mt312_config* config,
651 struct mt312_state* state = NULL; 651 struct mt312_state* state = NULL;
652 652
653 /* allocate memory for the internal state */ 653 /* allocate memory for the internal state */
654 state = (struct mt312_state*) kmalloc(sizeof(struct mt312_state), GFP_KERNEL); 654 state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
655 if (state == NULL) 655 if (state == NULL)
656 goto error; 656 goto error;
657 657
diff --git a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c
index 50326c7248fa..d32dc4de9e7f 100644
--- a/drivers/media/dvb/frontends/mt352.c
+++ b/drivers/media/dvb/frontends/mt352.c
@@ -46,7 +46,7 @@ struct mt352_state {
46 struct dvb_frontend_ops ops; 46 struct dvb_frontend_ops ops;
47 47
48 /* configuration settings */ 48 /* configuration settings */
49 const struct mt352_config* config; 49 struct mt352_config config;
50}; 50};
51 51
52static int debug; 52static int debug;
@@ -59,7 +59,7 @@ static int mt352_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
59{ 59{
60 struct mt352_state* state = fe->demodulator_priv; 60 struct mt352_state* state = fe->demodulator_priv;
61 u8 buf[2] = { reg, val }; 61 u8 buf[2] = { reg, val };
62 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, 62 struct i2c_msg msg = { .addr = state->config.demod_address, .flags = 0,
63 .buf = buf, .len = 2 }; 63 .buf = buf, .len = 2 };
64 int err = i2c_transfer(state->i2c, &msg, 1); 64 int err = i2c_transfer(state->i2c, &msg, 1);
65 if (err != 1) { 65 if (err != 1) {
@@ -84,10 +84,10 @@ static int mt352_read_register(struct mt352_state* state, u8 reg)
84 int ret; 84 int ret;
85 u8 b0 [] = { reg }; 85 u8 b0 [] = { reg };
86 u8 b1 [] = { 0 }; 86 u8 b1 [] = { 0 };
87 struct i2c_msg msg [] = { { .addr = state->config->demod_address, 87 struct i2c_msg msg [] = { { .addr = state->config.demod_address,
88 .flags = 0, 88 .flags = 0,
89 .buf = b0, .len = 1 }, 89 .buf = b0, .len = 1 },
90 { .addr = state->config->demod_address, 90 { .addr = state->config.demod_address,
91 .flags = I2C_M_RD, 91 .flags = I2C_M_RD,
92 .buf = b1, .len = 1 } }; 92 .buf = b1, .len = 1 } };
93 93
@@ -102,11 +102,6 @@ static int mt352_read_register(struct mt352_state* state, u8 reg)
102 return b1[0]; 102 return b1[0];
103} 103}
104 104
105int mt352_read(struct dvb_frontend *fe, u8 reg)
106{
107 return mt352_read_register(fe->demodulator_priv,reg);
108}
109
110static int mt352_sleep(struct dvb_frontend* fe) 105static int mt352_sleep(struct dvb_frontend* fe)
111{ 106{
112 static u8 mt352_softdown[] = { CLOCK_CTL, 0x20, 0x08 }; 107 static u8 mt352_softdown[] = { CLOCK_CTL, 0x20, 0x08 };
@@ -134,8 +129,8 @@ static void mt352_calc_nominal_rate(struct mt352_state* state,
134 bw = 8; 129 bw = 8;
135 break; 130 break;
136 } 131 }
137 if (state->config->adc_clock) 132 if (state->config.adc_clock)
138 adc_clock = state->config->adc_clock; 133 adc_clock = state->config.adc_clock;
139 134
140 value = 64 * bw * (1<<16) / (7 * 8); 135 value = 64 * bw * (1<<16) / (7 * 8);
141 value = value * 1000 / adc_clock; 136 value = value * 1000 / adc_clock;
@@ -152,10 +147,10 @@ static void mt352_calc_input_freq(struct mt352_state* state,
152 int if2 = 36167; /* 36.166667 MHz */ 147 int if2 = 36167; /* 36.166667 MHz */
153 int ife,value; 148 int ife,value;
154 149
155 if (state->config->adc_clock) 150 if (state->config.adc_clock)
156 adc_clock = state->config->adc_clock; 151 adc_clock = state->config.adc_clock;
157 if (state->config->if2) 152 if (state->config.if2)
158 if2 = state->config->if2; 153 if2 = state->config.if2;
159 154
160 ife = (2*adc_clock - if2); 155 ife = (2*adc_clock - if2);
161 value = -16374 * ife / adc_clock; 156 value = -16374 * ife / adc_clock;
@@ -289,10 +284,10 @@ static int mt352_set_parameters(struct dvb_frontend* fe,
289 284
290 mt352_calc_nominal_rate(state, op->bandwidth, buf+4); 285 mt352_calc_nominal_rate(state, op->bandwidth, buf+4);
291 mt352_calc_input_freq(state, buf+6); 286 mt352_calc_input_freq(state, buf+6);
292 state->config->pll_set(fe, param, buf+8); 287 state->config.pll_set(fe, param, buf+8);
293 288
294 mt352_write(fe, buf, sizeof(buf)); 289 mt352_write(fe, buf, sizeof(buf));
295 if (state->config->no_tuner) { 290 if (state->config.no_tuner) {
296 /* start decoding */ 291 /* start decoding */
297 mt352_write(fe, fsm_go, 2); 292 mt352_write(fe, fsm_go, 2);
298 } else { 293 } else {
@@ -516,7 +511,7 @@ static int mt352_init(struct dvb_frontend* fe)
516 511
517 /* Do a "hard" reset */ 512 /* Do a "hard" reset */
518 mt352_write(fe, mt352_reset_attach, sizeof(mt352_reset_attach)); 513 mt352_write(fe, mt352_reset_attach, sizeof(mt352_reset_attach));
519 return state->config->demod_init(fe); 514 return state->config.demod_init(fe);
520 } 515 }
521 516
522 return 0; 517 return 0;
@@ -541,8 +536,8 @@ struct dvb_frontend* mt352_attach(const struct mt352_config* config,
541 memset(state,0,sizeof(*state)); 536 memset(state,0,sizeof(*state));
542 537
543 /* setup the state */ 538 /* setup the state */
544 state->config = config;
545 state->i2c = i2c; 539 state->i2c = i2c;
540 memcpy(&state->config,config,sizeof(struct mt352_config));
546 memcpy(&state->ops, &mt352_ops, sizeof(struct dvb_frontend_ops)); 541 memcpy(&state->ops, &mt352_ops, sizeof(struct dvb_frontend_ops));
547 542
548 /* check if the demod is there */ 543 /* check if the demod is there */
@@ -601,10 +596,3 @@ MODULE_LICENSE("GPL");
601 596
602EXPORT_SYMBOL(mt352_attach); 597EXPORT_SYMBOL(mt352_attach);
603EXPORT_SYMBOL(mt352_write); 598EXPORT_SYMBOL(mt352_write);
604EXPORT_SYMBOL(mt352_read);
605/*
606 * Local variables:
607 * c-basic-offset: 8
608 * compile-command: "make DVB=1"
609 * End:
610 */
diff --git a/drivers/media/dvb/frontends/mt352.h b/drivers/media/dvb/frontends/mt352.h
index f5d8a5aed8a9..03040cd595bb 100644
--- a/drivers/media/dvb/frontends/mt352.h
+++ b/drivers/media/dvb/frontends/mt352.h
@@ -61,12 +61,5 @@ extern struct dvb_frontend* mt352_attach(const struct mt352_config* config,
61 struct i2c_adapter* i2c); 61 struct i2c_adapter* i2c);
62 62
63extern int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen); 63extern int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen);
64extern int mt352_read(struct dvb_frontend *fe, u8 reg);
65 64
66#endif // MT352_H 65#endif // MT352_H
67
68/*
69 * Local variables:
70 * c-basic-offset: 8
71 * End:
72 */
diff --git a/drivers/media/dvb/frontends/nxt2002.c b/drivers/media/dvb/frontends/nxt2002.c
index 4743aa17406e..35a1d60f1927 100644
--- a/drivers/media/dvb/frontends/nxt2002.c
+++ b/drivers/media/dvb/frontends/nxt2002.c
@@ -241,7 +241,7 @@ static void nxt2002_agc_reset(struct nxt2002_state* state)
241static int nxt2002_load_firmware (struct dvb_frontend* fe, const struct firmware *fw) 241static int nxt2002_load_firmware (struct dvb_frontend* fe, const struct firmware *fw)
242{ 242{
243 243
244 struct nxt2002_state* state = (struct nxt2002_state*) fe->demodulator_priv; 244 struct nxt2002_state* state = fe->demodulator_priv;
245 u8 buf[256],written = 0,chunkpos = 0; 245 u8 buf[256],written = 0,chunkpos = 0;
246 u16 rambase,position,crc = 0; 246 u16 rambase,position,crc = 0;
247 247
@@ -309,7 +309,7 @@ static int nxt2002_load_firmware (struct dvb_frontend* fe, const struct firmware
309static int nxt2002_setup_frontend_parameters (struct dvb_frontend* fe, 309static int nxt2002_setup_frontend_parameters (struct dvb_frontend* fe,
310 struct dvb_frontend_parameters *p) 310 struct dvb_frontend_parameters *p)
311{ 311{
312 struct nxt2002_state* state = (struct nxt2002_state*) fe->demodulator_priv; 312 struct nxt2002_state* state = fe->demodulator_priv;
313 u32 freq = 0; 313 u32 freq = 0;
314 u16 tunerfreq = 0; 314 u16 tunerfreq = 0;
315 u8 buf[4]; 315 u8 buf[4];
@@ -343,8 +343,6 @@ static int nxt2002_setup_frontend_parameters (struct dvb_frontend* fe,
343 /* reset the agc now that tuning has been completed */ 343 /* reset the agc now that tuning has been completed */
344 nxt2002_agc_reset(state); 344 nxt2002_agc_reset(state);
345 345
346
347
348 /* set target power level */ 346 /* set target power level */
349 switch (p->u.vsb.modulation) { 347 switch (p->u.vsb.modulation) {
350 case QAM_64: 348 case QAM_64:
@@ -453,7 +451,7 @@ static int nxt2002_setup_frontend_parameters (struct dvb_frontend* fe,
453 451
454static int nxt2002_read_status(struct dvb_frontend* fe, fe_status_t* status) 452static int nxt2002_read_status(struct dvb_frontend* fe, fe_status_t* status)
455{ 453{
456 struct nxt2002_state* state = (struct nxt2002_state*) fe->demodulator_priv; 454 struct nxt2002_state* state = fe->demodulator_priv;
457 u8 lock; 455 u8 lock;
458 i2c_readbytes(state,0x31,&lock,1); 456 i2c_readbytes(state,0x31,&lock,1);
459 457
@@ -470,7 +468,7 @@ static int nxt2002_read_status(struct dvb_frontend* fe, fe_status_t* status)
470 468
471static int nxt2002_read_ber(struct dvb_frontend* fe, u32* ber) 469static int nxt2002_read_ber(struct dvb_frontend* fe, u32* ber)
472{ 470{
473 struct nxt2002_state* state = (struct nxt2002_state*) fe->demodulator_priv; 471 struct nxt2002_state* state = fe->demodulator_priv;
474 u8 b[3]; 472 u8 b[3];
475 473
476 nxt2002_readreg_multibyte(state,0xE6,b,3); 474 nxt2002_readreg_multibyte(state,0xE6,b,3);
@@ -482,7 +480,7 @@ static int nxt2002_read_ber(struct dvb_frontend* fe, u32* ber)
482 480
483static int nxt2002_read_signal_strength(struct dvb_frontend* fe, u16* strength) 481static int nxt2002_read_signal_strength(struct dvb_frontend* fe, u16* strength)
484{ 482{
485 struct nxt2002_state* state = (struct nxt2002_state*) fe->demodulator_priv; 483 struct nxt2002_state* state = fe->demodulator_priv;
486 u8 b[2]; 484 u8 b[2];
487 u16 temp = 0; 485 u16 temp = 0;
488 486
@@ -502,7 +500,7 @@ static int nxt2002_read_signal_strength(struct dvb_frontend* fe, u16* strength)
502static int nxt2002_read_snr(struct dvb_frontend* fe, u16* snr) 500static int nxt2002_read_snr(struct dvb_frontend* fe, u16* snr)
503{ 501{
504 502
505 struct nxt2002_state* state = (struct nxt2002_state*) fe->demodulator_priv; 503 struct nxt2002_state* state = fe->demodulator_priv;
506 u8 b[2]; 504 u8 b[2];
507 u16 temp = 0, temp2; 505 u16 temp = 0, temp2;
508 u32 snrdb = 0; 506 u32 snrdb = 0;
@@ -536,7 +534,7 @@ static int nxt2002_read_snr(struct dvb_frontend* fe, u16* snr)
536 534
537static int nxt2002_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 535static int nxt2002_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
538{ 536{
539 struct nxt2002_state* state = (struct nxt2002_state*) fe->demodulator_priv; 537 struct nxt2002_state* state = fe->demodulator_priv;
540 u8 b[3]; 538 u8 b[3];
541 539
542 nxt2002_readreg_multibyte(state,0xE6,b,3); 540 nxt2002_readreg_multibyte(state,0xE6,b,3);
@@ -552,7 +550,7 @@ static int nxt2002_sleep(struct dvb_frontend* fe)
552 550
553static int nxt2002_init(struct dvb_frontend* fe) 551static int nxt2002_init(struct dvb_frontend* fe)
554{ 552{
555 struct nxt2002_state* state = (struct nxt2002_state*) fe->demodulator_priv; 553 struct nxt2002_state* state = fe->demodulator_priv;
556 const struct firmware *fw; 554 const struct firmware *fw;
557 int ret; 555 int ret;
558 u8 buf[2]; 556 u8 buf[2];
@@ -624,7 +622,7 @@ static int nxt2002_get_tune_settings(struct dvb_frontend* fe, struct dvb_fronten
624 622
625static void nxt2002_release(struct dvb_frontend* fe) 623static void nxt2002_release(struct dvb_frontend* fe)
626{ 624{
627 struct nxt2002_state* state = (struct nxt2002_state*) fe->demodulator_priv; 625 struct nxt2002_state* state = fe->demodulator_priv;
628 kfree(state); 626 kfree(state);
629} 627}
630 628
@@ -637,7 +635,7 @@ struct dvb_frontend* nxt2002_attach(const struct nxt2002_config* config,
637 u8 buf [] = {0,0,0,0,0}; 635 u8 buf [] = {0,0,0,0,0};
638 636
639 /* allocate memory for the internal state */ 637 /* allocate memory for the internal state */
640 state = (struct nxt2002_state*) kmalloc(sizeof(struct nxt2002_state), GFP_KERNEL); 638 state = kmalloc(sizeof(struct nxt2002_state), GFP_KERNEL);
641 if (state == NULL) goto error; 639 if (state == NULL) goto error;
642 640
643 /* setup the state */ 641 /* setup the state */
diff --git a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c
index a41f7da8b842..966de9853d18 100644
--- a/drivers/media/dvb/frontends/nxt6000.c
+++ b/drivers/media/dvb/frontends/nxt6000.c
@@ -176,11 +176,16 @@ static int nxt6000_set_transmission_mode(struct nxt6000_state* state, fe_transmi
176 176
177static void nxt6000_setup(struct dvb_frontend* fe) 177static void nxt6000_setup(struct dvb_frontend* fe)
178{ 178{
179 struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv; 179 struct nxt6000_state* state = fe->demodulator_priv;
180 180
181 nxt6000_writereg(state, RS_COR_SYNC_PARAM, SYNC_PARAM); 181 nxt6000_writereg(state, RS_COR_SYNC_PARAM, SYNC_PARAM);
182 nxt6000_writereg(state, BER_CTRL, /*(1 << 2) | */ (0x01 << 1) | 0x01); 182 nxt6000_writereg(state, BER_CTRL, /*(1 << 2) | */ (0x01 << 1) | 0x01);
183 nxt6000_writereg(state, VIT_COR_CTL, VIT_COR_RESYNC); 183 nxt6000_writereg(state, VIT_BERTIME_2, 0x00); // BER Timer = 0x000200 * 256 = 131072 bits
184 nxt6000_writereg(state, VIT_BERTIME_1, 0x02); //
185 nxt6000_writereg(state, VIT_BERTIME_0, 0x00); //
186 nxt6000_writereg(state, VIT_COR_INTEN, 0x98); // Enable BER interrupts
187 nxt6000_writereg(state, VIT_COR_CTL, 0x82); // Enable BER measurement
188 nxt6000_writereg(state, VIT_COR_CTL, VIT_COR_RESYNC | 0x02 );
184 nxt6000_writereg(state, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(state, OFDM_COR_CTL) & 0x0F)); 189 nxt6000_writereg(state, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(state, OFDM_COR_CTL) & 0x0F));
185 nxt6000_writereg(state, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02); 190 nxt6000_writereg(state, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02);
186 nxt6000_writereg(state, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW); 191 nxt6000_writereg(state, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW);
@@ -422,7 +427,7 @@ static void nxt6000_dump_status(struct nxt6000_state *state)
422static int nxt6000_read_status(struct dvb_frontend* fe, fe_status_t* status) 427static int nxt6000_read_status(struct dvb_frontend* fe, fe_status_t* status)
423{ 428{
424 u8 core_status; 429 u8 core_status;
425 struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv; 430 struct nxt6000_state* state = fe->demodulator_priv;
426 431
427 *status = 0; 432 *status = 0;
428 433
@@ -451,7 +456,7 @@ static int nxt6000_read_status(struct dvb_frontend* fe, fe_status_t* status)
451 456
452static int nxt6000_init(struct dvb_frontend* fe) 457static int nxt6000_init(struct dvb_frontend* fe)
453{ 458{
454 struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv; 459 struct nxt6000_state* state = fe->demodulator_priv;
455 460
456 nxt6000_reset(state); 461 nxt6000_reset(state);
457 nxt6000_setup(fe); 462 nxt6000_setup(fe);
@@ -461,7 +466,7 @@ static int nxt6000_init(struct dvb_frontend* fe)
461 466
462static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *param) 467static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *param)
463{ 468{
464 struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv; 469 struct nxt6000_state* state = fe->demodulator_priv;
465 int result; 470 int result;
466 471
467 nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x01); /* open i2c bus switch */ 472 nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x01); /* open i2c bus switch */
@@ -482,10 +487,44 @@ static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
482 487
483static void nxt6000_release(struct dvb_frontend* fe) 488static void nxt6000_release(struct dvb_frontend* fe)
484{ 489{
485 struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv; 490 struct nxt6000_state* state = fe->demodulator_priv;
486 kfree(state); 491 kfree(state);
487} 492}
488 493
494static int nxt6000_read_snr(struct dvb_frontend* fe, u16* snr)
495{
496 struct nxt6000_state* state = fe->demodulator_priv;
497
498 *snr = nxt6000_readreg( state, OFDM_CHC_SNR) / 8;
499
500 return 0;
501}
502
503static int nxt6000_read_ber(struct dvb_frontend* fe, u32* ber)
504{
505 struct nxt6000_state* state = fe->demodulator_priv;
506
507 nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18 );
508
509 *ber = (nxt6000_readreg( state, VIT_BER_1 ) << 8 ) |
510 nxt6000_readreg( state, VIT_BER_0 );
511
512 nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18); // Clear BER Done interrupts
513
514 return 0;
515}
516
517static int nxt6000_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
518{
519 struct nxt6000_state* state = fe->demodulator_priv;
520
521 *signal_strength = (short) (511 -
522 (nxt6000_readreg(state, AGC_GAIN_1) +
523 ((nxt6000_readreg(state, AGC_GAIN_2) & 0x03) << 8)));
524
525 return 0;
526}
527
489static struct dvb_frontend_ops nxt6000_ops; 528static struct dvb_frontend_ops nxt6000_ops;
490 529
491struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, 530struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
@@ -494,7 +533,7 @@ struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
494 struct nxt6000_state* state = NULL; 533 struct nxt6000_state* state = NULL;
495 534
496 /* allocate memory for the internal state */ 535 /* allocate memory for the internal state */
497 state = (struct nxt6000_state*) kmalloc(sizeof(struct nxt6000_state), GFP_KERNEL); 536 state = kmalloc(sizeof(struct nxt6000_state), GFP_KERNEL);
498 if (state == NULL) goto error; 537 if (state == NULL) goto error;
499 538
500 /* setup the state */ 539 /* setup the state */
@@ -542,6 +581,9 @@ static struct dvb_frontend_ops nxt6000_ops = {
542 .set_frontend = nxt6000_set_frontend, 581 .set_frontend = nxt6000_set_frontend,
543 582
544 .read_status = nxt6000_read_status, 583 .read_status = nxt6000_read_status,
584 .read_ber = nxt6000_read_ber,
585 .read_signal_strength = nxt6000_read_signal_strength,
586 .read_snr = nxt6000_read_snr,
545}; 587};
546 588
547module_param(debug, int, 0644); 589module_param(debug, int, 0644);
diff --git a/drivers/media/dvb/frontends/nxt6000_priv.h b/drivers/media/dvb/frontends/nxt6000_priv.h
index 64b1a89b2a22..0422e580038a 100644
--- a/drivers/media/dvb/frontends/nxt6000_priv.h
+++ b/drivers/media/dvb/frontends/nxt6000_priv.h
@@ -65,12 +65,27 @@
65#define BER_DONE (0x08) 65#define BER_DONE (0x08)
66#define BER_OVERFLOW (0x10) 66#define BER_OVERFLOW (0x10)
67 67
68/* 0x38 VIT_BERTIME_2 */
69#define VIT_BERTIME_2 (0x38)
70
71/* 0x39 VIT_BERTIME_1 */
72#define VIT_BERTIME_1 (0x39)
73
74/* 0x3A VIT_BERTIME_0 */
75#define VIT_BERTIME_0 (0x3a)
76
68 /* 0x38 OFDM_BERTimer *//* Use the alias registers */ 77 /* 0x38 OFDM_BERTimer *//* Use the alias registers */
69#define A_VIT_BER_TIMER_0 (0x1D) 78#define A_VIT_BER_TIMER_0 (0x1D)
70 79
71 /* 0x3A VIT_BER_TIMER_0 *//* Use the alias registers */ 80 /* 0x3A VIT_BER_TIMER_0 *//* Use the alias registers */
72#define A_VIT_BER_0 (0x1B) 81#define A_VIT_BER_0 (0x1B)
73 82
83/* 0x3B VIT_BER_1 */
84#define VIT_BER_1 (0x3b)
85
86/* 0x3C VIT_BER_0 */
87#define VIT_BER_0 (0x3c)
88
74/* 0x40 OFDM_COR_CTL */ 89/* 0x40 OFDM_COR_CTL */
75#define OFDM_COR_CTL (0x40) 90#define OFDM_COR_CTL (0x40)
76#define COREACT (0x20) 91#define COREACT (0x20)
@@ -117,6 +132,12 @@
117#define OFDM_ITB_CTL (0x4B) 132#define OFDM_ITB_CTL (0x4B)
118#define ITBINV (0x01) 133#define ITBINV (0x01)
119 134
135/* 0x49 AGC_GAIN_1 */
136#define AGC_GAIN_1 (0x49)
137
138/* 0x4A AGC_GAIN_2 */
139#define AGC_GAIN_2 (0x4A)
140
120/* 0x4C OFDM_ITB_FREQ_1 */ 141/* 0x4C OFDM_ITB_FREQ_1 */
121#define OFDM_ITB_FREQ_1 (0x4C) 142#define OFDM_ITB_FREQ_1 (0x4C)
122 143
diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c
index df5dee7760a3..cc0a77c790f1 100644
--- a/drivers/media/dvb/frontends/or51132.c
+++ b/drivers/media/dvb/frontends/or51132.c
@@ -102,7 +102,7 @@ static u8 i2c_readbytes (struct or51132_state* state, u8 reg, u8* buf, int len)
102 102
103static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware *fw) 103static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware *fw)
104{ 104{
105 struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv; 105 struct or51132_state* state = fe->demodulator_priv;
106 static u8 run_buf[] = {0x7F,0x01}; 106 static u8 run_buf[] = {0x7F,0x01};
107 static u8 get_ver_buf[] = {0x04,0x00,0x30,0x00,0x00}; 107 static u8 get_ver_buf[] = {0x04,0x00,0x30,0x00,0x00};
108 u8 rec_buf[14]; 108 u8 rec_buf[14];
@@ -240,7 +240,7 @@ static int or51132_sleep(struct dvb_frontend* fe)
240 240
241static int or51132_setmode(struct dvb_frontend* fe) 241static int or51132_setmode(struct dvb_frontend* fe)
242{ 242{
243 struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv; 243 struct or51132_state* state = fe->demodulator_priv;
244 unsigned char cmd_buf[4]; 244 unsigned char cmd_buf[4];
245 245
246 dprintk("setmode %d\n",(int)state->current_modulation); 246 dprintk("setmode %d\n",(int)state->current_modulation);
@@ -316,7 +316,7 @@ static int or51132_set_parameters(struct dvb_frontend* fe,
316{ 316{
317 int ret; 317 int ret;
318 u8 buf[4]; 318 u8 buf[4];
319 struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv; 319 struct or51132_state* state = fe->demodulator_priv;
320 const struct firmware *fw; 320 const struct firmware *fw;
321 321
322 /* Change only if we are actually changing the modulation */ 322 /* Change only if we are actually changing the modulation */
@@ -391,7 +391,7 @@ static int or51132_set_parameters(struct dvb_frontend* fe,
391 391
392static int or51132_read_status(struct dvb_frontend* fe, fe_status_t* status) 392static int or51132_read_status(struct dvb_frontend* fe, fe_status_t* status)
393{ 393{
394 struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv; 394 struct or51132_state* state = fe->demodulator_priv;
395 unsigned char rec_buf[2]; 395 unsigned char rec_buf[2];
396 unsigned char snd_buf[2]; 396 unsigned char snd_buf[2];
397 *status = 0; 397 *status = 0;
@@ -464,7 +464,7 @@ static unsigned int i20Log10(unsigned short val)
464 464
465static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength) 465static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength)
466{ 466{
467 struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv; 467 struct or51132_state* state = fe->demodulator_priv;
468 unsigned char rec_buf[2]; 468 unsigned char rec_buf[2];
469 unsigned char snd_buf[2]; 469 unsigned char snd_buf[2];
470 u8 rcvr_stat; 470 u8 rcvr_stat;
@@ -512,7 +512,7 @@ static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength)
512 512
513static int or51132_read_snr(struct dvb_frontend* fe, u16* snr) 513static int or51132_read_snr(struct dvb_frontend* fe, u16* snr)
514{ 514{
515 struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv; 515 struct or51132_state* state = fe->demodulator_priv;
516 unsigned char rec_buf[2]; 516 unsigned char rec_buf[2];
517 unsigned char snd_buf[2]; 517 unsigned char snd_buf[2];
518 u16 snr_equ; 518 u16 snr_equ;
@@ -549,7 +549,7 @@ static int or51132_get_tune_settings(struct dvb_frontend* fe, struct dvb_fronten
549 549
550static void or51132_release(struct dvb_frontend* fe) 550static void or51132_release(struct dvb_frontend* fe)
551{ 551{
552 struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv; 552 struct or51132_state* state = fe->demodulator_priv;
553 kfree(state); 553 kfree(state);
554} 554}
555 555
diff --git a/drivers/media/dvb/frontends/sp8870.c b/drivers/media/dvb/frontends/sp8870.c
index 58ad34ef0a00..764a95a2e212 100644
--- a/drivers/media/dvb/frontends/sp8870.c
+++ b/drivers/media/dvb/frontends/sp8870.c
@@ -248,7 +248,7 @@ static int sp8870_wake_up(struct sp8870_state* state)
248static int sp8870_set_frontend_parameters (struct dvb_frontend* fe, 248static int sp8870_set_frontend_parameters (struct dvb_frontend* fe,
249 struct dvb_frontend_parameters *p) 249 struct dvb_frontend_parameters *p)
250{ 250{
251 struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv; 251 struct sp8870_state* state = fe->demodulator_priv;
252 int err; 252 int err;
253 u16 reg0xc05; 253 u16 reg0xc05;
254 254
@@ -302,7 +302,7 @@ static int sp8870_set_frontend_parameters (struct dvb_frontend* fe,
302 302
303static int sp8870_init (struct dvb_frontend* fe) 303static int sp8870_init (struct dvb_frontend* fe)
304{ 304{
305 struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv; 305 struct sp8870_state* state = fe->demodulator_priv;
306 const struct firmware *fw = NULL; 306 const struct firmware *fw = NULL;
307 307
308 sp8870_wake_up(state); 308 sp8870_wake_up(state);
@@ -358,7 +358,7 @@ static int sp8870_init (struct dvb_frontend* fe)
358 358
359static int sp8870_read_status (struct dvb_frontend* fe, fe_status_t * fe_status) 359static int sp8870_read_status (struct dvb_frontend* fe, fe_status_t * fe_status)
360{ 360{
361 struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv; 361 struct sp8870_state* state = fe->demodulator_priv;
362 int status; 362 int status;
363 int signal; 363 int signal;
364 364
@@ -384,7 +384,7 @@ static int sp8870_read_status (struct dvb_frontend* fe, fe_status_t * fe_status)
384 384
385static int sp8870_read_ber (struct dvb_frontend* fe, u32 * ber) 385static int sp8870_read_ber (struct dvb_frontend* fe, u32 * ber)
386{ 386{
387 struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv; 387 struct sp8870_state* state = fe->demodulator_priv;
388 int ret; 388 int ret;
389 u32 tmp; 389 u32 tmp;
390 390
@@ -412,7 +412,7 @@ static int sp8870_read_ber (struct dvb_frontend* fe, u32 * ber)
412 412
413static int sp8870_read_signal_strength(struct dvb_frontend* fe, u16 * signal) 413static int sp8870_read_signal_strength(struct dvb_frontend* fe, u16 * signal)
414{ 414{
415 struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv; 415 struct sp8870_state* state = fe->demodulator_priv;
416 int ret; 416 int ret;
417 u16 tmp; 417 u16 tmp;
418 418
@@ -438,7 +438,7 @@ static int sp8870_read_signal_strength(struct dvb_frontend* fe, u16 * signal)
438 438
439static int sp8870_read_uncorrected_blocks (struct dvb_frontend* fe, u32* ublocks) 439static int sp8870_read_uncorrected_blocks (struct dvb_frontend* fe, u32* ublocks)
440{ 440{
441 struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv; 441 struct sp8870_state* state = fe->demodulator_priv;
442 int ret; 442 int ret;
443 443
444 *ublocks = 0; 444 *ublocks = 0;
@@ -467,7 +467,7 @@ static int switches = 0;
467 467
468static int sp8870_set_frontend (struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 468static int sp8870_set_frontend (struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
469{ 469{
470 struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv; 470 struct sp8870_state* state = fe->demodulator_priv;
471 471
472 /* 472 /*
473 The firmware of the sp8870 sometimes locks up after setting frontend parameters. 473 The firmware of the sp8870 sometimes locks up after setting frontend parameters.
@@ -524,7 +524,7 @@ static int sp8870_set_frontend (struct dvb_frontend* fe, struct dvb_frontend_par
524 524
525static int sp8870_sleep(struct dvb_frontend* fe) 525static int sp8870_sleep(struct dvb_frontend* fe)
526{ 526{
527 struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv; 527 struct sp8870_state* state = fe->demodulator_priv;
528 528
529 // tristate TS output and disable interface pins 529 // tristate TS output and disable interface pins
530 return sp8870_writereg(state, 0xC18, 0x000); 530 return sp8870_writereg(state, 0xC18, 0x000);
@@ -540,7 +540,7 @@ static int sp8870_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend
540 540
541static void sp8870_release(struct dvb_frontend* fe) 541static void sp8870_release(struct dvb_frontend* fe)
542{ 542{
543 struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv; 543 struct sp8870_state* state = fe->demodulator_priv;
544 kfree(state); 544 kfree(state);
545} 545}
546 546
@@ -552,7 +552,7 @@ struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
552 struct sp8870_state* state = NULL; 552 struct sp8870_state* state = NULL;
553 553
554 /* allocate memory for the internal state */ 554 /* allocate memory for the internal state */
555 state = (struct sp8870_state*) kmalloc(sizeof(struct sp8870_state), GFP_KERNEL); 555 state = kmalloc(sizeof(struct sp8870_state), GFP_KERNEL);
556 if (state == NULL) goto error; 556 if (state == NULL) goto error;
557 557
558 /* setup the state */ 558 /* setup the state */
diff --git a/drivers/media/dvb/frontends/sp887x.c b/drivers/media/dvb/frontends/sp887x.c
index 7eae833ece49..d868a6927a16 100644
--- a/drivers/media/dvb/frontends/sp887x.c
+++ b/drivers/media/dvb/frontends/sp887x.c
@@ -135,7 +135,7 @@ static void sp887x_setup_agc (struct sp887x_state* state)
135 */ 135 */
136static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware *fw) 136static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware *fw)
137{ 137{
138 struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv; 138 struct sp887x_state* state = fe->demodulator_priv;
139 u8 buf [BLOCKSIZE+2]; 139 u8 buf [BLOCKSIZE+2];
140 int i; 140 int i;
141 int fw_size = fw->size; 141 int fw_size = fw->size;
@@ -344,7 +344,7 @@ static void sp887x_correct_offsets (struct sp887x_state* state,
344static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe, 344static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe,
345 struct dvb_frontend_parameters *p) 345 struct dvb_frontend_parameters *p)
346{ 346{
347 struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv; 347 struct sp887x_state* state = fe->demodulator_priv;
348 int actual_freq, err; 348 int actual_freq, err;
349 u16 val, reg0xc05; 349 u16 val, reg0xc05;
350 350
@@ -405,7 +405,7 @@ static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe,
405 405
406static int sp887x_read_status(struct dvb_frontend* fe, fe_status_t* status) 406static int sp887x_read_status(struct dvb_frontend* fe, fe_status_t* status)
407{ 407{
408 struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv; 408 struct sp887x_state* state = fe->demodulator_priv;
409 u16 snr12 = sp887x_readreg(state, 0xf16); 409 u16 snr12 = sp887x_readreg(state, 0xf16);
410 u16 sync0x200 = sp887x_readreg(state, 0x200); 410 u16 sync0x200 = sp887x_readreg(state, 0x200);
411 u16 sync0xf17 = sp887x_readreg(state, 0xf17); 411 u16 sync0xf17 = sp887x_readreg(state, 0xf17);
@@ -439,7 +439,7 @@ static int sp887x_read_status(struct dvb_frontend* fe, fe_status_t* status)
439 439
440static int sp887x_read_ber(struct dvb_frontend* fe, u32* ber) 440static int sp887x_read_ber(struct dvb_frontend* fe, u32* ber)
441{ 441{
442 struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv; 442 struct sp887x_state* state = fe->demodulator_priv;
443 443
444 *ber = (sp887x_readreg(state, 0xc08) & 0x3f) | 444 *ber = (sp887x_readreg(state, 0xc08) & 0x3f) |
445 (sp887x_readreg(state, 0xc07) << 6); 445 (sp887x_readreg(state, 0xc07) << 6);
@@ -453,7 +453,7 @@ static int sp887x_read_ber(struct dvb_frontend* fe, u32* ber)
453 453
454static int sp887x_read_signal_strength(struct dvb_frontend* fe, u16* strength) 454static int sp887x_read_signal_strength(struct dvb_frontend* fe, u16* strength)
455{ 455{
456 struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv; 456 struct sp887x_state* state = fe->demodulator_priv;
457 457
458 u16 snr12 = sp887x_readreg(state, 0xf16); 458 u16 snr12 = sp887x_readreg(state, 0xf16);
459 u32 signal = 3 * (snr12 << 4); 459 u32 signal = 3 * (snr12 << 4);
@@ -464,7 +464,7 @@ static int sp887x_read_signal_strength(struct dvb_frontend* fe, u16* strength)
464 464
465static int sp887x_read_snr(struct dvb_frontend* fe, u16* snr) 465static int sp887x_read_snr(struct dvb_frontend* fe, u16* snr)
466{ 466{
467 struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv; 467 struct sp887x_state* state = fe->demodulator_priv;
468 468
469 u16 snr12 = sp887x_readreg(state, 0xf16); 469 u16 snr12 = sp887x_readreg(state, 0xf16);
470 *snr = (snr12 << 4) | (snr12 >> 8); 470 *snr = (snr12 << 4) | (snr12 >> 8);
@@ -474,7 +474,7 @@ static int sp887x_read_snr(struct dvb_frontend* fe, u16* snr)
474 474
475static int sp887x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 475static int sp887x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
476{ 476{
477 struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv; 477 struct sp887x_state* state = fe->demodulator_priv;
478 478
479 *ucblocks = sp887x_readreg(state, 0xc0c); 479 *ucblocks = sp887x_readreg(state, 0xc0c);
480 if (*ucblocks == 0xfff) 480 if (*ucblocks == 0xfff)
@@ -485,7 +485,7 @@ static int sp887x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
485 485
486static int sp887x_sleep(struct dvb_frontend* fe) 486static int sp887x_sleep(struct dvb_frontend* fe)
487{ 487{
488 struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv; 488 struct sp887x_state* state = fe->demodulator_priv;
489 489
490 /* tristate TS output and disable interface pins */ 490 /* tristate TS output and disable interface pins */
491 sp887x_writereg(state, 0xc18, 0x000); 491 sp887x_writereg(state, 0xc18, 0x000);
@@ -495,7 +495,7 @@ static int sp887x_sleep(struct dvb_frontend* fe)
495 495
496static int sp887x_init(struct dvb_frontend* fe) 496static int sp887x_init(struct dvb_frontend* fe)
497{ 497{
498 struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv; 498 struct sp887x_state* state = fe->demodulator_priv;
499 const struct firmware *fw = NULL; 499 const struct firmware *fw = NULL;
500 int ret; 500 int ret;
501 501
@@ -534,7 +534,7 @@ static int sp887x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend
534 534
535static void sp887x_release(struct dvb_frontend* fe) 535static void sp887x_release(struct dvb_frontend* fe)
536{ 536{
537 struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv; 537 struct sp887x_state* state = fe->demodulator_priv;
538 kfree(state); 538 kfree(state);
539} 539}
540 540
@@ -546,7 +546,7 @@ struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
546 struct sp887x_state* state = NULL; 546 struct sp887x_state* state = NULL;
547 547
548 /* allocate memory for the internal state */ 548 /* allocate memory for the internal state */
549 state = (struct sp887x_state*) kmalloc(sizeof(struct sp887x_state), GFP_KERNEL); 549 state = kmalloc(sizeof(struct sp887x_state), GFP_KERNEL);
550 if (state == NULL) goto error; 550 if (state == NULL) goto error;
551 551
552 /* setup the state */ 552 /* setup the state */
diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c
index 502c6403dfc6..e681263bf079 100644
--- a/drivers/media/dvb/frontends/stv0297.c
+++ b/drivers/media/dvb/frontends/stv0297.c
@@ -365,7 +365,7 @@ static int stv0297_set_inversion(struct stv0297_state *state, fe_spectral_invers
365 365
366int stv0297_enable_plli2c(struct dvb_frontend *fe) 366int stv0297_enable_plli2c(struct dvb_frontend *fe)
367{ 367{
368 struct stv0297_state *state = (struct stv0297_state *) fe->demodulator_priv; 368 struct stv0297_state *state = fe->demodulator_priv;
369 369
370 stv0297_writereg(state, 0x87, 0x78); 370 stv0297_writereg(state, 0x87, 0x78);
371 stv0297_writereg(state, 0x86, 0xc8); 371 stv0297_writereg(state, 0x86, 0xc8);
@@ -375,7 +375,7 @@ int stv0297_enable_plli2c(struct dvb_frontend *fe)
375 375
376static int stv0297_init(struct dvb_frontend *fe) 376static int stv0297_init(struct dvb_frontend *fe)
377{ 377{
378 struct stv0297_state *state = (struct stv0297_state *) fe->demodulator_priv; 378 struct stv0297_state *state = fe->demodulator_priv;
379 int i; 379 int i;
380 380
381 /* soft reset */ 381 /* soft reset */
@@ -416,7 +416,7 @@ static int stv0297_init(struct dvb_frontend *fe)
416 416
417static int stv0297_sleep(struct dvb_frontend *fe) 417static int stv0297_sleep(struct dvb_frontend *fe)
418{ 418{
419 struct stv0297_state *state = (struct stv0297_state *) fe->demodulator_priv; 419 struct stv0297_state *state = fe->demodulator_priv;
420 420
421 stv0297_writereg_mask(state, 0x80, 1, 1); 421 stv0297_writereg_mask(state, 0x80, 1, 1);
422 422
@@ -425,7 +425,7 @@ static int stv0297_sleep(struct dvb_frontend *fe)
425 425
426static int stv0297_read_status(struct dvb_frontend *fe, fe_status_t * status) 426static int stv0297_read_status(struct dvb_frontend *fe, fe_status_t * status)
427{ 427{
428 struct stv0297_state *state = (struct stv0297_state *) fe->demodulator_priv; 428 struct stv0297_state *state = fe->demodulator_priv;
429 429
430 u8 sync = stv0297_readreg(state, 0xDF); 430 u8 sync = stv0297_readreg(state, 0xDF);
431 431
@@ -438,7 +438,7 @@ static int stv0297_read_status(struct dvb_frontend *fe, fe_status_t * status)
438 438
439static int stv0297_read_ber(struct dvb_frontend *fe, u32 * ber) 439static int stv0297_read_ber(struct dvb_frontend *fe, u32 * ber)
440{ 440{
441 struct stv0297_state *state = (struct stv0297_state *) fe->demodulator_priv; 441 struct stv0297_state *state = fe->demodulator_priv;
442 u8 BER[3]; 442 u8 BER[3];
443 443
444 stv0297_writereg(state, 0xA0, 0x80); // Start Counting bit errors for 4096 Bytes 444 stv0297_writereg(state, 0xA0, 0x80); // Start Counting bit errors for 4096 Bytes
@@ -453,7 +453,7 @@ static int stv0297_read_ber(struct dvb_frontend *fe, u32 * ber)
453 453
454static int stv0297_read_signal_strength(struct dvb_frontend *fe, u16 * strength) 454static int stv0297_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
455{ 455{
456 struct stv0297_state *state = (struct stv0297_state *) fe->demodulator_priv; 456 struct stv0297_state *state = fe->demodulator_priv;
457 u8 STRENGTH[2]; 457 u8 STRENGTH[2];
458 458
459 stv0297_readregs(state, 0x41, STRENGTH, 2); 459 stv0297_readregs(state, 0x41, STRENGTH, 2);
@@ -464,7 +464,7 @@ static int stv0297_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
464 464
465static int stv0297_read_snr(struct dvb_frontend *fe, u16 * snr) 465static int stv0297_read_snr(struct dvb_frontend *fe, u16 * snr)
466{ 466{
467 struct stv0297_state *state = (struct stv0297_state *) fe->demodulator_priv; 467 struct stv0297_state *state = fe->demodulator_priv;
468 u8 SNR[2]; 468 u8 SNR[2];
469 469
470 stv0297_readregs(state, 0x07, SNR, 2); 470 stv0297_readregs(state, 0x07, SNR, 2);
@@ -475,7 +475,7 @@ static int stv0297_read_snr(struct dvb_frontend *fe, u16 * snr)
475 475
476static int stv0297_read_ucblocks(struct dvb_frontend *fe, u32 * ucblocks) 476static int stv0297_read_ucblocks(struct dvb_frontend *fe, u32 * ucblocks)
477{ 477{
478 struct stv0297_state *state = (struct stv0297_state *) fe->demodulator_priv; 478 struct stv0297_state *state = fe->demodulator_priv;
479 479
480 *ucblocks = (stv0297_readreg(state, 0xD5) << 8) 480 *ucblocks = (stv0297_readreg(state, 0xD5) << 8)
481 | stv0297_readreg(state, 0xD4); 481 | stv0297_readreg(state, 0xD4);
@@ -485,7 +485,7 @@ static int stv0297_read_ucblocks(struct dvb_frontend *fe, u32 * ucblocks)
485 485
486static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) 486static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
487{ 487{
488 struct stv0297_state *state = (struct stv0297_state *) fe->demodulator_priv; 488 struct stv0297_state *state = fe->demodulator_priv;
489 int u_threshold; 489 int u_threshold;
490 int initial_u; 490 int initial_u;
491 int blind_u; 491 int blind_u;
@@ -689,7 +689,7 @@ timeout:
689 689
690static int stv0297_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) 690static int stv0297_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
691{ 691{
692 struct stv0297_state *state = (struct stv0297_state *) fe->demodulator_priv; 692 struct stv0297_state *state = fe->demodulator_priv;
693 int reg_00, reg_83; 693 int reg_00, reg_83;
694 694
695 reg_00 = stv0297_readreg(state, 0x00); 695 reg_00 = stv0297_readreg(state, 0x00);
@@ -725,7 +725,7 @@ static int stv0297_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
725 725
726static void stv0297_release(struct dvb_frontend *fe) 726static void stv0297_release(struct dvb_frontend *fe)
727{ 727{
728 struct stv0297_state *state = (struct stv0297_state *) fe->demodulator_priv; 728 struct stv0297_state *state = fe->demodulator_priv;
729 kfree(state); 729 kfree(state);
730} 730}
731 731
@@ -737,7 +737,7 @@ struct dvb_frontend *stv0297_attach(const struct stv0297_config *config,
737 struct stv0297_state *state = NULL; 737 struct stv0297_state *state = NULL;
738 738
739 /* allocate memory for the internal state */ 739 /* allocate memory for the internal state */
740 state = (struct stv0297_state *) kmalloc(sizeof(struct stv0297_state), GFP_KERNEL); 740 state = kmalloc(sizeof(struct stv0297_state), GFP_KERNEL);
741 if (state == NULL) 741 if (state == NULL)
742 goto error; 742 goto error;
743 743
diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c
index 15b40541b62d..cfa3928bb487 100644
--- a/drivers/media/dvb/frontends/stv0299.c
+++ b/drivers/media/dvb/frontends/stv0299.c
@@ -70,6 +70,7 @@ struct stv0299_state {
70#define STATUS_UCBLOCKS 1 70#define STATUS_UCBLOCKS 1
71 71
72static int debug; 72static int debug;
73static int debug_legacy_dish_switch;
73#define dprintk(args...) \ 74#define dprintk(args...) \
74 do { \ 75 do { \
75 if (debug) printk(KERN_DEBUG "stv0299: " args); \ 76 if (debug) printk(KERN_DEBUG "stv0299: " args); \
@@ -93,7 +94,7 @@ static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data)
93 94
94int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data) 95int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data)
95{ 96{
96 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 97 struct stv0299_state* state = fe->demodulator_priv;
97 98
98 return stv0299_writeregI(state, reg, data); 99 return stv0299_writeregI(state, reg, data);
99} 100}
@@ -218,7 +219,7 @@ static int stv0299_wait_diseqc_idle (struct stv0299_state* state, int timeout)
218 219
219static int stv0299_set_symbolrate (struct dvb_frontend* fe, u32 srate) 220static int stv0299_set_symbolrate (struct dvb_frontend* fe, u32 srate)
220{ 221{
221 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 222 struct stv0299_state* state = fe->demodulator_priv;
222 u64 big = srate; 223 u64 big = srate;
223 u32 ratio; 224 u32 ratio;
224 225
@@ -269,7 +270,7 @@ static int stv0299_get_symbolrate (struct stv0299_state* state)
269static int stv0299_send_diseqc_msg (struct dvb_frontend* fe, 270static int stv0299_send_diseqc_msg (struct dvb_frontend* fe,
270 struct dvb_diseqc_master_cmd *m) 271 struct dvb_diseqc_master_cmd *m)
271{ 272{
272 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 273 struct stv0299_state* state = fe->demodulator_priv;
273 u8 val; 274 u8 val;
274 int i; 275 int i;
275 276
@@ -299,7 +300,7 @@ static int stv0299_send_diseqc_msg (struct dvb_frontend* fe,
299 300
300static int stv0299_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) 301static int stv0299_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
301{ 302{
302 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 303 struct stv0299_state* state = fe->demodulator_priv;
303 u8 val; 304 u8 val;
304 305
305 dprintk ("%s\n", __FUNCTION__); 306 dprintk ("%s\n", __FUNCTION__);
@@ -326,7 +327,7 @@ static int stv0299_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t
326 327
327static int stv0299_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 328static int stv0299_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
328{ 329{
329 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 330 struct stv0299_state* state = fe->demodulator_priv;
330 u8 val; 331 u8 val;
331 332
332 if (stv0299_wait_diseqc_idle (state, 100) < 0) 333 if (stv0299_wait_diseqc_idle (state, 100) < 0)
@@ -348,7 +349,7 @@ static int stv0299_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
348 349
349static int stv0299_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage) 350static int stv0299_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
350{ 351{
351 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 352 struct stv0299_state* state = fe->demodulator_priv;
352 u8 reg0x08; 353 u8 reg0x08;
353 u8 reg0x0c; 354 u8 reg0x0c;
354 355
@@ -385,34 +386,84 @@ static int stv0299_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag
385 }; 386 };
386} 387}
387 388
388static int stv0299_send_legacy_dish_cmd(struct dvb_frontend* fe, u32 cmd) 389static inline s32 stv0299_calc_usec_delay (struct timeval lasttime, struct timeval curtime)
389{ 390{
391 return ((curtime.tv_usec < lasttime.tv_usec) ?
392 1000000 - lasttime.tv_usec + curtime.tv_usec :
393 curtime.tv_usec - lasttime.tv_usec);
394}
395
396static void stv0299_sleep_until (struct timeval *waketime, u32 add_usec)
397{
398 struct timeval lasttime;
399 s32 delta, newdelta;
400
401 waketime->tv_usec += add_usec;
402 if (waketime->tv_usec >= 1000000) {
403 waketime->tv_usec -= 1000000;
404 waketime->tv_sec++;
405 }
406
407 do_gettimeofday (&lasttime);
408 delta = stv0299_calc_usec_delay (lasttime, *waketime);
409 if (delta > 2500) {
410 msleep ((delta - 1500) / 1000);
411 do_gettimeofday (&lasttime);
412 newdelta = stv0299_calc_usec_delay (lasttime, *waketime);
413 delta = (newdelta > delta) ? 0 : newdelta;
414 }
415 if (delta > 0)
416 udelay (delta);
417}
418
419static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, u32 cmd)
420{
421 struct stv0299_state* state = fe->demodulator_priv;
422 u8 reg0x08;
423 u8 reg0x0c;
424 u8 lv_mask = 0x40;
390 u8 last = 1; 425 u8 last = 1;
391 int i; 426 int i;
427 struct timeval nexttime;
428 struct timeval tv[10];
392 429
393 /* reset voltage at the end 430 reg0x08 = stv0299_readreg (state, 0x08);
394 if((0x50 & stv0299_readreg (i2c, 0x0c)) == 0x50) 431 reg0x0c = stv0299_readreg (state, 0x0c);
395 cmd |= 0x80; 432 reg0x0c &= 0x0f;
396 else 433 stv0299_writeregI (state, 0x08, (reg0x08 & 0x3f) | (state->config->lock_output << 6));
397 cmd &= 0x7F; 434 if (state->config->volt13_op0_op1 == STV0299_VOLT13_OP0)
398 */ 435 lv_mask = 0x10;
399 436
400 cmd = cmd << 1; 437 cmd = cmd << 1;
401 dprintk("%s switch command: 0x%04x\n",__FUNCTION__, cmd); 438 if (debug_legacy_dish_switch)
439 printk ("%s switch command: 0x%04x\n",__FUNCTION__, cmd);
440
441 do_gettimeofday (&nexttime);
442 if (debug_legacy_dish_switch)
443 memcpy (&tv[0], &nexttime, sizeof (struct timeval));
444 stv0299_writeregI (state, 0x0c, reg0x0c | 0x50); /* set LNB to 18V */
402 445
403 stv0299_set_voltage(fe,SEC_VOLTAGE_18); 446 stv0299_sleep_until (&nexttime, 32000);
404 msleep(32);
405 447
406 for (i=0; i<9; i++) { 448 for (i=0; i<9; i++) {
449 if (debug_legacy_dish_switch)
450 do_gettimeofday (&tv[i+1]);
407 if((cmd & 0x01) != last) { 451 if((cmd & 0x01) != last) {
408 stv0299_set_voltage(fe, last ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18); 452 /* set voltage to (last ? 13V : 18V) */
453 stv0299_writeregI (state, 0x0c, reg0x0c | (last ? lv_mask : 0x50));
409 last = (last) ? 0 : 1; 454 last = (last) ? 0 : 1;
410 } 455 }
411 456
412 cmd = cmd >> 1; 457 cmd = cmd >> 1;
413 458
414 if (i != 8) 459 if (i != 8)
415 msleep(8); 460 stv0299_sleep_until (&nexttime, 8000);
461 }
462 if (debug_legacy_dish_switch) {
463 printk ("%s(%d): switch delay (should be 32k followed by all 8k\n",
464 __FUNCTION__, fe->dvb->num);
465 for (i=1; i < 10; i++)
466 printk ("%d: %d\n", i, stv0299_calc_usec_delay (tv[i-1] , tv[i]));
416 } 467 }
417 468
418 return 0; 469 return 0;
@@ -420,7 +471,7 @@ static int stv0299_send_legacy_dish_cmd(struct dvb_frontend* fe, u32 cmd)
420 471
421static int stv0299_init (struct dvb_frontend* fe) 472static int stv0299_init (struct dvb_frontend* fe)
422{ 473{
423 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 474 struct stv0299_state* state = fe->demodulator_priv;
424 int i; 475 int i;
425 476
426 dprintk("stv0299: init chip\n"); 477 dprintk("stv0299: init chip\n");
@@ -439,7 +490,7 @@ static int stv0299_init (struct dvb_frontend* fe)
439 490
440static int stv0299_read_status(struct dvb_frontend* fe, fe_status_t* status) 491static int stv0299_read_status(struct dvb_frontend* fe, fe_status_t* status)
441{ 492{
442 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 493 struct stv0299_state* state = fe->demodulator_priv;
443 494
444 u8 signal = 0xff - stv0299_readreg (state, 0x18); 495 u8 signal = 0xff - stv0299_readreg (state, 0x18);
445 u8 sync = stv0299_readreg (state, 0x1b); 496 u8 sync = stv0299_readreg (state, 0x1b);
@@ -467,7 +518,7 @@ static int stv0299_read_status(struct dvb_frontend* fe, fe_status_t* status)
467 518
468static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber) 519static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber)
469{ 520{
470 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 521 struct stv0299_state* state = fe->demodulator_priv;
471 522
472 if (state->errmode != STATUS_BER) return 0; 523 if (state->errmode != STATUS_BER) return 0;
473 *ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); 524 *ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e);
@@ -477,7 +528,7 @@ static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber)
477 528
478static int stv0299_read_signal_strength(struct dvb_frontend* fe, u16* strength) 529static int stv0299_read_signal_strength(struct dvb_frontend* fe, u16* strength)
479{ 530{
480 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 531 struct stv0299_state* state = fe->demodulator_priv;
481 532
482 s32 signal = 0xffff - ((stv0299_readreg (state, 0x18) << 8) 533 s32 signal = 0xffff - ((stv0299_readreg (state, 0x18) << 8)
483 | stv0299_readreg (state, 0x19)); 534 | stv0299_readreg (state, 0x19));
@@ -494,7 +545,7 @@ static int stv0299_read_signal_strength(struct dvb_frontend* fe, u16* strength)
494 545
495static int stv0299_read_snr(struct dvb_frontend* fe, u16* snr) 546static int stv0299_read_snr(struct dvb_frontend* fe, u16* snr)
496{ 547{
497 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 548 struct stv0299_state* state = fe->demodulator_priv;
498 549
499 s32 xsnr = 0xffff - ((stv0299_readreg (state, 0x24) << 8) 550 s32 xsnr = 0xffff - ((stv0299_readreg (state, 0x24) << 8)
500 | stv0299_readreg (state, 0x25)); 551 | stv0299_readreg (state, 0x25));
@@ -506,7 +557,7 @@ static int stv0299_read_snr(struct dvb_frontend* fe, u16* snr)
506 557
507static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 558static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
508{ 559{
509 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 560 struct stv0299_state* state = fe->demodulator_priv;
510 561
511 if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0; 562 if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0;
512 else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); 563 else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e);
@@ -516,7 +567,7 @@ static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
516 567
517static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p) 568static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p)
518{ 569{
519 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 570 struct stv0299_state* state = fe->demodulator_priv;
520 int invval = 0; 571 int invval = 0;
521 572
522 dprintk ("%s : FE_SET_FRONTEND\n", __FUNCTION__); 573 dprintk ("%s : FE_SET_FRONTEND\n", __FUNCTION__);
@@ -584,7 +635,7 @@ static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
584 635
585static int stv0299_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p) 636static int stv0299_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p)
586{ 637{
587 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 638 struct stv0299_state* state = fe->demodulator_priv;
588 s32 derot_freq; 639 s32 derot_freq;
589 int invval; 640 int invval;
590 641
@@ -609,7 +660,7 @@ static int stv0299_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
609 660
610static int stv0299_sleep(struct dvb_frontend* fe) 661static int stv0299_sleep(struct dvb_frontend* fe)
611{ 662{
612 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 663 struct stv0299_state* state = fe->demodulator_priv;
613 664
614 stv0299_writeregI(state, 0x02, 0x80); 665 stv0299_writeregI(state, 0x02, 0x80);
615 state->initialised = 0; 666 state->initialised = 0;
@@ -619,7 +670,7 @@ static int stv0299_sleep(struct dvb_frontend* fe)
619 670
620static int stv0299_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) 671static int stv0299_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
621{ 672{
622 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 673 struct stv0299_state* state = fe->demodulator_priv;
623 674
624 fesettings->min_delay_ms = state->config->min_delay_ms; 675 fesettings->min_delay_ms = state->config->min_delay_ms;
625 if (fesettings->parameters.u.qpsk.symbol_rate < 10000000) { 676 if (fesettings->parameters.u.qpsk.symbol_rate < 10000000) {
@@ -634,7 +685,7 @@ static int stv0299_get_tune_settings(struct dvb_frontend* fe, struct dvb_fronten
634 685
635static void stv0299_release(struct dvb_frontend* fe) 686static void stv0299_release(struct dvb_frontend* fe)
636{ 687{
637 struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv; 688 struct stv0299_state* state = fe->demodulator_priv;
638 kfree(state); 689 kfree(state);
639} 690}
640 691
@@ -647,7 +698,7 @@ struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
647 int id; 698 int id;
648 699
649 /* allocate memory for the internal state */ 700 /* allocate memory for the internal state */
650 state = (struct stv0299_state*) kmalloc(sizeof(struct stv0299_state), GFP_KERNEL); 701 state = kmalloc(sizeof(struct stv0299_state), GFP_KERNEL);
651 if (state == NULL) goto error; 702 if (state == NULL) goto error;
652 703
653 /* setup the state */ 704 /* setup the state */
@@ -719,6 +770,9 @@ static struct dvb_frontend_ops stv0299_ops = {
719 .dishnetwork_send_legacy_command = stv0299_send_legacy_dish_cmd, 770 .dishnetwork_send_legacy_command = stv0299_send_legacy_dish_cmd,
720}; 771};
721 772
773module_param(debug_legacy_dish_switch, int, 0444);
774MODULE_PARM_DESC(debug_legacy_dish_switch, "Enable timing analysis for Dish Network legacy switches");
775
722module_param(debug, int, 0644); 776module_param(debug, int, 0644);
723MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); 777MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
724 778
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c
index 4e40d95ee95d..87d5f4d8790f 100644
--- a/drivers/media/dvb/frontends/tda10021.c
+++ b/drivers/media/dvb/frontends/tda10021.c
@@ -205,7 +205,7 @@ static int tda10021_set_symbolrate (struct tda10021_state* state, u32 symbolrate
205 205
206static int tda10021_init (struct dvb_frontend *fe) 206static int tda10021_init (struct dvb_frontend *fe)
207{ 207{
208 struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv; 208 struct tda10021_state* state = fe->demodulator_priv;
209 int i; 209 int i;
210 210
211 dprintk("DVB: TDA10021(%d): init chip\n", fe->adapter->num); 211 dprintk("DVB: TDA10021(%d): init chip\n", fe->adapter->num);
@@ -238,7 +238,7 @@ static int tda10021_init (struct dvb_frontend *fe)
238static int tda10021_set_parameters (struct dvb_frontend *fe, 238static int tda10021_set_parameters (struct dvb_frontend *fe,
239 struct dvb_frontend_parameters *p) 239 struct dvb_frontend_parameters *p)
240{ 240{
241 struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv; 241 struct tda10021_state* state = fe->demodulator_priv;
242 242
243 //table for QAM4-QAM256 ready QAM4 QAM16 QAM32 QAM64 QAM128 QAM256 243 //table for QAM4-QAM256 ready QAM4 QAM16 QAM32 QAM64 QAM128 QAM256
244 //CONF 244 //CONF
@@ -278,7 +278,7 @@ static int tda10021_set_parameters (struct dvb_frontend *fe,
278 278
279static int tda10021_read_status(struct dvb_frontend* fe, fe_status_t* status) 279static int tda10021_read_status(struct dvb_frontend* fe, fe_status_t* status)
280{ 280{
281 struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv; 281 struct tda10021_state* state = fe->demodulator_priv;
282 int sync; 282 int sync;
283 283
284 *status = 0; 284 *status = 0;
@@ -303,7 +303,7 @@ static int tda10021_read_status(struct dvb_frontend* fe, fe_status_t* status)
303 303
304static int tda10021_read_ber(struct dvb_frontend* fe, u32* ber) 304static int tda10021_read_ber(struct dvb_frontend* fe, u32* ber)
305{ 305{
306 struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv; 306 struct tda10021_state* state = fe->demodulator_priv;
307 307
308 u32 _ber = tda10021_readreg(state, 0x14) | 308 u32 _ber = tda10021_readreg(state, 0x14) |
309 (tda10021_readreg(state, 0x15) << 8) | 309 (tda10021_readreg(state, 0x15) << 8) |
@@ -315,7 +315,7 @@ static int tda10021_read_ber(struct dvb_frontend* fe, u32* ber)
315 315
316static int tda10021_read_signal_strength(struct dvb_frontend* fe, u16* strength) 316static int tda10021_read_signal_strength(struct dvb_frontend* fe, u16* strength)
317{ 317{
318 struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv; 318 struct tda10021_state* state = fe->demodulator_priv;
319 319
320 u8 gain = tda10021_readreg(state, 0x17); 320 u8 gain = tda10021_readreg(state, 0x17);
321 *strength = (gain << 8) | gain; 321 *strength = (gain << 8) | gain;
@@ -325,7 +325,7 @@ static int tda10021_read_signal_strength(struct dvb_frontend* fe, u16* strength)
325 325
326static int tda10021_read_snr(struct dvb_frontend* fe, u16* snr) 326static int tda10021_read_snr(struct dvb_frontend* fe, u16* snr)
327{ 327{
328 struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv; 328 struct tda10021_state* state = fe->demodulator_priv;
329 329
330 u8 quality = ~tda10021_readreg(state, 0x18); 330 u8 quality = ~tda10021_readreg(state, 0x18);
331 *snr = (quality << 8) | quality; 331 *snr = (quality << 8) | quality;
@@ -335,7 +335,7 @@ static int tda10021_read_snr(struct dvb_frontend* fe, u16* snr)
335 335
336static int tda10021_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 336static int tda10021_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
337{ 337{
338 struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv; 338 struct tda10021_state* state = fe->demodulator_priv;
339 339
340 *ucblocks = tda10021_readreg (state, 0x13) & 0x7f; 340 *ucblocks = tda10021_readreg (state, 0x13) & 0x7f;
341 if (*ucblocks == 0x7f) 341 if (*ucblocks == 0x7f)
@@ -350,7 +350,7 @@ static int tda10021_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
350 350
351static int tda10021_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 351static int tda10021_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
352{ 352{
353 struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv; 353 struct tda10021_state* state = fe->demodulator_priv;
354 int sync; 354 int sync;
355 s8 afc = 0; 355 s8 afc = 0;
356 356
@@ -378,7 +378,7 @@ static int tda10021_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_pa
378 378
379static int tda10021_sleep(struct dvb_frontend* fe) 379static int tda10021_sleep(struct dvb_frontend* fe)
380{ 380{
381 struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv; 381 struct tda10021_state* state = fe->demodulator_priv;
382 382
383 tda10021_writereg (state, 0x1b, 0x02); /* pdown ADC */ 383 tda10021_writereg (state, 0x1b, 0x02); /* pdown ADC */
384 tda10021_writereg (state, 0x00, 0x80); /* standby */ 384 tda10021_writereg (state, 0x00, 0x80); /* standby */
@@ -388,7 +388,7 @@ static int tda10021_sleep(struct dvb_frontend* fe)
388 388
389static void tda10021_release(struct dvb_frontend* fe) 389static void tda10021_release(struct dvb_frontend* fe)
390{ 390{
391 struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv; 391 struct tda10021_state* state = fe->demodulator_priv;
392 kfree(state); 392 kfree(state);
393} 393}
394 394
@@ -401,7 +401,7 @@ struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
401 struct tda10021_state* state = NULL; 401 struct tda10021_state* state = NULL;
402 402
403 /* allocate memory for the internal state */ 403 /* allocate memory for the internal state */
404 state = (struct tda10021_state*) kmalloc(sizeof(struct tda10021_state), GFP_KERNEL); 404 state = kmalloc(sizeof(struct tda10021_state), GFP_KERNEL);
405 if (state == NULL) goto error; 405 if (state == NULL) goto error;
406 406
407 /* setup the state */ 407 /* setup the state */
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
index 687ad9cf3384..0beb370792ae 100644
--- a/drivers/media/dvb/frontends/tda1004x.c
+++ b/drivers/media/dvb/frontends/tda1004x.c
@@ -35,9 +35,10 @@
35#include "dvb_frontend.h" 35#include "dvb_frontend.h"
36#include "tda1004x.h" 36#include "tda1004x.h"
37 37
38#define TDA1004X_DEMOD_TDA10045 0 38enum tda1004x_demod {
39#define TDA1004X_DEMOD_TDA10046 1 39 TDA1004X_DEMOD_TDA10045,
40 40 TDA1004X_DEMOD_TDA10046,
41};
41 42
42struct tda1004x_state { 43struct tda1004x_state {
43 struct i2c_adapter* i2c; 44 struct i2c_adapter* i2c;
@@ -46,8 +47,9 @@ struct tda1004x_state {
46 struct dvb_frontend frontend; 47 struct dvb_frontend frontend;
47 48
48 /* private demod data */ 49 /* private demod data */
49 u8 initialised:1; 50 u8 initialised;
50 u8 demod_type; 51 enum tda1004x_demod demod_type;
52 u8 fw_version;
51}; 53};
52 54
53 55
@@ -139,7 +141,7 @@ static int tda1004x_write_byteI(struct tda1004x_state *state, int reg, int data)
139{ 141{
140 int ret; 142 int ret;
141 u8 buf[] = { reg, data }; 143 u8 buf[] = { reg, data };
142 struct i2c_msg msg = { .addr=0, .flags=0, .buf=buf, .len=2 }; 144 struct i2c_msg msg = { .flags = 0, .buf = buf, .len = 2 };
143 145
144 dprintk("%s: reg=0x%x, data=0x%x\n", __FUNCTION__, reg, data); 146 dprintk("%s: reg=0x%x, data=0x%x\n", __FUNCTION__, reg, data);
145 147
@@ -160,8 +162,8 @@ static int tda1004x_read_byte(struct tda1004x_state *state, int reg)
160 int ret; 162 int ret;
161 u8 b0[] = { reg }; 163 u8 b0[] = { reg };
162 u8 b1[] = { 0 }; 164 u8 b1[] = { 0 };
163 struct i2c_msg msg[] = {{ .addr=0, .flags=0, .buf=b0, .len=1}, 165 struct i2c_msg msg[] = {{ .flags = 0, .buf = b0, .len = 1 },
164 { .addr=0, .flags=I2C_M_RD, .buf=b1, .len = 1}}; 166 { .flags = I2C_M_RD, .buf = b1, .len = 1 }};
165 167
166 dprintk("%s: reg=0x%x\n", __FUNCTION__, reg); 168 dprintk("%s: reg=0x%x\n", __FUNCTION__, reg);
167 169
@@ -294,7 +296,7 @@ static int tda1004x_do_upload(struct tda1004x_state *state,
294 u8 dspCodeCounterReg, u8 dspCodeInReg) 296 u8 dspCodeCounterReg, u8 dspCodeInReg)
295{ 297{
296 u8 buf[65]; 298 u8 buf[65];
297 struct i2c_msg fw_msg = {.addr = 0,.flags = 0,.buf = buf,.len = 0 }; 299 struct i2c_msg fw_msg = { .flags = 0, .buf = buf, .len = 0 };
298 int tx_size; 300 int tx_size;
299 int pos = 0; 301 int pos = 0;
300 302
@@ -304,12 +306,10 @@ static int tda1004x_do_upload(struct tda1004x_state *state,
304 306
305 buf[0] = dspCodeInReg; 307 buf[0] = dspCodeInReg;
306 while (pos != len) { 308 while (pos != len) {
307
308 // work out how much to send this time 309 // work out how much to send this time
309 tx_size = len - pos; 310 tx_size = len - pos;
310 if (tx_size > 0x10) { 311 if (tx_size > 0x10)
311 tx_size = 0x10; 312 tx_size = 0x10;
312 }
313 313
314 // send the chunk 314 // send the chunk
315 memcpy(buf + 1, mem + pos, tx_size); 315 memcpy(buf + 1, mem + pos, tx_size);
@@ -322,6 +322,7 @@ static int tda1004x_do_upload(struct tda1004x_state *state,
322 322
323 dprintk("%s: fw_pos=0x%x\n", __FUNCTION__, pos); 323 dprintk("%s: fw_pos=0x%x\n", __FUNCTION__, pos);
324 } 324 }
325
325 return 0; 326 return 0;
326} 327}
327 328
@@ -335,9 +336,8 @@ static int tda1004x_check_upload_ok(struct tda1004x_state *state, u8 dspVersion)
335 336
336 data1 = tda1004x_read_byte(state, TDA1004X_DSP_DATA1); 337 data1 = tda1004x_read_byte(state, TDA1004X_DSP_DATA1);
337 data2 = tda1004x_read_byte(state, TDA1004X_DSP_DATA2); 338 data2 = tda1004x_read_byte(state, TDA1004X_DSP_DATA2);
338 if (data1 != 0x67 || data2 != dspVersion) { 339 if ((data1 != 0x67) || (data2 != dspVersion))
339 return -EIO; 340 return -EIO;
340 }
341 341
342 return 0; 342 return 0;
343} 343}
@@ -348,9 +348,9 @@ static int tda10045_fwupload(struct dvb_frontend* fe)
348 int ret; 348 int ret;
349 const struct firmware *fw; 349 const struct firmware *fw;
350 350
351
352 /* don't re-upload unless necessary */ 351 /* don't re-upload unless necessary */
353 if (tda1004x_check_upload_ok(state, 0x2c) == 0) return 0; 352 if (tda1004x_check_upload_ok(state, 0x2c) == 0)
353 return 0;
354 354
355 /* request the firmware, this will block until someone uploads it */ 355 /* request the firmware, this will block until someone uploads it */
356 printk("tda1004x: waiting for firmware upload (%s)...\n", TDA10045_DEFAULT_FIRMWARE); 356 printk("tda1004x: waiting for firmware upload (%s)...\n", TDA10045_DEFAULT_FIRMWARE);
@@ -381,6 +381,25 @@ static int tda10045_fwupload(struct dvb_frontend* fe)
381 return tda1004x_check_upload_ok(state, 0x2c); 381 return tda1004x_check_upload_ok(state, 0x2c);
382} 382}
383 383
384static int tda10046_get_fw_version(struct tda1004x_state *state,
385 const struct firmware *fw)
386{
387 const unsigned char pattern[] = { 0x67, 0x00, 0x50, 0x62, 0x5e, 0x18, 0x67 };
388 unsigned int i;
389
390 /* area guessed from firmware v20, v21 and v25 */
391 for (i = 0x660; i < 0x700; i++) {
392 if (!memcmp(&fw->data[i], pattern, sizeof(pattern))) {
393 state->fw_version = fw->data[i + sizeof(pattern)];
394 printk(KERN_INFO "tda1004x: using firmware v%02x\n",
395 state->fw_version);
396 return 0;
397 }
398 }
399
400 return -EINVAL;
401}
402
384static int tda10046_fwupload(struct dvb_frontend* fe) 403static int tda10046_fwupload(struct dvb_frontend* fe)
385{ 404{
386 struct tda1004x_state* state = fe->demodulator_priv; 405 struct tda1004x_state* state = fe->demodulator_priv;
@@ -394,7 +413,8 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
394 msleep(100); 413 msleep(100);
395 414
396 /* don't re-upload unless necessary */ 415 /* don't re-upload unless necessary */
397 if (tda1004x_check_upload_ok(state, 0x20) == 0) return 0; 416 if (tda1004x_check_upload_ok(state, state->fw_version) == 0)
417 return 0;
398 418
399 /* request the firmware, this will block until someone uploads it */ 419 /* request the firmware, this will block until someone uploads it */
400 printk("tda1004x: waiting for firmware upload (%s)...\n", TDA10046_DEFAULT_FIRMWARE); 420 printk("tda1004x: waiting for firmware upload (%s)...\n", TDA10046_DEFAULT_FIRMWARE);
@@ -404,9 +424,20 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
404 return ret; 424 return ret;
405 } 425 }
406 426
427 if (fw->size < 24478) { /* size of firmware v20, which is the smallest of v20, v21 and v25 */
428 printk("tda1004x: firmware file seems to be too small (%d bytes)\n", fw->size);
429 return -EINVAL;
430 }
431
432 ret = tda10046_get_fw_version(state, fw);
433 if (ret < 0) {
434 printk("tda1004x: unable to find firmware version\n");
435 return ret;
436 }
437
407 /* set parameters */ 438 /* set parameters */
408 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10); 439 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10);
409 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0); 440 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, state->config->n_i2c);
410 tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99); 441 tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99);
411 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4); 442 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4);
412 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c); 443 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c);
@@ -419,7 +450,7 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
419 450
420 /* wait for DSP to initialise */ 451 /* wait for DSP to initialise */
421 timeout = jiffies + HZ; 452 timeout = jiffies + HZ;
422 while(!(tda1004x_read_byte(state, TDA1004X_STATUS_CD) & 0x20)) { 453 while (!(tda1004x_read_byte(state, TDA1004X_STATUS_CD) & 0x20)) {
423 if (time_after(jiffies, timeout)) { 454 if (time_after(jiffies, timeout)) {
424 printk("tda1004x: DSP failed to initialised.\n"); 455 printk("tda1004x: DSP failed to initialised.\n");
425 return -EIO; 456 return -EIO;
@@ -427,7 +458,7 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
427 msleep(1); 458 msleep(1);
428 } 459 }
429 460
430 return tda1004x_check_upload_ok(state, 0x20); 461 return tda1004x_check_upload_ok(state, state->fw_version);
431} 462}
432 463
433static int tda1004x_encode_fec(int fec) 464static int tda1004x_encode_fec(int fec)
@@ -483,7 +514,8 @@ static int tda10045_init(struct dvb_frontend* fe)
483 514
484 dprintk("%s\n", __FUNCTION__); 515 dprintk("%s\n", __FUNCTION__);
485 516
486 if (state->initialised) return 0; 517 if (state->initialised)
518 return 0;
487 519
488 if (tda10045_fwupload(fe)) { 520 if (tda10045_fwupload(fe)) {
489 printk("tda1004x: firmware upload failed\n"); 521 printk("tda1004x: firmware upload failed\n");
@@ -523,7 +555,8 @@ static int tda10046_init(struct dvb_frontend* fe)
523 struct tda1004x_state* state = fe->demodulator_priv; 555 struct tda1004x_state* state = fe->demodulator_priv;
524 dprintk("%s\n", __FUNCTION__); 556 dprintk("%s\n", __FUNCTION__);
525 557
526 if (state->initialised) return 0; 558 if (state->initialised)
559 return 0;
527 560
528 if (tda10046_fwupload(fe)) { 561 if (tda10046_fwupload(fe)) {
529 printk("tda1004x: firmware upload failed\n"); 562 printk("tda1004x: firmware upload failed\n");
@@ -545,7 +578,7 @@ static int tda10046_init(struct dvb_frontend* fe)
545 tda1004x_write_mask(state, TDA1004X_AUTO, 8, 0); // select HP stream 578 tda1004x_write_mask(state, TDA1004X_AUTO, 8, 0); // select HP stream
546 tda1004x_write_mask(state, TDA1004X_CONFC1, 0x80, 0); // disable pulse killer 579 tda1004x_write_mask(state, TDA1004X_CONFC1, 0x80, 0); // disable pulse killer
547 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10); // PLL M = 10 580 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10); // PLL M = 10
548 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0); // PLL P = N = 0 581 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, state->config->n_i2c); // PLL P = N = 0
549 tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99); // FREQOFFS = 99 582 tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99); // FREQOFFS = 99
550 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4); // } PHY2 = -11221 583 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4); // } PHY2 = -11221
551 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c); // } 584 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c); // }
@@ -621,12 +654,14 @@ static int tda1004x_set_fe(struct dvb_frontend* fe,
621 654
622 // set HP FEC 655 // set HP FEC
623 tmp = tda1004x_encode_fec(fe_params->u.ofdm.code_rate_HP); 656 tmp = tda1004x_encode_fec(fe_params->u.ofdm.code_rate_HP);
624 if (tmp < 0) return tmp; 657 if (tmp < 0)
658 return tmp;
625 tda1004x_write_mask(state, TDA1004X_IN_CONF2, 7, tmp); 659 tda1004x_write_mask(state, TDA1004X_IN_CONF2, 7, tmp);
626 660
627 // set LP FEC 661 // set LP FEC
628 tmp = tda1004x_encode_fec(fe_params->u.ofdm.code_rate_LP); 662 tmp = tda1004x_encode_fec(fe_params->u.ofdm.code_rate_LP);
629 if (tmp < 0) return tmp; 663 if (tmp < 0)
664 return tmp;
630 tda1004x_write_mask(state, TDA1004X_IN_CONF2, 0x38, tmp << 3); 665 tda1004x_write_mask(state, TDA1004X_IN_CONF2, 0x38, tmp << 3);
631 666
632 // set constellation 667 // set constellation
@@ -671,7 +706,7 @@ static int tda1004x_set_fe(struct dvb_frontend* fe,
671 } 706 }
672 707
673 // set bandwidth 708 // set bandwidth
674 switch(state->demod_type) { 709 switch (state->demod_type) {
675 case TDA1004X_DEMOD_TDA10045: 710 case TDA1004X_DEMOD_TDA10045:
676 tda10045h_set_bandwidth(state, fe_params->u.ofdm.bandwidth); 711 tda10045h_set_bandwidth(state, fe_params->u.ofdm.bandwidth);
677 break; 712 break;
@@ -683,7 +718,8 @@ static int tda1004x_set_fe(struct dvb_frontend* fe,
683 718
684 // set inversion 719 // set inversion
685 inversion = fe_params->inversion; 720 inversion = fe_params->inversion;
686 if (state->config->invert) inversion = inversion ? INVERSION_OFF : INVERSION_ON; 721 if (state->config->invert)
722 inversion = inversion ? INVERSION_OFF : INVERSION_ON;
687 switch (inversion) { 723 switch (inversion) {
688 case INVERSION_OFF: 724 case INVERSION_OFF:
689 tda1004x_write_mask(state, TDA1004X_CONFC1, 0x20, 0); 725 tda1004x_write_mask(state, TDA1004X_CONFC1, 0x20, 0);
@@ -750,19 +786,19 @@ static int tda1004x_set_fe(struct dvb_frontend* fe,
750 } 786 }
751 787
752 // start the lock 788 // start the lock
753 switch(state->demod_type) { 789 switch (state->demod_type) {
754 case TDA1004X_DEMOD_TDA10045: 790 case TDA1004X_DEMOD_TDA10045:
755 tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8); 791 tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8);
756 tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 0); 792 tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 0);
757 msleep(10);
758 break; 793 break;
759 794
760 case TDA1004X_DEMOD_TDA10046: 795 case TDA1004X_DEMOD_TDA10046:
761 tda1004x_write_mask(state, TDA1004X_AUTO, 0x40, 0x40); 796 tda1004x_write_mask(state, TDA1004X_AUTO, 0x40, 0x40);
762 msleep(10);
763 break; 797 break;
764 } 798 }
765 799
800 msleep(10);
801
766 return 0; 802 return 0;
767} 803}
768 804
@@ -773,13 +809,13 @@ static int tda1004x_get_fe(struct dvb_frontend* fe, struct dvb_frontend_paramete
773 809
774 // inversion status 810 // inversion status
775 fe_params->inversion = INVERSION_OFF; 811 fe_params->inversion = INVERSION_OFF;
776 if (tda1004x_read_byte(state, TDA1004X_CONFC1) & 0x20) { 812 if (tda1004x_read_byte(state, TDA1004X_CONFC1) & 0x20)
777 fe_params->inversion = INVERSION_ON; 813 fe_params->inversion = INVERSION_ON;
778 } 814 if (state->config->invert)
779 if (state->config->invert) fe_params->inversion = fe_params->inversion ? INVERSION_OFF : INVERSION_ON; 815 fe_params->inversion = fe_params->inversion ? INVERSION_OFF : INVERSION_ON;
780 816
781 // bandwidth 817 // bandwidth
782 switch(state->demod_type) { 818 switch (state->demod_type) {
783 case TDA1004X_DEMOD_TDA10045: 819 case TDA1004X_DEMOD_TDA10045:
784 switch (tda1004x_read_byte(state, TDA10045H_WREF_LSB)) { 820 switch (tda1004x_read_byte(state, TDA10045H_WREF_LSB)) {
785 case 0x14: 821 case 0x14:
@@ -830,9 +866,8 @@ static int tda1004x_get_fe(struct dvb_frontend* fe, struct dvb_frontend_paramete
830 866
831 // transmission mode 867 // transmission mode
832 fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_2K; 868 fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
833 if (tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 0x10) { 869 if (tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 0x10)
834 fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_8K; 870 fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_8K;
835 }
836 871
837 // guard interval 872 // guard interval
838 switch ((tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 0x0c) >> 2) { 873 switch ((tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 0x0c) >> 2) {
@@ -880,30 +915,33 @@ static int tda1004x_read_status(struct dvb_frontend* fe, fe_status_t * fe_status
880 915
881 // read status 916 // read status
882 status = tda1004x_read_byte(state, TDA1004X_STATUS_CD); 917 status = tda1004x_read_byte(state, TDA1004X_STATUS_CD);
883 if (status == -1) { 918 if (status == -1)
884 return -EIO; 919 return -EIO;
885 }
886 920
887 // decode 921 // decode
888 *fe_status = 0; 922 *fe_status = 0;
889 if (status & 4) *fe_status |= FE_HAS_SIGNAL; 923 if (status & 4)
890 if (status & 2) *fe_status |= FE_HAS_CARRIER; 924 *fe_status |= FE_HAS_SIGNAL;
891 if (status & 8) *fe_status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; 925 if (status & 2)
926 *fe_status |= FE_HAS_CARRIER;
927 if (status & 8)
928 *fe_status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
892 929
893 // if we don't already have VITERBI (i.e. not LOCKED), see if the viterbi 930 // if we don't already have VITERBI (i.e. not LOCKED), see if the viterbi
894 // is getting anything valid 931 // is getting anything valid
895 if (!(*fe_status & FE_HAS_VITERBI)) { 932 if (!(*fe_status & FE_HAS_VITERBI)) {
896 // read the CBER 933 // read the CBER
897 cber = tda1004x_read_byte(state, TDA1004X_CBER_LSB); 934 cber = tda1004x_read_byte(state, TDA1004X_CBER_LSB);
898 if (cber == -1) return -EIO; 935 if (cber == -1)
936 return -EIO;
899 status = tda1004x_read_byte(state, TDA1004X_CBER_MSB); 937 status = tda1004x_read_byte(state, TDA1004X_CBER_MSB);
900 if (status == -1) return -EIO; 938 if (status == -1)
939 return -EIO;
901 cber |= (status << 8); 940 cber |= (status << 8);
902 tda1004x_read_byte(state, TDA1004X_CBER_RESET); 941 tda1004x_read_byte(state, TDA1004X_CBER_RESET);
903 942
904 if (cber != 65535) { 943 if (cber != 65535)
905 *fe_status |= FE_HAS_VITERBI; 944 *fe_status |= FE_HAS_VITERBI;
906 }
907 } 945 }
908 946
909 // if we DO have some valid VITERBI output, but don't already have SYNC 947 // if we DO have some valid VITERBI output, but don't already have SYNC
@@ -911,20 +949,22 @@ static int tda1004x_read_status(struct dvb_frontend* fe, fe_status_t * fe_status
911 if ((*fe_status & FE_HAS_VITERBI) && (!(*fe_status & FE_HAS_SYNC))) { 949 if ((*fe_status & FE_HAS_VITERBI) && (!(*fe_status & FE_HAS_SYNC))) {
912 // read the VBER 950 // read the VBER
913 vber = tda1004x_read_byte(state, TDA1004X_VBER_LSB); 951 vber = tda1004x_read_byte(state, TDA1004X_VBER_LSB);
914 if (vber == -1) return -EIO; 952 if (vber == -1)
953 return -EIO;
915 status = tda1004x_read_byte(state, TDA1004X_VBER_MID); 954 status = tda1004x_read_byte(state, TDA1004X_VBER_MID);
916 if (status == -1) return -EIO; 955 if (status == -1)
956 return -EIO;
917 vber |= (status << 8); 957 vber |= (status << 8);
918 status = tda1004x_read_byte(state, TDA1004X_VBER_MSB); 958 status = tda1004x_read_byte(state, TDA1004X_VBER_MSB);
919 if (status == -1) return -EIO; 959 if (status == -1)
960 return -EIO;
920 vber |= ((status << 16) & 0x0f); 961 vber |= ((status << 16) & 0x0f);
921 tda1004x_read_byte(state, TDA1004X_CVBER_LUT); 962 tda1004x_read_byte(state, TDA1004X_CVBER_LUT);
922 963
923 // if RS has passed some valid TS packets, then we must be 964 // if RS has passed some valid TS packets, then we must be
924 // getting some SYNC bytes 965 // getting some SYNC bytes
925 if (vber < 16632) { 966 if (vber < 16632)
926 *fe_status |= FE_HAS_SYNC; 967 *fe_status |= FE_HAS_SYNC;
927 }
928 } 968 }
929 969
930 // success 970 // success
@@ -941,7 +981,7 @@ static int tda1004x_read_signal_strength(struct dvb_frontend* fe, u16 * signal)
941 dprintk("%s\n", __FUNCTION__); 981 dprintk("%s\n", __FUNCTION__);
942 982
943 // determine the register to use 983 // determine the register to use
944 switch(state->demod_type) { 984 switch (state->demod_type) {
945 case TDA1004X_DEMOD_TDA10045: 985 case TDA1004X_DEMOD_TDA10045:
946 reg = TDA10045H_S_AGC; 986 reg = TDA10045H_S_AGC;
947 break; 987 break;
@@ -972,9 +1012,8 @@ static int tda1004x_read_snr(struct dvb_frontend* fe, u16 * snr)
972 tmp = tda1004x_read_byte(state, TDA1004X_SNR); 1012 tmp = tda1004x_read_byte(state, TDA1004X_SNR);
973 if (tmp < 0) 1013 if (tmp < 0)
974 return -EIO; 1014 return -EIO;
975 if (tmp) { 1015 if (tmp)
976 tmp = 255 - tmp; 1016 tmp = 255 - tmp;
977 }
978 1017
979 *snr = ((tmp << 8) | tmp); 1018 *snr = ((tmp << 8) | tmp);
980 dprintk("%s: snr=0x%x\n", __FUNCTION__, *snr); 1019 dprintk("%s: snr=0x%x\n", __FUNCTION__, *snr);
@@ -1009,11 +1048,11 @@ static int tda1004x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
1009 break; 1048 break;
1010 } 1049 }
1011 1050
1012 if (tmp != 0x7f) { 1051 if (tmp != 0x7f)
1013 *ucblocks = tmp; 1052 *ucblocks = tmp;
1014 } else { 1053 else
1015 *ucblocks = 0xffffffff; 1054 *ucblocks = 0xffffffff;
1016 } 1055
1017 dprintk("%s: ucblocks=0x%x\n", __FUNCTION__, *ucblocks); 1056 dprintk("%s: ucblocks=0x%x\n", __FUNCTION__, *ucblocks);
1018 return 0; 1057 return 0;
1019} 1058}
@@ -1027,10 +1066,12 @@ static int tda1004x_read_ber(struct dvb_frontend* fe, u32* ber)
1027 1066
1028 // read it in 1067 // read it in
1029 tmp = tda1004x_read_byte(state, TDA1004X_CBER_LSB); 1068 tmp = tda1004x_read_byte(state, TDA1004X_CBER_LSB);
1030 if (tmp < 0) return -EIO; 1069 if (tmp < 0)
1070 return -EIO;
1031 *ber = tmp << 1; 1071 *ber = tmp << 1;
1032 tmp = tda1004x_read_byte(state, TDA1004X_CBER_MSB); 1072 tmp = tda1004x_read_byte(state, TDA1004X_CBER_MSB);
1033 if (tmp < 0) return -EIO; 1073 if (tmp < 0)
1074 return -EIO;
1034 *ber |= (tmp << 9); 1075 *ber |= (tmp << 9);
1035 tda1004x_read_byte(state, TDA1004X_CBER_RESET); 1076 tda1004x_read_byte(state, TDA1004X_CBER_RESET);
1036 1077
@@ -1042,7 +1083,7 @@ static int tda1004x_sleep(struct dvb_frontend* fe)
1042{ 1083{
1043 struct tda1004x_state* state = fe->demodulator_priv; 1084 struct tda1004x_state* state = fe->demodulator_priv;
1044 1085
1045 switch(state->demod_type) { 1086 switch (state->demod_type) {
1046 case TDA1004X_DEMOD_TDA10045: 1087 case TDA1004X_DEMOD_TDA10045:
1047 tda1004x_write_mask(state, TDA1004X_CONFADC1, 0x10, 0x10); 1088 tda1004x_write_mask(state, TDA1004X_CONFADC1, 0x10, 0x10);
1048 break; 1089 break;
@@ -1066,74 +1107,11 @@ static int tda1004x_get_tune_settings(struct dvb_frontend* fe, struct dvb_fronte
1066 1107
1067static void tda1004x_release(struct dvb_frontend* fe) 1108static void tda1004x_release(struct dvb_frontend* fe)
1068{ 1109{
1069 struct tda1004x_state* state = (struct tda1004x_state*) fe->demodulator_priv; 1110 struct tda1004x_state *state = fe->demodulator_priv;
1070 kfree(state);
1071}
1072
1073static struct dvb_frontend_ops tda10045_ops;
1074
1075struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
1076 struct i2c_adapter* i2c)
1077{
1078 struct tda1004x_state* state = NULL;
1079
1080 /* allocate memory for the internal state */
1081 state = (struct tda1004x_state*) kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL);
1082 if (state == NULL) goto error;
1083
1084 /* setup the state */
1085 state->config = config;
1086 state->i2c = i2c;
1087 memcpy(&state->ops, &tda10045_ops, sizeof(struct dvb_frontend_ops));
1088 state->initialised = 0;
1089 state->demod_type = TDA1004X_DEMOD_TDA10045;
1090
1091 /* check if the demod is there */
1092 if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x25) goto error;
1093
1094 /* create dvb_frontend */
1095 state->frontend.ops = &state->ops;
1096 state->frontend.demodulator_priv = state;
1097 return &state->frontend;
1098
1099error:
1100 kfree(state); 1111 kfree(state);
1101 return NULL;
1102}
1103
1104static struct dvb_frontend_ops tda10046_ops;
1105
1106struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
1107 struct i2c_adapter* i2c)
1108{
1109 struct tda1004x_state* state = NULL;
1110
1111 /* allocate memory for the internal state */
1112 state = (struct tda1004x_state*) kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL);
1113 if (state == NULL) goto error;
1114
1115 /* setup the state */
1116 state->config = config;
1117 state->i2c = i2c;
1118 memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops));
1119 state->initialised = 0;
1120 state->demod_type = TDA1004X_DEMOD_TDA10046;
1121
1122 /* check if the demod is there */
1123 if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x46) goto error;
1124
1125 /* create dvb_frontend */
1126 state->frontend.ops = &state->ops;
1127 state->frontend.demodulator_priv = state;
1128 return &state->frontend;
1129
1130error:
1131 if (state) kfree(state);
1132 return NULL;
1133} 1112}
1134 1113
1135static struct dvb_frontend_ops tda10045_ops = { 1114static struct dvb_frontend_ops tda10045_ops = {
1136
1137 .info = { 1115 .info = {
1138 .name = "Philips TDA10045H DVB-T", 1116 .name = "Philips TDA10045H DVB-T",
1139 .type = FE_OFDM, 1117 .type = FE_OFDM,
@@ -1163,8 +1141,36 @@ static struct dvb_frontend_ops tda10045_ops = {
1163 .read_ucblocks = tda1004x_read_ucblocks, 1141 .read_ucblocks = tda1004x_read_ucblocks,
1164}; 1142};
1165 1143
1166static struct dvb_frontend_ops tda10046_ops = { 1144struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
1145 struct i2c_adapter* i2c)
1146{
1147 struct tda1004x_state *state;
1148
1149 /* allocate memory for the internal state */
1150 state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL);
1151 if (!state)
1152 return NULL;
1153
1154 /* setup the state */
1155 state->config = config;
1156 state->i2c = i2c;
1157 memcpy(&state->ops, &tda10045_ops, sizeof(struct dvb_frontend_ops));
1158 state->initialised = 0;
1159 state->demod_type = TDA1004X_DEMOD_TDA10045;
1160
1161 /* check if the demod is there */
1162 if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x25) {
1163 kfree(state);
1164 return NULL;
1165 }
1167 1166
1167 /* create dvb_frontend */
1168 state->frontend.ops = &state->ops;
1169 state->frontend.demodulator_priv = state;
1170 return &state->frontend;
1171}
1172
1173static struct dvb_frontend_ops tda10046_ops = {
1168 .info = { 1174 .info = {
1169 .name = "Philips TDA10046H DVB-T", 1175 .name = "Philips TDA10046H DVB-T",
1170 .type = FE_OFDM, 1176 .type = FE_OFDM,
@@ -1194,6 +1200,36 @@ static struct dvb_frontend_ops tda10046_ops = {
1194 .read_ucblocks = tda1004x_read_ucblocks, 1200 .read_ucblocks = tda1004x_read_ucblocks,
1195}; 1201};
1196 1202
1203struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
1204 struct i2c_adapter* i2c)
1205{
1206 struct tda1004x_state *state;
1207
1208 /* allocate memory for the internal state */
1209 state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL);
1210 if (!state)
1211 return NULL;
1212
1213 /* setup the state */
1214 state->config = config;
1215 state->i2c = i2c;
1216 memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops));
1217 state->initialised = 0;
1218 state->demod_type = TDA1004X_DEMOD_TDA10046;
1219 state->fw_version = 0x20; /* dummy default value */
1220
1221 /* check if the demod is there */
1222 if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x46) {
1223 kfree(state);
1224 return NULL;
1225 }
1226
1227 /* create dvb_frontend */
1228 state->frontend.ops = &state->ops;
1229 state->frontend.demodulator_priv = state;
1230 return &state->frontend;
1231}
1232
1197module_param(debug, int, 0644); 1233module_param(debug, int, 0644);
1198MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); 1234MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
1199 1235
diff --git a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h
index e452fc0bad11..c8e1d54ff262 100644
--- a/drivers/media/dvb/frontends/tda1004x.h
+++ b/drivers/media/dvb/frontends/tda1004x.h
@@ -32,10 +32,13 @@ struct tda1004x_config
32 u8 demod_address; 32 u8 demod_address;
33 33
34 /* does the "inversion" need inverted? */ 34 /* does the "inversion" need inverted? */
35 u8 invert:1; 35 u8 invert;
36 36
37 /* Does the OCLK signal need inverted? */ 37 /* Does the OCLK signal need inverted? */
38 u8 invert_oclk:1; 38 u8 invert_oclk;
39
40 /* value of N_I2C of the CONF_PLL3 register */
41 u8 n_i2c;
39 42
40 /* PLL maintenance */ 43 /* PLL maintenance */
41 int (*pll_init)(struct dvb_frontend* fe); 44 int (*pll_init)(struct dvb_frontend* fe);
diff --git a/drivers/media/dvb/frontends/tda8083.c b/drivers/media/dvb/frontends/tda8083.c
index da82e90d6d13..168e013d23bd 100644
--- a/drivers/media/dvb/frontends/tda8083.c
+++ b/drivers/media/dvb/frontends/tda8083.c
@@ -226,7 +226,7 @@ static int tda8083_send_diseqc_burst (struct tda8083_state* state, fe_sec_mini_c
226static int tda8083_send_diseqc_msg (struct dvb_frontend* fe, 226static int tda8083_send_diseqc_msg (struct dvb_frontend* fe,
227 struct dvb_diseqc_master_cmd *m) 227 struct dvb_diseqc_master_cmd *m)
228{ 228{
229 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 229 struct tda8083_state* state = fe->demodulator_priv;
230 int i; 230 int i;
231 231
232 tda8083_writereg (state, 0x29, (m->msg_len - 3) | (1 << 2)); /* enable */ 232 tda8083_writereg (state, 0x29, (m->msg_len - 3) | (1 << 2)); /* enable */
@@ -243,7 +243,7 @@ static int tda8083_send_diseqc_msg (struct dvb_frontend* fe,
243 243
244static int tda8083_read_status(struct dvb_frontend* fe, fe_status_t* status) 244static int tda8083_read_status(struct dvb_frontend* fe, fe_status_t* status)
245{ 245{
246 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 246 struct tda8083_state* state = fe->demodulator_priv;
247 247
248 u8 signal = ~tda8083_readreg (state, 0x01); 248 u8 signal = ~tda8083_readreg (state, 0x01);
249 u8 sync = tda8083_readreg (state, 0x02); 249 u8 sync = tda8083_readreg (state, 0x02);
@@ -270,7 +270,7 @@ static int tda8083_read_status(struct dvb_frontend* fe, fe_status_t* status)
270 270
271static int tda8083_read_signal_strength(struct dvb_frontend* fe, u16* strength) 271static int tda8083_read_signal_strength(struct dvb_frontend* fe, u16* strength)
272{ 272{
273 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 273 struct tda8083_state* state = fe->demodulator_priv;
274 274
275 u8 signal = ~tda8083_readreg (state, 0x01); 275 u8 signal = ~tda8083_readreg (state, 0x01);
276 *strength = (signal << 8) | signal; 276 *strength = (signal << 8) | signal;
@@ -280,7 +280,7 @@ static int tda8083_read_signal_strength(struct dvb_frontend* fe, u16* strength)
280 280
281static int tda8083_read_snr(struct dvb_frontend* fe, u16* snr) 281static int tda8083_read_snr(struct dvb_frontend* fe, u16* snr)
282{ 282{
283 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 283 struct tda8083_state* state = fe->demodulator_priv;
284 284
285 u8 _snr = tda8083_readreg (state, 0x08); 285 u8 _snr = tda8083_readreg (state, 0x08);
286 *snr = (_snr << 8) | _snr; 286 *snr = (_snr << 8) | _snr;
@@ -290,7 +290,7 @@ static int tda8083_read_snr(struct dvb_frontend* fe, u16* snr)
290 290
291static int tda8083_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 291static int tda8083_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
292{ 292{
293 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 293 struct tda8083_state* state = fe->demodulator_priv;
294 294
295 state->config->pll_set(fe, p); 295 state->config->pll_set(fe, p);
296 tda8083_set_inversion (state, p->inversion); 296 tda8083_set_inversion (state, p->inversion);
@@ -305,7 +305,7 @@ static int tda8083_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
305 305
306static int tda8083_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 306static int tda8083_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
307{ 307{
308 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 308 struct tda8083_state* state = fe->demodulator_priv;
309 309
310 /* FIXME: get symbolrate & frequency offset...*/ 310 /* FIXME: get symbolrate & frequency offset...*/
311 /*p->frequency = ???;*/ 311 /*p->frequency = ???;*/
@@ -319,7 +319,7 @@ static int tda8083_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
319 319
320static int tda8083_sleep(struct dvb_frontend* fe) 320static int tda8083_sleep(struct dvb_frontend* fe)
321{ 321{
322 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 322 struct tda8083_state* state = fe->demodulator_priv;
323 323
324 tda8083_writereg (state, 0x00, 0x02); 324 tda8083_writereg (state, 0x00, 0x02);
325 return 0; 325 return 0;
@@ -327,7 +327,7 @@ static int tda8083_sleep(struct dvb_frontend* fe)
327 327
328static int tda8083_init(struct dvb_frontend* fe) 328static int tda8083_init(struct dvb_frontend* fe)
329{ 329{
330 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 330 struct tda8083_state* state = fe->demodulator_priv;
331 int i; 331 int i;
332 332
333 for (i=0; i<44; i++) 333 for (i=0; i<44; i++)
@@ -343,7 +343,7 @@ static int tda8083_init(struct dvb_frontend* fe)
343 343
344static int tda8083_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) 344static int tda8083_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
345{ 345{
346 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 346 struct tda8083_state* state = fe->demodulator_priv;
347 347
348 tda8083_send_diseqc_burst (state, burst); 348 tda8083_send_diseqc_burst (state, burst);
349 tda8083_writereg (state, 0x00, 0x3c); 349 tda8083_writereg (state, 0x00, 0x3c);
@@ -354,7 +354,7 @@ static int tda8083_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t
354 354
355static int tda8083_diseqc_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 355static int tda8083_diseqc_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
356{ 356{
357 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 357 struct tda8083_state* state = fe->demodulator_priv;
358 358
359 tda8083_set_tone (state, tone); 359 tda8083_set_tone (state, tone);
360 tda8083_writereg (state, 0x00, 0x3c); 360 tda8083_writereg (state, 0x00, 0x3c);
@@ -365,7 +365,7 @@ static int tda8083_diseqc_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t t
365 365
366static int tda8083_diseqc_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 366static int tda8083_diseqc_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
367{ 367{
368 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 368 struct tda8083_state* state = fe->demodulator_priv;
369 369
370 tda8083_set_voltage (state, voltage); 370 tda8083_set_voltage (state, voltage);
371 tda8083_writereg (state, 0x00, 0x3c); 371 tda8083_writereg (state, 0x00, 0x3c);
@@ -376,7 +376,7 @@ static int tda8083_diseqc_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t
376 376
377static void tda8083_release(struct dvb_frontend* fe) 377static void tda8083_release(struct dvb_frontend* fe)
378{ 378{
379 struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv; 379 struct tda8083_state* state = fe->demodulator_priv;
380 kfree(state); 380 kfree(state);
381} 381}
382 382
@@ -388,7 +388,7 @@ struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
388 struct tda8083_state* state = NULL; 388 struct tda8083_state* state = NULL;
389 389
390 /* allocate memory for the internal state */ 390 /* allocate memory for the internal state */
391 state = (struct tda8083_state*) kmalloc(sizeof(struct tda8083_state), GFP_KERNEL); 391 state = kmalloc(sizeof(struct tda8083_state), GFP_KERNEL);
392 if (state == NULL) goto error; 392 if (state == NULL) goto error;
393 393
394 /* setup the state */ 394 /* setup the state */
diff --git a/drivers/media/dvb/frontends/tda80xx.c b/drivers/media/dvb/frontends/tda80xx.c
index c99632114283..032d348dafb7 100644
--- a/drivers/media/dvb/frontends/tda80xx.c
+++ b/drivers/media/dvb/frontends/tda80xx.c
@@ -27,7 +27,7 @@
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/threads.h> 28#include <linux/threads.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <asm/irq.h> 30#include <linux/irq.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
@@ -400,7 +400,7 @@ static void tda80xx_wait_diseqc_fifo(struct tda80xx_state* state)
400 400
401static int tda8044_init(struct dvb_frontend* fe) 401static int tda8044_init(struct dvb_frontend* fe)
402{ 402{
403 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 403 struct tda80xx_state* state = fe->demodulator_priv;
404 int ret; 404 int ret;
405 405
406 /* 406 /*
@@ -432,7 +432,7 @@ static int tda8044_init(struct dvb_frontend* fe)
432 432
433static int tda8083_init(struct dvb_frontend* fe) 433static int tda8083_init(struct dvb_frontend* fe)
434{ 434{
435 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 435 struct tda80xx_state* state = fe->demodulator_priv;
436 436
437 tda80xx_write(state, 0x00, tda8083_inittab, sizeof(tda8083_inittab)); 437 tda80xx_write(state, 0x00, tda8083_inittab, sizeof(tda8083_inittab));
438 438
@@ -447,7 +447,7 @@ static int tda8083_init(struct dvb_frontend* fe)
447 447
448static int tda80xx_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 448static int tda80xx_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
449{ 449{
450 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 450 struct tda80xx_state* state = fe->demodulator_priv;
451 451
452 switch (voltage) { 452 switch (voltage) {
453 case SEC_VOLTAGE_13: 453 case SEC_VOLTAGE_13:
@@ -463,7 +463,7 @@ static int tda80xx_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage
463 463
464static int tda80xx_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 464static int tda80xx_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
465{ 465{
466 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 466 struct tda80xx_state* state = fe->demodulator_priv;
467 467
468 switch (tone) { 468 switch (tone) {
469 case SEC_TONE_OFF: 469 case SEC_TONE_OFF:
@@ -477,7 +477,7 @@ static int tda80xx_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
477 477
478static int tda80xx_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd) 478static int tda80xx_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd)
479{ 479{
480 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 480 struct tda80xx_state* state = fe->demodulator_priv;
481 481
482 if (cmd->msg_len > 6) 482 if (cmd->msg_len > 6)
483 return -EINVAL; 483 return -EINVAL;
@@ -492,7 +492,7 @@ static int tda80xx_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma
492 492
493static int tda80xx_send_diseqc_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t cmd) 493static int tda80xx_send_diseqc_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t cmd)
494{ 494{
495 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 495 struct tda80xx_state* state = fe->demodulator_priv;
496 496
497 switch (cmd) { 497 switch (cmd) {
498 case SEC_MINI_A: 498 case SEC_MINI_A:
@@ -512,7 +512,7 @@ static int tda80xx_send_diseqc_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t
512 512
513static int tda80xx_sleep(struct dvb_frontend* fe) 513static int tda80xx_sleep(struct dvb_frontend* fe)
514{ 514{
515 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 515 struct tda80xx_state* state = fe->demodulator_priv;
516 516
517 tda80xx_writereg(state, 0x00, 0x02); /* enter standby */ 517 tda80xx_writereg(state, 0x00, 0x02); /* enter standby */
518 518
@@ -521,7 +521,7 @@ static int tda80xx_sleep(struct dvb_frontend* fe)
521 521
522static int tda80xx_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 522static int tda80xx_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
523{ 523{
524 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 524 struct tda80xx_state* state = fe->demodulator_priv;
525 525
526 tda80xx_writereg(state, 0x1c, 0x80); 526 tda80xx_writereg(state, 0x1c, 0x80);
527 state->config->pll_set(fe, p); 527 state->config->pll_set(fe, p);
@@ -537,7 +537,7 @@ static int tda80xx_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
537 537
538static int tda80xx_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 538static int tda80xx_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
539{ 539{
540 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 540 struct tda80xx_state* state = fe->demodulator_priv;
541 541
542 if (!state->config->irq) 542 if (!state->config->irq)
543 tda80xx_read_status_int(state); 543 tda80xx_read_status_int(state);
@@ -550,7 +550,7 @@ static int tda80xx_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
550 550
551static int tda80xx_read_status(struct dvb_frontend* fe, fe_status_t* status) 551static int tda80xx_read_status(struct dvb_frontend* fe, fe_status_t* status)
552{ 552{
553 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 553 struct tda80xx_state* state = fe->demodulator_priv;
554 554
555 if (!state->config->irq) 555 if (!state->config->irq)
556 tda80xx_read_status_int(state); 556 tda80xx_read_status_int(state);
@@ -561,7 +561,7 @@ static int tda80xx_read_status(struct dvb_frontend* fe, fe_status_t* status)
561 561
562static int tda80xx_read_ber(struct dvb_frontend* fe, u32* ber) 562static int tda80xx_read_ber(struct dvb_frontend* fe, u32* ber)
563{ 563{
564 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 564 struct tda80xx_state* state = fe->demodulator_priv;
565 int ret; 565 int ret;
566 u8 buf[3]; 566 u8 buf[3];
567 567
@@ -575,7 +575,7 @@ static int tda80xx_read_ber(struct dvb_frontend* fe, u32* ber)
575 575
576static int tda80xx_read_signal_strength(struct dvb_frontend* fe, u16* strength) 576static int tda80xx_read_signal_strength(struct dvb_frontend* fe, u16* strength)
577{ 577{
578 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 578 struct tda80xx_state* state = fe->demodulator_priv;
579 579
580 u8 gain = ~tda80xx_readreg(state, 0x01); 580 u8 gain = ~tda80xx_readreg(state, 0x01);
581 *strength = (gain << 8) | gain; 581 *strength = (gain << 8) | gain;
@@ -585,7 +585,7 @@ static int tda80xx_read_signal_strength(struct dvb_frontend* fe, u16* strength)
585 585
586static int tda80xx_read_snr(struct dvb_frontend* fe, u16* snr) 586static int tda80xx_read_snr(struct dvb_frontend* fe, u16* snr)
587{ 587{
588 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 588 struct tda80xx_state* state = fe->demodulator_priv;
589 589
590 u8 quality = tda80xx_readreg(state, 0x08); 590 u8 quality = tda80xx_readreg(state, 0x08);
591 *snr = (quality << 8) | quality; 591 *snr = (quality << 8) | quality;
@@ -595,7 +595,7 @@ static int tda80xx_read_snr(struct dvb_frontend* fe, u16* snr)
595 595
596static int tda80xx_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 596static int tda80xx_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
597{ 597{
598 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 598 struct tda80xx_state* state = fe->demodulator_priv;
599 599
600 *ucblocks = tda80xx_readreg(state, 0x0f); 600 *ucblocks = tda80xx_readreg(state, 0x0f);
601 if (*ucblocks == 0xff) 601 if (*ucblocks == 0xff)
@@ -606,7 +606,7 @@ static int tda80xx_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
606 606
607static int tda80xx_init(struct dvb_frontend* fe) 607static int tda80xx_init(struct dvb_frontend* fe)
608{ 608{
609 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 609 struct tda80xx_state* state = fe->demodulator_priv;
610 610
611 switch(state->id) { 611 switch(state->id) {
612 case ID_TDA8044: 612 case ID_TDA8044:
@@ -620,7 +620,7 @@ static int tda80xx_init(struct dvb_frontend* fe)
620 620
621static void tda80xx_release(struct dvb_frontend* fe) 621static void tda80xx_release(struct dvb_frontend* fe)
622{ 622{
623 struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv; 623 struct tda80xx_state* state = fe->demodulator_priv;
624 624
625 if (state->config->irq) 625 if (state->config->irq)
626 free_irq(state->config->irq, &state->worklet); 626 free_irq(state->config->irq, &state->worklet);
@@ -637,7 +637,7 @@ struct dvb_frontend* tda80xx_attach(const struct tda80xx_config* config,
637 int ret; 637 int ret;
638 638
639 /* allocate memory for the internal state */ 639 /* allocate memory for the internal state */
640 state = (struct tda80xx_state*) kmalloc(sizeof(struct tda80xx_state), GFP_KERNEL); 640 state = kmalloc(sizeof(struct tda80xx_state), GFP_KERNEL);
641 if (state == NULL) goto error; 641 if (state == NULL) goto error;
642 642
643 /* setup the state */ 643 /* setup the state */
diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c
index 9c0d23e1d9e5..70fb44b391a7 100644
--- a/drivers/media/dvb/frontends/ves1820.c
+++ b/drivers/media/dvb/frontends/ves1820.c
@@ -70,7 +70,6 @@ static int ves1820_writereg(struct ves1820_state *state, u8 reg, u8 data)
70 printk("ves1820: %s(): writereg error (reg == 0x%02x," 70 printk("ves1820: %s(): writereg error (reg == 0x%02x,"
71 "val == 0x%02x, ret == %i)\n", __FUNCTION__, reg, data, ret); 71 "val == 0x%02x, ret == %i)\n", __FUNCTION__, reg, data, ret);
72 72
73 msleep(10);
74 return (ret != 1) ? -EREMOTEIO : 0; 73 return (ret != 1) ? -EREMOTEIO : 0;
75} 74}
76 75
@@ -193,7 +192,7 @@ static int ves1820_set_symbolrate(struct ves1820_state *state, u32 symbolrate)
193 192
194static int ves1820_init(struct dvb_frontend* fe) 193static int ves1820_init(struct dvb_frontend* fe)
195{ 194{
196 struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv; 195 struct ves1820_state* state = fe->demodulator_priv;
197 int i; 196 int i;
198 int val; 197 int val;
199 198
@@ -214,7 +213,7 @@ static int ves1820_init(struct dvb_frontend* fe)
214 213
215static int ves1820_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 214static int ves1820_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
216{ 215{
217 struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv; 216 struct ves1820_state* state = fe->demodulator_priv;
218 static const u8 reg0x00[] = { 0x00, 0x04, 0x08, 0x0c, 0x10 }; 217 static const u8 reg0x00[] = { 0x00, 0x04, 0x08, 0x0c, 0x10 };
219 static const u8 reg0x01[] = { 140, 140, 106, 100, 92 }; 218 static const u8 reg0x01[] = { 140, 140, 106, 100, 92 };
220 static const u8 reg0x05[] = { 135, 100, 70, 54, 38 }; 219 static const u8 reg0x05[] = { 135, 100, 70, 54, 38 };
@@ -241,7 +240,7 @@ static int ves1820_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_p
241 240
242static int ves1820_read_status(struct dvb_frontend* fe, fe_status_t* status) 241static int ves1820_read_status(struct dvb_frontend* fe, fe_status_t* status)
243{ 242{
244 struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv; 243 struct ves1820_state* state = fe->demodulator_priv;
245 int sync; 244 int sync;
246 245
247 *status = 0; 246 *status = 0;
@@ -267,7 +266,7 @@ static int ves1820_read_status(struct dvb_frontend* fe, fe_status_t* status)
267 266
268static int ves1820_read_ber(struct dvb_frontend* fe, u32* ber) 267static int ves1820_read_ber(struct dvb_frontend* fe, u32* ber)
269{ 268{
270 struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv; 269 struct ves1820_state* state = fe->demodulator_priv;
271 270
272 u32 _ber = ves1820_readreg(state, 0x14) | 271 u32 _ber = ves1820_readreg(state, 0x14) |
273 (ves1820_readreg(state, 0x15) << 8) | 272 (ves1820_readreg(state, 0x15) << 8) |
@@ -279,7 +278,7 @@ static int ves1820_read_ber(struct dvb_frontend* fe, u32* ber)
279 278
280static int ves1820_read_signal_strength(struct dvb_frontend* fe, u16* strength) 279static int ves1820_read_signal_strength(struct dvb_frontend* fe, u16* strength)
281{ 280{
282 struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv; 281 struct ves1820_state* state = fe->demodulator_priv;
283 282
284 u8 gain = ves1820_readreg(state, 0x17); 283 u8 gain = ves1820_readreg(state, 0x17);
285 *strength = (gain << 8) | gain; 284 *strength = (gain << 8) | gain;
@@ -289,7 +288,7 @@ static int ves1820_read_signal_strength(struct dvb_frontend* fe, u16* strength)
289 288
290static int ves1820_read_snr(struct dvb_frontend* fe, u16* snr) 289static int ves1820_read_snr(struct dvb_frontend* fe, u16* snr)
291{ 290{
292 struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv; 291 struct ves1820_state* state = fe->demodulator_priv;
293 292
294 u8 quality = ~ves1820_readreg(state, 0x18); 293 u8 quality = ~ves1820_readreg(state, 0x18);
295 *snr = (quality << 8) | quality; 294 *snr = (quality << 8) | quality;
@@ -299,7 +298,7 @@ static int ves1820_read_snr(struct dvb_frontend* fe, u16* snr)
299 298
300static int ves1820_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 299static int ves1820_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
301{ 300{
302 struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv; 301 struct ves1820_state* state = fe->demodulator_priv;
303 302
304 *ucblocks = ves1820_readreg(state, 0x13) & 0x7f; 303 *ucblocks = ves1820_readreg(state, 0x13) & 0x7f;
305 if (*ucblocks == 0x7f) 304 if (*ucblocks == 0x7f)
@@ -314,7 +313,7 @@ static int ves1820_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
314 313
315static int ves1820_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 314static int ves1820_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
316{ 315{
317 struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv; 316 struct ves1820_state* state = fe->demodulator_priv;
318 int sync; 317 int sync;
319 s8 afc = 0; 318 s8 afc = 0;
320 319
@@ -345,7 +344,7 @@ static int ves1820_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
345 344
346static int ves1820_sleep(struct dvb_frontend* fe) 345static int ves1820_sleep(struct dvb_frontend* fe)
347{ 346{
348 struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv; 347 struct ves1820_state* state = fe->demodulator_priv;
349 348
350 ves1820_writereg(state, 0x1b, 0x02); /* pdown ADC */ 349 ves1820_writereg(state, 0x1b, 0x02); /* pdown ADC */
351 ves1820_writereg(state, 0x00, 0x80); /* standby */ 350 ves1820_writereg(state, 0x00, 0x80); /* standby */
@@ -364,7 +363,7 @@ static int ves1820_get_tune_settings(struct dvb_frontend* fe, struct dvb_fronten
364 363
365static void ves1820_release(struct dvb_frontend* fe) 364static void ves1820_release(struct dvb_frontend* fe)
366{ 365{
367 struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv; 366 struct ves1820_state* state = fe->demodulator_priv;
368 kfree(state); 367 kfree(state);
369} 368}
370 369
@@ -377,7 +376,7 @@ struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
377 struct ves1820_state* state = NULL; 376 struct ves1820_state* state = NULL;
378 377
379 /* allocate memory for the internal state */ 378 /* allocate memory for the internal state */
380 state = (struct ves1820_state*) kmalloc(sizeof(struct ves1820_state), GFP_KERNEL); 379 state = kmalloc(sizeof(struct ves1820_state), GFP_KERNEL);
381 if (state == NULL) 380 if (state == NULL)
382 goto error; 381 goto error;
383 382
diff --git a/drivers/media/dvb/frontends/ves1x93.c b/drivers/media/dvb/frontends/ves1x93.c
index edcad283aa86..821df8e839d0 100644
--- a/drivers/media/dvb/frontends/ves1x93.c
+++ b/drivers/media/dvb/frontends/ves1x93.c
@@ -263,7 +263,7 @@ static int ves1x93_set_symbolrate (struct ves1x93_state* state, u32 srate)
263 263
264static int ves1x93_init (struct dvb_frontend* fe) 264static int ves1x93_init (struct dvb_frontend* fe)
265{ 265{
266 struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv; 266 struct ves1x93_state* state = fe->demodulator_priv;
267 int i; 267 int i;
268 int val; 268 int val;
269 269
@@ -289,7 +289,7 @@ static int ves1x93_init (struct dvb_frontend* fe)
289 289
290static int ves1x93_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage) 290static int ves1x93_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
291{ 291{
292 struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv; 292 struct ves1x93_state* state = fe->demodulator_priv;
293 293
294 switch (voltage) { 294 switch (voltage) {
295 case SEC_VOLTAGE_13: 295 case SEC_VOLTAGE_13:
@@ -305,7 +305,7 @@ static int ves1x93_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag
305 305
306static int ves1x93_read_status(struct dvb_frontend* fe, fe_status_t* status) 306static int ves1x93_read_status(struct dvb_frontend* fe, fe_status_t* status)
307{ 307{
308 struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv; 308 struct ves1x93_state* state = fe->demodulator_priv;
309 309
310 u8 sync = ves1x93_readreg (state, 0x0e); 310 u8 sync = ves1x93_readreg (state, 0x0e);
311 311
@@ -346,7 +346,7 @@ static int ves1x93_read_status(struct dvb_frontend* fe, fe_status_t* status)
346 346
347static int ves1x93_read_ber(struct dvb_frontend* fe, u32* ber) 347static int ves1x93_read_ber(struct dvb_frontend* fe, u32* ber)
348{ 348{
349 struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv; 349 struct ves1x93_state* state = fe->demodulator_priv;
350 350
351 *ber = ves1x93_readreg (state, 0x15); 351 *ber = ves1x93_readreg (state, 0x15);
352 *ber |= (ves1x93_readreg (state, 0x16) << 8); 352 *ber |= (ves1x93_readreg (state, 0x16) << 8);
@@ -358,7 +358,7 @@ static int ves1x93_read_ber(struct dvb_frontend* fe, u32* ber)
358 358
359static int ves1x93_read_signal_strength(struct dvb_frontend* fe, u16* strength) 359static int ves1x93_read_signal_strength(struct dvb_frontend* fe, u16* strength)
360{ 360{
361 struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv; 361 struct ves1x93_state* state = fe->demodulator_priv;
362 362
363 u8 signal = ~ves1x93_readreg (state, 0x0b); 363 u8 signal = ~ves1x93_readreg (state, 0x0b);
364 *strength = (signal << 8) | signal; 364 *strength = (signal << 8) | signal;
@@ -368,7 +368,7 @@ static int ves1x93_read_signal_strength(struct dvb_frontend* fe, u16* strength)
368 368
369static int ves1x93_read_snr(struct dvb_frontend* fe, u16* snr) 369static int ves1x93_read_snr(struct dvb_frontend* fe, u16* snr)
370{ 370{
371 struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv; 371 struct ves1x93_state* state = fe->demodulator_priv;
372 372
373 u8 _snr = ~ves1x93_readreg (state, 0x1c); 373 u8 _snr = ~ves1x93_readreg (state, 0x1c);
374 *snr = (_snr << 8) | _snr; 374 *snr = (_snr << 8) | _snr;
@@ -378,7 +378,7 @@ static int ves1x93_read_snr(struct dvb_frontend* fe, u16* snr)
378 378
379static int ves1x93_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 379static int ves1x93_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
380{ 380{
381 struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv; 381 struct ves1x93_state* state = fe->demodulator_priv;
382 382
383 *ucblocks = ves1x93_readreg (state, 0x18) & 0x7f; 383 *ucblocks = ves1x93_readreg (state, 0x18) & 0x7f;
384 384
@@ -393,7 +393,7 @@ static int ves1x93_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
393 393
394static int ves1x93_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 394static int ves1x93_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
395{ 395{
396 struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv; 396 struct ves1x93_state* state = fe->demodulator_priv;
397 397
398 ves1x93_writereg(state, 0x00, 0x11); 398 ves1x93_writereg(state, 0x00, 0x11);
399 state->config->pll_set(fe, p); 399 state->config->pll_set(fe, p);
@@ -408,7 +408,7 @@ static int ves1x93_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
408 408
409static int ves1x93_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 409static int ves1x93_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
410{ 410{
411 struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv; 411 struct ves1x93_state* state = fe->demodulator_priv;
412 int afc; 412 int afc;
413 413
414 afc = ((int)((char)(ves1x93_readreg (state, 0x0a) << 1)))/2; 414 afc = ((int)((char)(ves1x93_readreg (state, 0x0a) << 1)))/2;
@@ -431,14 +431,14 @@ static int ves1x93_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
431 431
432static int ves1x93_sleep(struct dvb_frontend* fe) 432static int ves1x93_sleep(struct dvb_frontend* fe)
433{ 433{
434 struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv; 434 struct ves1x93_state* state = fe->demodulator_priv;
435 435
436 return ves1x93_writereg (state, 0x00, 0x08); 436 return ves1x93_writereg (state, 0x00, 0x08);
437} 437}
438 438
439static void ves1x93_release(struct dvb_frontend* fe) 439static void ves1x93_release(struct dvb_frontend* fe)
440{ 440{
441 struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv; 441 struct ves1x93_state* state = fe->demodulator_priv;
442 kfree(state); 442 kfree(state);
443} 443}
444 444
@@ -451,7 +451,7 @@ struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
451 u8 identity; 451 u8 identity;
452 452
453 /* allocate memory for the internal state */ 453 /* allocate memory for the internal state */
454 state = (struct ves1x93_state*) kmalloc(sizeof(struct ves1x93_state), GFP_KERNEL); 454 state = kmalloc(sizeof(struct ves1x93_state), GFP_KERNEL);
455 if (state == NULL) goto error; 455 if (state == NULL) goto error;
456 456
457 /* setup the state */ 457 /* setup the state */
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 922c205a2652..8e33a850e13e 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -130,7 +130,7 @@ static void init_av7110_av(struct av7110 *av7110)
130 av7110->current_input = 0; 130 av7110->current_input = 0;
131 if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) { 131 if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) {
132 printk ("dvb-ttpci: Crystal audio DAC @ card %d detected\n", 132 printk ("dvb-ttpci: Crystal audio DAC @ card %d detected\n",
133 av7110->dvb_adapter->num); 133 av7110->dvb_adapter.num);
134 av7110->adac_type = DVB_ADAC_CRYSTAL; 134 av7110->adac_type = DVB_ADAC_CRYSTAL;
135 i2c_writereg(av7110, 0x20, 0x01, 0xd2); 135 i2c_writereg(av7110, 0x20, 0x01, 0xd2);
136 i2c_writereg(av7110, 0x20, 0x02, 0x49); 136 i2c_writereg(av7110, 0x20, 0x02, 0x49);
@@ -145,13 +145,13 @@ static void init_av7110_av(struct av7110 *av7110)
145 } 145 }
146 else if (dev->pci->subsystem_vendor == 0x110a) { 146 else if (dev->pci->subsystem_vendor == 0x110a) {
147 printk("dvb-ttpci: DVB-C w/o analog module @ card %d detected\n", 147 printk("dvb-ttpci: DVB-C w/o analog module @ card %d detected\n",
148 av7110->dvb_adapter->num); 148 av7110->dvb_adapter.num);
149 av7110->adac_type = DVB_ADAC_NONE; 149 av7110->adac_type = DVB_ADAC_NONE;
150 } 150 }
151 else { 151 else {
152 av7110->adac_type = adac; 152 av7110->adac_type = adac;
153 printk("dvb-ttpci: adac type set to %d @ card %d\n", 153 printk("dvb-ttpci: adac type set to %d @ card %d\n",
154 av7110->dvb_adapter->num, av7110->adac_type); 154 av7110->dvb_adapter.num, av7110->adac_type);
155 } 155 }
156 156
157 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) { 157 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) {
@@ -231,7 +231,7 @@ static int arm_thread(void *data)
231 231
232 if (newloops == av7110->arm_loops) { 232 if (newloops == av7110->arm_loops) {
233 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n", 233 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n",
234 av7110->dvb_adapter->num); 234 av7110->dvb_adapter.num);
235 235
236 arm_error(av7110); 236 arm_error(av7110);
237 av7710_set_video_mode(av7110, vidmode); 237 av7710_set_video_mode(av7110, vidmode);
@@ -1282,7 +1282,7 @@ static int av7110_register(struct av7110 *av7110)
1282 av7110->dmxdev.demux = &dvbdemux->dmx; 1282 av7110->dmxdev.demux = &dvbdemux->dmx;
1283 av7110->dmxdev.capabilities = 0; 1283 av7110->dmxdev.capabilities = 0;
1284 1284
1285 dvb_dmxdev_init(&av7110->dmxdev, av7110->dvb_adapter); 1285 dvb_dmxdev_init(&av7110->dmxdev, &av7110->dvb_adapter);
1286 1286
1287 av7110->hw_frontend.source = DMX_FRONTEND_0; 1287 av7110->hw_frontend.source = DMX_FRONTEND_0;
1288 1288
@@ -1307,11 +1307,11 @@ static int av7110_register(struct av7110 *av7110)
1307 av7110_ca_register(av7110); 1307 av7110_ca_register(av7110);
1308 1308
1309#ifdef CONFIG_DVB_AV7110_OSD 1309#ifdef CONFIG_DVB_AV7110_OSD
1310 dvb_register_device(av7110->dvb_adapter, &av7110->osd_dev, 1310 dvb_register_device(&av7110->dvb_adapter, &av7110->osd_dev,
1311 &dvbdev_osd, av7110, DVB_DEVICE_OSD); 1311 &dvbdev_osd, av7110, DVB_DEVICE_OSD);
1312#endif 1312#endif
1313 1313
1314 dvb_net_init(av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx); 1314 dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx);
1315 1315
1316 if (budgetpatch) { 1316 if (budgetpatch) {
1317 /* initialize software demux1 without its own frontend 1317 /* initialize software demux1 without its own frontend
@@ -1334,9 +1334,9 @@ static int av7110_register(struct av7110 *av7110)
1334 av7110->dmxdev1.demux = &dvbdemux1->dmx; 1334 av7110->dmxdev1.demux = &dvbdemux1->dmx;
1335 av7110->dmxdev1.capabilities = 0; 1335 av7110->dmxdev1.capabilities = 0;
1336 1336
1337 dvb_dmxdev_init(&av7110->dmxdev1, av7110->dvb_adapter); 1337 dvb_dmxdev_init(&av7110->dmxdev1, &av7110->dvb_adapter);
1338 1338
1339 dvb_net_init(av7110->dvb_adapter, &av7110->dvb_net1, &dvbdemux1->dmx); 1339 dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net1, &dvbdemux1->dmx);
1340 printk("dvb-ttpci: additional demux1 for budget-patch registered\n"); 1340 printk("dvb-ttpci: additional demux1 for budget-patch registered\n");
1341 } 1341 }
1342 return 0; 1342 return 0;
@@ -1673,6 +1673,106 @@ static struct stv0299_config alps_bsru6_config = {
1673}; 1673};
1674 1674
1675 1675
1676static u8 alps_bsbe1_inittab[] = {
1677 0x01, 0x15,
1678 0x02, 0x30,
1679 0x03, 0x00,
1680 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
1681 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
1682 0x06, 0x40, /* DAC not used, set to high impendance mode */
1683 0x07, 0x00, /* DAC LSB */
1684 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
1685 0x09, 0x00, /* FIFO */
1686 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
1687 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
1688 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
1689 0x10, 0x3f, // AGC2 0x3d
1690 0x11, 0x84,
1691 0x12, 0xb5, // Lock detect: -64 Carrier freq detect:on
1692 0x15, 0xc9, // lock detector threshold
1693 0x16, 0x00,
1694 0x17, 0x00,
1695 0x18, 0x00,
1696 0x19, 0x00,
1697 0x1a, 0x00,
1698 0x1f, 0x50,
1699 0x20, 0x00,
1700 0x21, 0x00,
1701 0x22, 0x00,
1702 0x23, 0x00,
1703 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
1704 0x29, 0x1e, // 1/2 threshold
1705 0x2a, 0x14, // 2/3 threshold
1706 0x2b, 0x0f, // 3/4 threshold
1707 0x2c, 0x09, // 5/6 threshold
1708 0x2d, 0x05, // 7/8 threshold
1709 0x2e, 0x01,
1710 0x31, 0x1f, // test all FECs
1711 0x32, 0x19, // viterbi and synchro search
1712 0x33, 0xfc, // rs control
1713 0x34, 0x93, // error control
1714 0x0f, 0x92,
1715 0xff, 0xff
1716};
1717
1718static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1719{
1720 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1721 int ret;
1722 u8 data[4];
1723 u32 div;
1724 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
1725
1726 if ((params->frequency < 950000) || (params->frequency > 2150000))
1727 return -EINVAL;
1728
1729 div = (params->frequency + (125 - 1)) / 125; // round correctly
1730 data[0] = (div >> 8) & 0x7f;
1731 data[1] = div & 0xff;
1732 data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
1733 data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
1734
1735 ret = i2c_transfer(&av7110->i2c_adap, &msg, 1);
1736 return (ret != 1) ? -EIO : 0;
1737}
1738
1739static struct stv0299_config alps_bsbe1_config = {
1740 .demod_address = 0x68,
1741 .inittab = alps_bsbe1_inittab,
1742 .mclk = 88000000UL,
1743 .invert = 1,
1744 .enhanced_tuning = 0,
1745 .skip_reinit = 0,
1746 .min_delay_ms = 100,
1747 .set_symbol_rate = alps_bsru6_set_symbol_rate,
1748 .pll_set = alps_bsbe1_pll_set,
1749};
1750
1751static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
1752{
1753 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1754 int ret;
1755 u8 data[1];
1756 struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = data, .len = sizeof(data) };
1757
1758 switch(voltage) {
1759 case SEC_VOLTAGE_OFF:
1760 data[0] = 0x00;
1761 break;
1762 case SEC_VOLTAGE_13:
1763 data[0] = 0x44;
1764 break;
1765 case SEC_VOLTAGE_18:
1766 data[0] = 0x4c;
1767 break;
1768 default:
1769 return -EINVAL;
1770 };
1771
1772 ret = i2c_transfer(&av7110->i2c_adap, &msg, 1);
1773 return (ret != 1) ? -EIO : 0;
1774}
1775
1676 1776
1677static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 1777static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1678{ 1778{
@@ -2116,6 +2216,14 @@ static int frontend_init(struct av7110 *av7110)
2116 av7110->dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240; 2216 av7110->dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
2117 break; 2217 break;
2118 } 2218 }
2219 break;
2220
2221 case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */
2222 /* ALPS BSBE1 */
2223 av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap);
2224 if (av7110->fe)
2225 av7110->fe->ops->set_voltage = lnbp21_set_voltage;
2226 break;
2119 } 2227 }
2120 } 2228 }
2121 2229
@@ -2138,7 +2246,7 @@ static int frontend_init(struct av7110 *av7110)
2138 FE_FUNC_OVERRIDE(av7110->fe->ops->dishnetwork_send_legacy_command, av7110->fe_dishnetwork_send_legacy_command, av7110_fe_dishnetwork_send_legacy_command); 2246 FE_FUNC_OVERRIDE(av7110->fe->ops->dishnetwork_send_legacy_command, av7110->fe_dishnetwork_send_legacy_command, av7110_fe_dishnetwork_send_legacy_command);
2139 FE_FUNC_OVERRIDE(av7110->fe->ops->set_frontend, av7110->fe_set_frontend, av7110_fe_set_frontend); 2247 FE_FUNC_OVERRIDE(av7110->fe->ops->set_frontend, av7110->fe_set_frontend, av7110_fe_set_frontend);
2140 2248
2141 ret = dvb_register_frontend(av7110->dvb_adapter, av7110->fe); 2249 ret = dvb_register_frontend(&av7110->dvb_adapter, av7110->fe);
2142 if (ret < 0) { 2250 if (ret < 0) {
2143 printk("av7110: Frontend registration failed!\n"); 2251 printk("av7110: Frontend registration failed!\n");
2144 if (av7110->fe->ops->release) 2252 if (av7110->fe->ops->release)
@@ -2352,7 +2460,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
2352 goto err_dvb_unregister_adapter_2; 2460 goto err_dvb_unregister_adapter_2;
2353 2461
2354 ttpci_eeprom_parse_mac(&av7110->i2c_adap, 2462 ttpci_eeprom_parse_mac(&av7110->i2c_adap,
2355 av7110->dvb_adapter->proposed_mac); 2463 av7110->dvb_adapter.proposed_mac);
2356 ret = -ENOMEM; 2464 ret = -ENOMEM;
2357 2465
2358 if (budgetpatch) { 2466 if (budgetpatch) {
@@ -2523,7 +2631,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
2523 if (ret < 0) 2631 if (ret < 0)
2524 goto err_av7110_unregister_11; 2632 goto err_av7110_unregister_11;
2525 2633
2526 av7110->dvb_adapter->priv = av7110; 2634 av7110->dvb_adapter.priv = av7110;
2527 ret = frontend_init(av7110); 2635 ret = frontend_init(av7110);
2528 if (ret < 0) 2636 if (ret < 0)
2529 goto err_av7110_exit_v4l_12; 2637 goto err_av7110_exit_v4l_12;
@@ -2558,7 +2666,7 @@ err_saa71466_vfree_4:
2558err_i2c_del_3: 2666err_i2c_del_3:
2559 i2c_del_adapter(&av7110->i2c_adap); 2667 i2c_del_adapter(&av7110->i2c_adap);
2560err_dvb_unregister_adapter_2: 2668err_dvb_unregister_adapter_2:
2561 dvb_unregister_adapter(av7110->dvb_adapter); 2669 dvb_unregister_adapter(&av7110->dvb_adapter);
2562err_put_firmware_1: 2670err_put_firmware_1:
2563 put_firmware(av7110); 2671 put_firmware(av7110);
2564err_kfree_0: 2672err_kfree_0:
@@ -2604,7 +2712,7 @@ static int av7110_detach(struct saa7146_dev* saa)
2604 2712
2605 i2c_del_adapter(&av7110->i2c_adap); 2713 i2c_del_adapter(&av7110->i2c_adap);
2606 2714
2607 dvb_unregister_adapter (av7110->dvb_adapter); 2715 dvb_unregister_adapter (&av7110->dvb_adapter);
2608 2716
2609 av7110_num--; 2717 av7110_num--;
2610 2718
@@ -2672,21 +2780,23 @@ MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X");
2672MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X"); 2780MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X");
2673MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X"); 2781MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X");
2674MAKE_AV7110_INFO(tts_2_X, "Technotrend/Hauppauge WinTV Nexus-S rev2.X"); 2782MAKE_AV7110_INFO(tts_2_X, "Technotrend/Hauppauge WinTV Nexus-S rev2.X");
2783MAKE_AV7110_INFO(tts_2_3, "Technotrend/Hauppauge WinTV Nexus-S rev2.3");
2675MAKE_AV7110_INFO(tts_1_3se, "Technotrend/Hauppauge WinTV DVB-S rev1.3 SE"); 2784MAKE_AV7110_INFO(tts_1_3se, "Technotrend/Hauppauge WinTV DVB-S rev1.3 SE");
2676MAKE_AV7110_INFO(ttt, "Technotrend/Hauppauge DVB-T"); 2785MAKE_AV7110_INFO(ttt, "Technotrend/Hauppauge DVB-T");
2677MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C"); 2786MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C");
2678MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6"); 2787MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6");
2679 2788
2680static struct pci_device_id pci_tbl[] = { 2789static struct pci_device_id pci_tbl[] = {
2790 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000),
2681 MAKE_EXTENSION_PCI(tts_1_X, 0x13c2, 0x0000), 2791 MAKE_EXTENSION_PCI(tts_1_X, 0x13c2, 0x0000),
2682 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), 2792 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001),
2683 MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), 2793 MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002),
2684 MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), 2794 MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003),
2685 MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002),
2686 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000),
2687 MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a),
2688 MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), 2795 MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006),
2689 MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), 2796 MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008),
2797 MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a),
2798 MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e),
2799 MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002),
2690 2800
2691/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte 2801/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte
2692/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1 2802/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1
diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h
index 5070e0523da7..4f69b4d01479 100644
--- a/drivers/media/dvb/ttpci/av7110.h
+++ b/drivers/media/dvb/ttpci/av7110.h
@@ -220,7 +220,7 @@ struct av7110 {
220 220
221 struct audio_mixer mixer; 221 struct audio_mixer mixer;
222 222
223 struct dvb_adapter *dvb_adapter; 223 struct dvb_adapter dvb_adapter;
224 struct dvb_device *video_dev; 224 struct dvb_device *video_dev;
225 struct dvb_device *audio_dev; 225 struct dvb_device *audio_dev;
226 struct dvb_device *ca_dev; 226 struct dvb_device *ca_dev;
@@ -274,7 +274,6 @@ extern void av7110_ir_exit (void);
274extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val); 274extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val);
275extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg); 275extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg);
276extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val); 276extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val);
277extern int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val);
278 277
279 278
280extern int av7110_init_analog_module(struct av7110 *av7110); 279extern int av7110_init_analog_module(struct av7110 *av7110);
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index d77e8a00688f..ccf946125d02 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -1075,7 +1075,7 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
1075 } 1075 }
1076 if (ret < 0) 1076 if (ret < 0)
1077 break; 1077 break;
1078 av7110->videostate.video_format = format; 1078 av7110->videostate.display_format = format;
1079 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetPanScanType, 1079 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetPanScanType,
1080 1, (u16) val); 1080 1, (u16) val);
1081 break; 1081 break;
@@ -1230,14 +1230,20 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1230 switch(av7110->audiostate.channel_select) { 1230 switch(av7110->audiostate.channel_select) {
1231 case AUDIO_STEREO: 1231 case AUDIO_STEREO:
1232 audcom(av7110, AUDIO_CMD_STEREO); 1232 audcom(av7110, AUDIO_CMD_STEREO);
1233 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1234 i2c_writereg(av7110, 0x20, 0x02, 0x49);
1233 break; 1235 break;
1234 1236
1235 case AUDIO_MONO_LEFT: 1237 case AUDIO_MONO_LEFT:
1236 audcom(av7110, AUDIO_CMD_MONO_L); 1238 audcom(av7110, AUDIO_CMD_MONO_L);
1239 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1240 i2c_writereg(av7110, 0x20, 0x02, 0x4a);
1237 break; 1241 break;
1238 1242
1239 case AUDIO_MONO_RIGHT: 1243 case AUDIO_MONO_RIGHT:
1240 audcom(av7110, AUDIO_CMD_MONO_R); 1244 audcom(av7110, AUDIO_CMD_MONO_R);
1245 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1246 i2c_writereg(av7110, 0x20, 0x02, 0x45);
1241 break; 1247 break;
1242 1248
1243 default: 1249 default:
@@ -1409,10 +1415,10 @@ int av7110_av_register(struct av7110 *av7110)
1409 av7110->video_events.overflow = 0; 1415 av7110->video_events.overflow = 0;
1410 memset(&av7110->video_size, 0, sizeof (video_size_t)); 1416 memset(&av7110->video_size, 0, sizeof (video_size_t));
1411 1417
1412 dvb_register_device(av7110->dvb_adapter, &av7110->video_dev, 1418 dvb_register_device(&av7110->dvb_adapter, &av7110->video_dev,
1413 &dvbdev_video, av7110, DVB_DEVICE_VIDEO); 1419 &dvbdev_video, av7110, DVB_DEVICE_VIDEO);
1414 1420
1415 dvb_register_device(av7110->dvb_adapter, &av7110->audio_dev, 1421 dvb_register_device(&av7110->dvb_adapter, &av7110->audio_dev,
1416 &dvbdev_audio, av7110, DVB_DEVICE_AUDIO); 1422 &dvbdev_audio, av7110, DVB_DEVICE_AUDIO);
1417 1423
1418 return 0; 1424 return 0;
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index 21f7aacf7726..c3801e328fe9 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -123,7 +123,7 @@ static void ci_ll_release(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *
123} 123}
124 124
125static int ci_ll_reset(struct dvb_ringbuffer *cibuf, struct file *file, 125static int ci_ll_reset(struct dvb_ringbuffer *cibuf, struct file *file,
126 int slots, ca_slot_info_t *slot) 126 int slots, ca_slot_info_t *slot)
127{ 127{
128 int i; 128 int i;
129 int len = 0; 129 int len = 0;
@@ -370,7 +370,7 @@ static struct dvb_device dvbdev_ca = {
370 370
371int av7110_ca_register(struct av7110 *av7110) 371int av7110_ca_register(struct av7110 *av7110)
372{ 372{
373 return dvb_register_device(av7110->dvb_adapter, &av7110->ca_dev, 373 return dvb_register_device(&av7110->dvb_adapter, &av7110->ca_dev,
374 &dvbdev_ca, av7110, DVB_DEVICE_CA); 374 &dvbdev_ca, av7110, DVB_DEVICE_CA);
375} 375}
376 376
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c
index bd6e5ea4aefe..7fa4a0ebe133 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.c
+++ b/drivers/media/dvb/ttpci/av7110_hw.c
@@ -104,7 +104,7 @@ u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count)
104 104
105 105
106/* av7110 ARM core boot stuff */ 106/* av7110 ARM core boot stuff */
107 107#if 0
108void av7110_reset_arm(struct av7110 *av7110) 108void av7110_reset_arm(struct av7110 *av7110)
109{ 109{
110 saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTLO); 110 saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTLO);
@@ -124,7 +124,7 @@ void av7110_reset_arm(struct av7110 *av7110)
124 av7110->arm_ready = 1; 124 av7110->arm_ready = 1;
125 dprintk(1, "reset ARM\n"); 125 dprintk(1, "reset ARM\n");
126} 126}
127 127#endif /* 0 */
128 128
129static int waitdebi(struct av7110 *av7110, int adr, int state) 129static int waitdebi(struct av7110 *av7110, int adr, int state)
130{ 130{
@@ -335,7 +335,7 @@ int av7110_wait_msgstate(struct av7110 *av7110, u16 flags)
335 return 0; 335 return 0;
336} 336}
337 337
338int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) 338static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
339{ 339{
340 int i; 340 int i;
341 unsigned long start; 341 unsigned long start;
@@ -455,7 +455,7 @@ int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
455 return 0; 455 return 0;
456} 456}
457 457
458int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) 458static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
459{ 459{
460 int ret; 460 int ret;
461 461
@@ -500,6 +500,7 @@ int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...)
500 return ret; 500 return ret;
501} 501}
502 502
503#if 0
503int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len) 504int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len)
504{ 505{
505 int i, ret; 506 int i, ret;
@@ -521,6 +522,7 @@ int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len)
521 printk(KERN_ERR "dvb-ttpci: av7110_send_ci_cmd error %d\n", ret); 522 printk(KERN_ERR "dvb-ttpci: av7110_send_ci_cmd error %d\n", ret);
522 return ret; 523 return ret;
523} 524}
525#endif /* 0 */
524 526
525int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, 527int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
526 int request_buf_len, u16 *reply_buf, int reply_buf_len) 528 int request_buf_len, u16 *reply_buf, int reply_buf_len)
@@ -593,7 +595,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
593 return 0; 595 return 0;
594} 596}
595 597
596int av7110_fw_query(struct av7110 *av7110, u16 tag, u16* buf, s16 length) 598static int av7110_fw_query(struct av7110 *av7110, u16 tag, u16* buf, s16 length)
597{ 599{
598 int ret; 600 int ret;
599 ret = av7110_fw_request(av7110, &tag, 0, buf, length); 601 ret = av7110_fw_request(av7110, &tag, 0, buf, length);
@@ -617,7 +619,7 @@ int av7110_firmversion(struct av7110 *av7110)
617 619
618 if (av7110_fw_query(av7110, tag, buf, 16)) { 620 if (av7110_fw_query(av7110, tag, buf, 16)) {
619 printk("dvb-ttpci: failed to boot firmware @ card %d\n", 621 printk("dvb-ttpci: failed to boot firmware @ card %d\n",
620 av7110->dvb_adapter->num); 622 av7110->dvb_adapter.num);
621 return -EIO; 623 return -EIO;
622 } 624 }
623 625
@@ -628,16 +630,16 @@ int av7110_firmversion(struct av7110 *av7110)
628 av7110->avtype = (buf[8] << 16) + buf[9]; 630 av7110->avtype = (buf[8] << 16) + buf[9];
629 631
630 printk("dvb-ttpci: info @ card %d: firm %08x, rtsl %08x, vid %08x, app %08x\n", 632 printk("dvb-ttpci: info @ card %d: firm %08x, rtsl %08x, vid %08x, app %08x\n",
631 av7110->dvb_adapter->num, av7110->arm_fw, 633 av7110->dvb_adapter.num, av7110->arm_fw,
632 av7110->arm_rtsl, av7110->arm_vid, av7110->arm_app); 634 av7110->arm_rtsl, av7110->arm_vid, av7110->arm_app);
633 635
634 /* print firmware capabilities */ 636 /* print firmware capabilities */
635 if (FW_CI_LL_SUPPORT(av7110->arm_app)) 637 if (FW_CI_LL_SUPPORT(av7110->arm_app))
636 printk("dvb-ttpci: firmware @ card %d supports CI link layer interface\n", 638 printk("dvb-ttpci: firmware @ card %d supports CI link layer interface\n",
637 av7110->dvb_adapter->num); 639 av7110->dvb_adapter.num);
638 else 640 else
639 printk("dvb-ttpci: no firmware support for CI link layer interface @ card %d\n", 641 printk("dvb-ttpci: no firmware support for CI link layer interface @ card %d\n",
640 av7110->dvb_adapter->num); 642 av7110->dvb_adapter.num);
641 643
642 return 0; 644 return 0;
643} 645}
diff --git a/drivers/media/dvb/ttpci/av7110_hw.h b/drivers/media/dvb/ttpci/av7110_hw.h
index bf901c624682..52061e17c6dd 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.h
+++ b/drivers/media/dvb/ttpci/av7110_hw.h
@@ -364,7 +364,6 @@ enum av7110_command_type {
364 364
365 365
366 366
367extern void av7110_reset_arm(struct av7110 *av7110);
368extern int av7110_bootarm(struct av7110 *av7110); 367extern int av7110_bootarm(struct av7110 *av7110);
369extern int av7110_firmversion(struct av7110 *av7110); 368extern int av7110_firmversion(struct av7110 *av7110);
370#define FW_CI_LL_SUPPORT(arm_app) ((arm_app) & 0x80000000) 369#define FW_CI_LL_SUPPORT(arm_app) ((arm_app) & 0x80000000)
@@ -373,12 +372,8 @@ extern int av7110_firmversion(struct av7110 *av7110);
373 372
374extern int av7110_wait_msgstate(struct av7110 *av7110, u16 flags); 373extern int av7110_wait_msgstate(struct av7110 *av7110, u16 flags);
375extern int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...); 374extern int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...);
376extern int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length);
377extern int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length);
378extern int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len);
379extern int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, 375extern int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
380 int request_buf_len, u16 *reply_buf, int reply_buf_len); 376 int request_buf_len, u16 *reply_buf, int reply_buf_len);
381extern int av7110_fw_query(struct av7110 *av7110, u16 tag, u16* Buff, s16 length);
382 377
383 378
384/* DEBI (saa7146 data extension bus interface) access */ 379/* DEBI (saa7146 data extension bus interface) access */
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c
index 6d2256f1e354..665cdb8a3f71 100644
--- a/drivers/media/dvb/ttpci/av7110_ir.c
+++ b/drivers/media/dvb/ttpci/av7110_ir.c
@@ -10,7 +10,7 @@
10 10
11#define UP_TIMEOUT (HZ/4) 11#define UP_TIMEOUT (HZ/4)
12 12
13/* enable ir debugging by or'ing av7110_debug with 16 */ 13/* enable ir debugging by or'ing debug with 16 */
14 14
15static int ir_initialized; 15static int ir_initialized;
16static struct input_dev input_dev; 16static struct input_dev input_dev;
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
index eb84fb08d95c..e65fc36e2ce8 100644
--- a/drivers/media/dvb/ttpci/av7110_v4l.c
+++ b/drivers/media/dvb/ttpci/av7110_v4l.c
@@ -46,13 +46,13 @@ int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val)
46 46
47 if (i2c_transfer(&av7110->i2c_adap, &msgs, 1) != 1) { 47 if (i2c_transfer(&av7110->i2c_adap, &msgs, 1) != 1) {
48 dprintk(1, "dvb-ttpci: failed @ card %d, %u = %u\n", 48 dprintk(1, "dvb-ttpci: failed @ card %d, %u = %u\n",
49 av7110->dvb_adapter->num, reg, val); 49 av7110->dvb_adapter.num, reg, val);
50 return -EIO; 50 return -EIO;
51 } 51 }
52 return 0; 52 return 0;
53} 53}
54 54
55int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val) 55static int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val)
56{ 56{
57 u8 msg1[3] = { dev, reg >> 8, reg & 0xff }; 57 u8 msg1[3] = { dev, reg >> 8, reg & 0xff };
58 u8 msg2[2]; 58 u8 msg2[2];
@@ -63,7 +63,7 @@ int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val)
63 63
64 if (i2c_transfer(&av7110->i2c_adap, &msgs[0], 2) != 2) { 64 if (i2c_transfer(&av7110->i2c_adap, &msgs[0], 2) != 2) {
65 dprintk(1, "dvb-ttpci: failed @ card %d, %u\n", 65 dprintk(1, "dvb-ttpci: failed @ card %d, %u\n",
66 av7110->dvb_adapter->num, reg); 66 av7110->dvb_adapter.num, reg);
67 return -EIO; 67 return -EIO;
68 } 68 }
69 *val = (msg2[0] << 8) | msg2[1]; 69 *val = (msg2[0] << 8) | msg2[1];
@@ -552,13 +552,13 @@ int av7110_init_analog_module(struct av7110 *av7110)
552 return -ENODEV; 552 return -ENODEV;
553 553
554 printk("dvb-ttpci: DVB-C analog module @ card %d detected, initializing MSP3400\n", 554 printk("dvb-ttpci: DVB-C analog module @ card %d detected, initializing MSP3400\n",
555 av7110->dvb_adapter->num); 555 av7110->dvb_adapter.num);
556 av7110->adac_type = DVB_ADAC_MSP; 556 av7110->adac_type = DVB_ADAC_MSP;
557 msleep(100); // the probing above resets the msp... 557 msleep(100); // the probing above resets the msp...
558 msp_readreg(av7110, MSP_RD_DSP, 0x001e, &version1); 558 msp_readreg(av7110, MSP_RD_DSP, 0x001e, &version1);
559 msp_readreg(av7110, MSP_RD_DSP, 0x001f, &version2); 559 msp_readreg(av7110, MSP_RD_DSP, 0x001f, &version2);
560 dprintk(1, "dvb-ttpci: @ card %d MSP3400 version 0x%04x 0x%04x\n", 560 dprintk(1, "dvb-ttpci: @ card %d MSP3400 version 0x%04x 0x%04x\n",
561 av7110->dvb_adapter->num, version1, version2); 561 av7110->dvb_adapter.num, version1, version2);
562 msp_writereg(av7110, MSP_WR_DSP, 0x0013, 0x0c00); 562 msp_writereg(av7110, MSP_WR_DSP, 0x0013, 0x0c00);
563 msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x7f00); // loudspeaker + headphone 563 msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x7f00); // loudspeaker + headphone
564 msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0220); // loudspeaker source 564 msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0220); // loudspeaker source
@@ -596,7 +596,7 @@ int av7110_init_analog_module(struct av7110 *av7110)
596 /* init the saa7113 */ 596 /* init the saa7113 */
597 while (*i != 0xff) { 597 while (*i != 0xff) {
598 if (i2c_writereg(av7110, 0x48, i[0], i[1]) != 1) { 598 if (i2c_writereg(av7110, 0x48, i[0], i[1]) != 1) {
599 dprintk(1, "saa7113 initialization failed @ card %d", av7110->dvb_adapter->num); 599 dprintk(1, "saa7113 initialization failed @ card %d", av7110->dvb_adapter.num);
600 break; 600 break;
601 } 601 }
602 i += 2; 602 i += 2;
@@ -726,11 +726,11 @@ static int std_callback(struct saa7146_dev* dev, struct saa7146_standard *std)
726{ 726{
727 struct av7110 *av7110 = (struct av7110*) dev->ext_priv; 727 struct av7110 *av7110 = (struct av7110*) dev->ext_priv;
728 728
729 if (std->id == V4L2_STD_PAL) { 729 if (std->id & V4L2_STD_PAL) {
730 av7110->vidmode = VIDEO_MODE_PAL; 730 av7110->vidmode = VIDEO_MODE_PAL;
731 av7110_set_vidmode(av7110, av7110->vidmode); 731 av7110_set_vidmode(av7110, av7110->vidmode);
732 } 732 }
733 else if (std->id == V4L2_STD_NTSC) { 733 else if (std->id & V4L2_STD_NTSC) {
734 av7110->vidmode = VIDEO_MODE_NTSC; 734 av7110->vidmode = VIDEO_MODE_NTSC;
735 av7110_set_vidmode(av7110, av7110->vidmode); 735 av7110_set_vidmode(av7110, av7110->vidmode);
736 } 736 }
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 14e963206b89..6e0f5d307c52 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -59,8 +59,12 @@ struct budget_av {
59 struct dvb_ca_en50221 ca; 59 struct dvb_ca_en50221 ca;
60}; 60};
61 61
62static int enable_ci = 0; 62/* GPIO CI Connections:
63 63 * 0 - Vcc/Reset (Reset is controlled by capacitor)
64 * 1 - Attribute Memory
65 * 2 - Card Enable (Active Low)
66 * 3 - Card Detect
67 */
64 68
65/**************************************************************************** 69/****************************************************************************
66 * INITIALIZATION 70 * INITIALIZATION
@@ -188,22 +192,35 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
188{ 192{
189 struct budget_av *budget_av = (struct budget_av *) ca->data; 193 struct budget_av *budget_av = (struct budget_av *) ca->data;
190 struct saa7146_dev *saa = budget_av->budget.dev; 194 struct saa7146_dev *saa = budget_av->budget.dev;
191 int max = 20; 195 int timeout = 50; // 5 seconds (4.4.6 Ready)
192 196
193 if (slot != 0) 197 if (slot != 0)
194 return -EINVAL; 198 return -EINVAL;
195 199
196 dprintk(1, "ciintf_slot_reset\n"); 200 dprintk(1, "ciintf_slot_reset\n");
197 201
198 /* reset the card */ 202 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
199 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
200 msleep(100);
201 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
202 203
203 while (--max > 0 && ciintf_read_attribute_mem(ca, slot, 0) != 0x1d) 204 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
205 msleep(2);
206 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); /* Vcc on */
207 msleep(20); /* 20 ms Vcc settling time */
208
209 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO); /* enable card */
210
211 /* This should have been based on pin 16 READY of the pcmcia port,
212 * but AFAICS it is not routed to the saa7146 */
213 while (--timeout > 0 && ciintf_read_attribute_mem(ca, slot, 0) != 0x1d)
204 msleep(100); 214 msleep(100);
205 215
206 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB); 216 if (timeout <= 0)
217 {
218 printk(KERN_ERR "budget-av: cam reset failed (timeout).\n");
219 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
220 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
221 return -ETIMEDOUT;
222 }
223
207 return 0; 224 return 0;
208} 225}
209 226
@@ -240,7 +257,6 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open
240{ 257{
241 struct budget_av *budget_av = (struct budget_av *) ca->data; 258 struct budget_av *budget_av = (struct budget_av *) ca->data;
242 struct saa7146_dev *saa = budget_av->budget.dev; 259 struct saa7146_dev *saa = budget_av->budget.dev;
243 int cam = 0;
244 260
245 if (slot != 0) 261 if (slot != 0)
246 return -EINVAL; 262 return -EINVAL;
@@ -248,15 +264,21 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open
248 if (!budget_av->slot_status) { 264 if (!budget_av->slot_status) {
249 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); 265 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
250 udelay(1); 266 udelay(1);
251 cam = saa7146_read(saa, PSR) & MASK_06; 267 if (saa7146_read(saa, PSR) & MASK_06)
252 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO); 268 {
253 269 printk(KERN_INFO "budget-av: cam inserted\n");
254 if (cam)
255 budget_av->slot_status = 1; 270 budget_av->slot_status = 1;
271 }
272 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
256 } else if (!open) { 273 } else if (!open) {
257 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO); 274 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
258 if (ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1) == -ETIMEDOUT) 275 if (ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1) == -ETIMEDOUT)
276 {
277 printk(KERN_INFO "budget-av: cam ejected\n");
278 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
279 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
259 budget_av->slot_status = 0; 280 budget_av->slot_status = 0;
281 }
260 } 282 }
261 283
262 if (budget_av->slot_status == 1) 284 if (budget_av->slot_status == 1)
@@ -272,17 +294,11 @@ static int ciintf_init(struct budget_av *budget_av)
272 294
273 memset(&budget_av->ca, 0, sizeof(struct dvb_ca_en50221)); 295 memset(&budget_av->ca, 0, sizeof(struct dvb_ca_en50221));
274 296
275 /* setup GPIOs */ 297 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
276 saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI); 298 saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO);
277 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO); 299 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO);
278 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO); 300 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
279 301
280 /* Reset the card */
281 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
282 msleep(50);
283 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
284 msleep(100);
285
286 /* Enable DEBI pins */ 302 /* Enable DEBI pins */
287 saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800); 303 saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800);
288 304
@@ -297,13 +313,14 @@ static int ciintf_init(struct budget_av *budget_av)
297 budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable; 313 budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable;
298 budget_av->ca.poll_slot_status = ciintf_poll_slot_status; 314 budget_av->ca.poll_slot_status = ciintf_poll_slot_status;
299 budget_av->ca.data = budget_av; 315 budget_av->ca.data = budget_av;
300 if ((result = dvb_ca_en50221_init(budget_av->budget.dvb_adapter, 316
317 if ((result = dvb_ca_en50221_init(&budget_av->budget.dvb_adapter,
301 &budget_av->ca, 0, 1)) != 0) { 318 &budget_av->ca, 0, 1)) != 0) {
302 printk("budget_av: CI interface detected, but initialisation failed.\n"); 319 printk(KERN_ERR "budget-av: ci initialisation failed.\n");
303 goto error; 320 goto error;
304 } 321 }
305 // success! 322
306 printk("ciintf_init: CI interface initialised\n"); 323 printk(KERN_INFO "budget-av: ci interface initialised.\n");
307 budget_av->budget.ci_present = 1; 324 budget_av->budget.ci_present = 1;
308 return 0; 325 return 0;
309 326
@@ -361,8 +378,12 @@ static const u8 saa7113_tab[] = {
361static int saa7113_init(struct budget_av *budget_av) 378static int saa7113_init(struct budget_av *budget_av)
362{ 379{
363 struct budget *budget = &budget_av->budget; 380 struct budget *budget = &budget_av->budget;
381 struct saa7146_dev *saa = budget->dev;
364 const u8 *data = saa7113_tab; 382 const u8 *data = saa7113_tab;
365 383
384 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
385 msleep(200);
386
366 if (i2c_writereg(&budget->i2c_adap, 0x4a, 0x01, 0x08) != 1) { 387 if (i2c_writereg(&budget->i2c_adap, 0x4a, 0x01, 0x08) != 1) {
367 dprintk(1, "saa7113 not found on KNC card\n"); 388 dprintk(1, "saa7113 not found on KNC card\n");
368 return -ENODEV; 389 return -ENODEV;
@@ -697,75 +718,90 @@ static u8 read_pwm(struct budget_av *budget_av)
697 return pwm; 718 return pwm;
698} 719}
699 720
721#define SUBID_DVBS_KNC1 0x0010
722#define SUBID_DVBS_KNC1_PLUS 0x0011
723#define SUBID_DVBS_TYPHOON 0x4f56
724#define SUBID_DVBS_CINERGY1200 0x1154
725
726#define SUBID_DVBC_KNC1 0x0020
727#define SUBID_DVBC_KNC1_PLUS 0x0021
728#define SUBID_DVBC_CINERGY1200 0x1156
729
730#define SUBID_DVBT_KNC1_PLUS 0x0031
731#define SUBID_DVBT_KNC1 0x0030
732#define SUBID_DVBT_CINERGY1200 0x1157
700 733
701static void frontend_init(struct budget_av *budget_av) 734static void frontend_init(struct budget_av *budget_av)
702{ 735{
703 switch (budget_av->budget.dev->pci->subsystem_device) { 736 struct saa7146_dev * saa = budget_av->budget.dev;
704 case 0x4f56: // Typhoon/KNC1 DVB-S budget (stv0299/Philips SU1278(tsa5059)) 737 struct dvb_frontend * fe = NULL;
705 budget_av->budget.dvb_frontend = 738
706 stv0299_attach(&typhoon_config, &budget_av->budget.i2c_adap); 739 switch (saa->pci->subsystem_device) {
707 if (budget_av->budget.dvb_frontend != NULL) { 740 case SUBID_DVBS_KNC1_PLUS:
741 case SUBID_DVBC_KNC1_PLUS:
742 case SUBID_DVBT_KNC1_PLUS:
743 // Enable / PowerON Frontend
744 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI);
708 break; 745 break;
709 } 746 }
747
748 switch (saa->pci->subsystem_device) {
749
750 case SUBID_DVBS_KNC1:
751 case SUBID_DVBS_KNC1_PLUS:
752 case SUBID_DVBS_TYPHOON:
753 fe = stv0299_attach(&typhoon_config,
754 &budget_av->budget.i2c_adap);
710 break; 755 break;
711 756
712 case 0x0020: // KNC1 DVB-C budget (tda10021/Philips CU1216(tua6034)) 757 case SUBID_DVBS_CINERGY1200:
713 budget_av->budget.dvb_frontend = 758 fe = stv0299_attach(&cinergy_1200s_config,
714 tda10021_attach(&philips_cu1216_config, 759 &budget_av->budget.i2c_adap);
715 &budget_av->budget.i2c_adap, read_pwm(budget_av));
716 if (budget_av->budget.dvb_frontend != NULL) {
717 break;
718 }
719 break; 760 break;
720 761
721 case 0x0030: // KNC1 DVB-T budget (tda10046/Philips TU1216(tda6651tt)) 762 case SUBID_DVBC_KNC1:
722 budget_av->budget.dvb_frontend = 763 case SUBID_DVBC_KNC1_PLUS:
723 tda10046_attach(&philips_tu1216_config, &budget_av->budget.i2c_adap); 764 fe = tda10021_attach(&philips_cu1216_config,
724 if (budget_av->budget.dvb_frontend != NULL) { 765 &budget_av->budget.i2c_adap,
725 break; 766 read_pwm(budget_av));
726 }
727 break; 767 break;
728 768
729 case 0x1154: // TerraTec Cinergy 1200 DVB-S (stv0299/Philips SU1278(tsa5059)) 769 case SUBID_DVBT_KNC1:
730 budget_av->budget.dvb_frontend = 770 case SUBID_DVBT_KNC1_PLUS:
731 stv0299_attach(&cinergy_1200s_config, &budget_av->budget.i2c_adap); 771 fe = tda10046_attach(&philips_tu1216_config,
732 if (budget_av->budget.dvb_frontend != NULL) { 772 &budget_av->budget.i2c_adap);
733 break;
734 }
735 break; 773 break;
736 774
737 case 0x1156: // Terratec Cinergy 1200 DVB-C (tda10021/Philips CU1216(tua6034)) 775 case SUBID_DVBC_CINERGY1200:
738 budget_av->budget.dvb_frontend = 776 fe = tda10021_attach(&philips_cu1216_config,
739 tda10021_attach(&philips_cu1216_config, 777 &budget_av->budget.i2c_adap,
740 &budget_av->budget.i2c_adap, read_pwm(budget_av)); 778 read_pwm(budget_av));
741 if (budget_av->budget.dvb_frontend) {
742 break;
743 }
744 break; 779 break;
745 780
746 case 0x1157: // Terratec Cinergy 1200 DVB-T (tda10046/Philips TU1216(tda6651tt)) 781 case SUBID_DVBT_CINERGY1200:
747 budget_av->budget.dvb_frontend = 782 fe = tda10046_attach(&philips_tu1216_config,
748 tda10046_attach(&philips_tu1216_config, &budget_av->budget.i2c_adap); 783 &budget_av->budget.i2c_adap);
749 if (budget_av->budget.dvb_frontend) {
750 break;
751 }
752 break; 784 break;
753 } 785 }
754 786
755 if (budget_av->budget.dvb_frontend == NULL) { 787 if (fe == NULL) {
756 printk("budget_av: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n", 788 printk(KERN_ERR "budget-av: A frontend driver was not found "
757 budget_av->budget.dev->pci->vendor, 789 "for device %04x/%04x subsystem %04x/%04x\n",
758 budget_av->budget.dev->pci->device, 790 saa->pci->vendor,
759 budget_av->budget.dev->pci->subsystem_vendor, 791 saa->pci->device,
760 budget_av->budget.dev->pci->subsystem_device); 792 saa->pci->subsystem_vendor,
761 } else { 793 saa->pci->subsystem_device);
762 if (dvb_register_frontend 794 return;
763 (budget_av->budget.dvb_adapter, budget_av->budget.dvb_frontend)) { 795 }
764 printk("budget-av: Frontend registration failed!\n"); 796
765 if (budget_av->budget.dvb_frontend->ops->release) 797 budget_av->budget.dvb_frontend = fe;
766 budget_av->budget.dvb_frontend->ops->release(budget_av->budget.dvb_frontend); 798
767 budget_av->budget.dvb_frontend = NULL; 799 if (dvb_register_frontend(&budget_av->budget.dvb_adapter,
768 } 800 budget_av->budget.dvb_frontend)) {
801 printk(KERN_ERR "budget-av: Frontend registration failed!\n");
802 if (budget_av->budget.dvb_frontend->ops->release)
803 budget_av->budget.dvb_frontend->ops->release(budget_av->budget.dvb_frontend);
804 budget_av->budget.dvb_frontend = NULL;
769 } 805 }
770} 806}
771 807
@@ -822,6 +858,7 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
822 858
823 memset(budget_av, 0, sizeof(struct budget_av)); 859 memset(budget_av, 0, sizeof(struct budget_av));
824 860
861 budget_av->has_saa7113 = 0;
825 budget_av->budget.ci_present = 0; 862 budget_av->budget.ci_present = 0;
826 863
827 dev->ext_priv = budget_av; 864 dev->ext_priv = budget_av;
@@ -836,10 +873,7 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
836 saa7146_write(dev, DD1_INIT, 0x07000600); 873 saa7146_write(dev, DD1_INIT, 0x07000600);
837 saa7146_write(dev, MC2, MASK_09 | MASK_25 | MASK_10 | MASK_26); 874 saa7146_write(dev, MC2, MASK_09 | MASK_25 | MASK_10 | MASK_26);
838 875
839 saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTHI); 876 if (saa7113_init(budget_av) == 0) {
840 msleep(500);
841
842 if (0 == saa7113_init(budget_av)) {
843 budget_av->has_saa7113 = 1; 877 budget_av->has_saa7113 = 1;
844 878
845 if (0 != saa7146_vv_init(dev, &vv_data)) { 879 if (0 != saa7146_vv_init(dev, &vv_data)) {
@@ -860,31 +894,26 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
860 894
861 saa7113_setinput(budget_av, 0); 895 saa7113_setinput(budget_av, 0);
862 } else { 896 } else {
863 budget_av->has_saa7113 = 0; 897 ciintf_init(budget_av);
864
865 saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO);
866 } 898 }
867 899
868 /* fixme: find some sane values here... */ 900 /* fixme: find some sane values here... */
869 saa7146_write(dev, PCI_BT_V1, 0x1c00101f); 901 saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
870 902
871 mac = budget_av->budget.dvb_adapter->proposed_mac; 903 mac = budget_av->budget.dvb_adapter.proposed_mac;
872 if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) { 904 if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) {
873 printk("KNC1-%d: Could not read MAC from KNC1 card\n", 905 printk(KERN_ERR "KNC1-%d: Could not read MAC from KNC1 card\n",
874 budget_av->budget.dvb_adapter->num); 906 budget_av->budget.dvb_adapter.num);
875 memset(mac, 0, 6); 907 memset(mac, 0, 6);
876 } else { 908 } else {
877 printk("KNC1-%d: MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", 909 printk(KERN_INFO "KNC1-%d: MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
878 budget_av->budget.dvb_adapter->num, 910 budget_av->budget.dvb_adapter.num,
879 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); 911 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
880 } 912 }
881 913
882 budget_av->budget.dvb_adapter->priv = budget_av; 914 budget_av->budget.dvb_adapter.priv = budget_av;
883 frontend_init(budget_av); 915 frontend_init(budget_av);
884 916
885 if (enable_ci)
886 ciintf_init(budget_av);
887
888 return 0; 917 return 0;
889} 918}
890 919
@@ -963,14 +992,21 @@ static struct saa7146_extension budget_extension;
963MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S); 992MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S);
964MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C); 993MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C);
965MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T); 994MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T);
995MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP);
996MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP);
997MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP);
966MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S); 998MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
967MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C); 999MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C);
968MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T); 1000MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T);
969 1001
970static struct pci_device_id pci_tbl[] = { 1002static struct pci_device_id pci_tbl[] = {
971 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56), 1003 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56),
1004 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
1005 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
972 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020), 1006 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
1007 MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),
973 MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030), 1008 MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030),
1009 MAKE_EXTENSION_PCI(knc1tp, 0x1894, 0x0031),
974 MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154), 1010 MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154),
975 MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156), 1011 MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156),
976 MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157), 1012 MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157),
@@ -1010,5 +1046,3 @@ MODULE_LICENSE("GPL");
1010MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others"); 1046MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
1011MODULE_DESCRIPTION("driver for the SAA7146 based so-called " 1047MODULE_DESCRIPTION("driver for the SAA7146 based so-called "
1012 "budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)"); 1048 "budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)");
1013module_param_named(enable_ci, enable_ci, int, 0644);
1014MODULE_PARM_DESC(enable_ci, "Turn on/off CI module (default:off).");
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 521111be3558..dce116111376 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -395,7 +395,7 @@ static int ciintf_init(struct budget_ci *budget_ci)
395 budget_ci->ca.slot_shutdown = ciintf_slot_shutdown; 395 budget_ci->ca.slot_shutdown = ciintf_slot_shutdown;
396 budget_ci->ca.slot_ts_enable = ciintf_slot_ts_enable; 396 budget_ci->ca.slot_ts_enable = ciintf_slot_ts_enable;
397 budget_ci->ca.data = budget_ci; 397 budget_ci->ca.data = budget_ci;
398 if ((result = dvb_ca_en50221_init(budget_ci->budget.dvb_adapter, 398 if ((result = dvb_ca_en50221_init(&budget_ci->budget.dvb_adapter,
399 &budget_ci->ca, 399 &budget_ci->ca,
400 DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE | 400 DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE |
401 DVB_CA_EN50221_FLAG_IRQ_FR | 401 DVB_CA_EN50221_FLAG_IRQ_FR |
@@ -881,7 +881,7 @@ static void frontend_init(struct budget_ci *budget_ci)
881 budget_ci->budget.dev->pci->subsystem_device); 881 budget_ci->budget.dev->pci->subsystem_device);
882 } else { 882 } else {
883 if (dvb_register_frontend 883 if (dvb_register_frontend
884 (budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) { 884 (&budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) {
885 printk("budget-ci: Frontend registration failed!\n"); 885 printk("budget-ci: Frontend registration failed!\n");
886 if (budget_ci->budget.dvb_frontend->ops->release) 886 if (budget_ci->budget.dvb_frontend->ops->release)
887 budget_ci->budget.dvb_frontend->ops->release(budget_ci->budget.dvb_frontend); 887 budget_ci->budget.dvb_frontend->ops->release(budget_ci->budget.dvb_frontend);
@@ -916,7 +916,7 @@ static int budget_ci_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
916 916
917 ciintf_init(budget_ci); 917 ciintf_init(budget_ci);
918 918
919 budget_ci->budget.dvb_adapter->priv = budget_ci; 919 budget_ci->budget.dvb_adapter.priv = budget_ci;
920 frontend_init(budget_ci); 920 frontend_init(budget_ci);
921 921
922 return 0; 922 return 0;
diff --git a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c
index 93a9b40917e4..0498a055a4cd 100644
--- a/drivers/media/dvb/ttpci/budget-core.c
+++ b/drivers/media/dvb/ttpci/budget-core.c
@@ -298,7 +298,7 @@ static int budget_register(struct budget *budget)
298 budget->dmxdev.demux = &dvbdemux->dmx; 298 budget->dmxdev.demux = &dvbdemux->dmx;
299 budget->dmxdev.capabilities = 0; 299 budget->dmxdev.capabilities = 0;
300 300
301 dvb_dmxdev_init(&budget->dmxdev, budget->dvb_adapter); 301 dvb_dmxdev_init(&budget->dmxdev, &budget->dvb_adapter);
302 302
303 budget->hw_frontend.source = DMX_FRONTEND_0; 303 budget->hw_frontend.source = DMX_FRONTEND_0;
304 304
@@ -316,7 +316,7 @@ static int budget_register(struct budget *budget)
316 if (ret < 0) 316 if (ret < 0)
317 return ret; 317 return ret;
318 318
319 dvb_net_init(budget->dvb_adapter, &budget->dvb_net, &dvbdemux->dmx); 319 dvb_net_init(&budget->dvb_adapter, &budget->dvb_net, &dvbdemux->dmx);
320 320
321 return 0; 321 return 0;
322} 322}
@@ -385,11 +385,11 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
385 strcpy(budget->i2c_adap.name, budget->card->name); 385 strcpy(budget->i2c_adap.name, budget->card->name);
386 386
387 if (i2c_add_adapter(&budget->i2c_adap) < 0) { 387 if (i2c_add_adapter(&budget->i2c_adap) < 0) {
388 dvb_unregister_adapter(budget->dvb_adapter); 388 dvb_unregister_adapter(&budget->dvb_adapter);
389 return -ENOMEM; 389 return -ENOMEM;
390 } 390 }
391 391
392 ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter->proposed_mac); 392 ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac);
393 393
394 if (NULL == 394 if (NULL ==
395 (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, length, &budget->pt))) { 395 (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, length, &budget->pt))) {
@@ -417,7 +417,7 @@ err:
417 417
418 vfree(budget->grabbing); 418 vfree(budget->grabbing);
419 419
420 dvb_unregister_adapter(budget->dvb_adapter); 420 dvb_unregister_adapter(&budget->dvb_adapter);
421 421
422 return ret; 422 return ret;
423} 423}
@@ -432,7 +432,7 @@ int ttpci_budget_deinit(struct budget *budget)
432 432
433 i2c_del_adapter(&budget->i2c_adap); 433 i2c_del_adapter(&budget->i2c_adap);
434 434
435 dvb_unregister_adapter(budget->dvb_adapter); 435 dvb_unregister_adapter(&budget->dvb_adapter);
436 436
437 tasklet_kill(&budget->vpe_tasklet); 437 tasklet_kill(&budget->vpe_tasklet);
438 438
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c
index 5d524a4f213f..8142e26b47f5 100644
--- a/drivers/media/dvb/ttpci/budget-patch.c
+++ b/drivers/media/dvb/ttpci/budget-patch.c
@@ -453,7 +453,7 @@ static void frontend_init(struct budget_patch* budget)
453 budget->dev->pci->subsystem_vendor, 453 budget->dev->pci->subsystem_vendor,
454 budget->dev->pci->subsystem_device); 454 budget->dev->pci->subsystem_device);
455 } else { 455 } else {
456 if (dvb_register_frontend(budget->dvb_adapter, budget->dvb_frontend)) { 456 if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) {
457 printk("budget-av: Frontend registration failed!\n"); 457 printk("budget-av: Frontend registration failed!\n");
458 if (budget->dvb_frontend->ops->release) 458 if (budget->dvb_frontend->ops->release)
459 budget->dvb_frontend->ops->release(budget->dvb_frontend); 459 budget->dvb_frontend->ops->release(budget->dvb_frontend);
@@ -702,7 +702,7 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
702 702
703 dev->ext_priv = budget; 703 dev->ext_priv = budget;
704 704
705 budget->dvb_adapter->priv = budget; 705 budget->dvb_adapter.priv = budget;
706 frontend_init(budget); 706 frontend_init(budget);
707 707
708 return 0; 708 return 0;
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index 5e6a10f4ad95..083fd44e5f90 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -468,7 +468,7 @@ static void frontend_init(struct budget *budget)
468 budget->dev->pci->subsystem_vendor, 468 budget->dev->pci->subsystem_vendor,
469 budget->dev->pci->subsystem_device); 469 budget->dev->pci->subsystem_device);
470 } else { 470 } else {
471 if (dvb_register_frontend(budget->dvb_adapter, budget->dvb_frontend)) { 471 if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) {
472 printk("budget: Frontend registration failed!\n"); 472 printk("budget: Frontend registration failed!\n");
473 if (budget->dvb_frontend->ops->release) 473 if (budget->dvb_frontend->ops->release)
474 budget->dvb_frontend->ops->release(budget->dvb_frontend); 474 budget->dvb_frontend->ops->release(budget->dvb_frontend);
@@ -497,7 +497,7 @@ static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_
497 return err; 497 return err;
498 } 498 }
499 499
500 budget->dvb_adapter->priv = budget; 500 budget->dvb_adapter.priv = budget;
501 frontend_init(budget); 501 frontend_init(budget);
502 502
503 return 0; 503 return 0;
diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h
index 10bd41f0363b..c6ef496ba70a 100644
--- a/drivers/media/dvb/ttpci/budget.h
+++ b/drivers/media/dvb/ttpci/budget.h
@@ -64,7 +64,7 @@ struct budget {
64 64
65 spinlock_t debilock; 65 spinlock_t debilock;
66 66
67 struct dvb_adapter *dvb_adapter; 67 struct dvb_adapter dvb_adapter;
68 struct dvb_frontend *dvb_frontend; 68 struct dvb_frontend *dvb_frontend;
69 void *priv; 69 void *priv;
70}; 70};
@@ -92,6 +92,9 @@ static struct saa7146_pci_extension_data x_var = { \
92#define BUDGET_KNC1S 8 92#define BUDGET_KNC1S 8
93#define BUDGET_KNC1C 9 93#define BUDGET_KNC1C 9
94#define BUDGET_KNC1T 10 94#define BUDGET_KNC1T 10
95#define BUDGET_KNC1SP 11
96#define BUDGET_KNC1CP 12
97#define BUDGET_KNC1TP 13
95 98
96#define BUDGET_VIDEO_PORTA 0 99#define BUDGET_VIDEO_PORTA 0
97#define BUDGET_VIDEO_PORTB 1 100#define BUDGET_VIDEO_PORTB 1
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 4c046ece883a..afa0e7a0e506 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -84,7 +84,7 @@ struct ttusb {
84 struct semaphore semi2c; 84 struct semaphore semi2c;
85 struct semaphore semusb; 85 struct semaphore semusb;
86 86
87 struct dvb_adapter *adapter; 87 struct dvb_adapter adapter;
88 struct usb_device *dev; 88 struct usb_device *dev;
89 89
90 struct i2c_adapter i2c_adap; 90 struct i2c_adapter i2c_adap;
@@ -1065,7 +1065,7 @@ static int alps_tdmb7_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param
1065 return 0; 1065 return 0;
1066} 1066}
1067 1067
1068struct cx22700_config alps_tdmb7_config = { 1068static struct cx22700_config alps_tdmb7_config = {
1069 .demod_address = 0x43, 1069 .demod_address = 0x43,
1070 .pll_set = alps_tdmb7_pll_set, 1070 .pll_set = alps_tdmb7_pll_set,
1071}; 1071};
@@ -1412,7 +1412,7 @@ static void frontend_init(struct ttusb* ttusb)
1412 le16_to_cpu(ttusb->dev->descriptor.idVendor), 1412 le16_to_cpu(ttusb->dev->descriptor.idVendor),
1413 le16_to_cpu(ttusb->dev->descriptor.idProduct)); 1413 le16_to_cpu(ttusb->dev->descriptor.idProduct));
1414 } else { 1414 } else {
1415 if (dvb_register_frontend(ttusb->adapter, ttusb->fe)) { 1415 if (dvb_register_frontend(&ttusb->adapter, ttusb->fe)) {
1416 printk("dvb-ttusb-budget: Frontend registration failed!\n"); 1416 printk("dvb-ttusb-budget: Frontend registration failed!\n");
1417 if (ttusb->fe->ops->release) 1417 if (ttusb->fe->ops->release)
1418 ttusb->fe->ops->release(ttusb->fe); 1418 ttusb->fe->ops->release(ttusb->fe);
@@ -1462,7 +1462,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1462 up(&ttusb->semi2c); 1462 up(&ttusb->semi2c);
1463 1463
1464 dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE); 1464 dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE);
1465 ttusb->adapter->priv = ttusb; 1465 ttusb->adapter.priv = ttusb;
1466 1466
1467 /* i2c */ 1467 /* i2c */
1468 memset(&ttusb->i2c_adap, 0, sizeof(struct i2c_adapter)); 1468 memset(&ttusb->i2c_adap, 0, sizeof(struct i2c_adapter));
@@ -1481,7 +1481,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1481 1481
1482 result = i2c_add_adapter(&ttusb->i2c_adap); 1482 result = i2c_add_adapter(&ttusb->i2c_adap);
1483 if (result) { 1483 if (result) {
1484 dvb_unregister_adapter (ttusb->adapter); 1484 dvb_unregister_adapter (&ttusb->adapter);
1485 return result; 1485 return result;
1486 } 1486 }
1487 1487
@@ -1503,7 +1503,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1503 if ((result = dvb_dmx_init(&ttusb->dvb_demux)) < 0) { 1503 if ((result = dvb_dmx_init(&ttusb->dvb_demux)) < 0) {
1504 printk("ttusb_dvb: dvb_dmx_init failed (errno = %d)\n", result); 1504 printk("ttusb_dvb: dvb_dmx_init failed (errno = %d)\n", result);
1505 i2c_del_adapter(&ttusb->i2c_adap); 1505 i2c_del_adapter(&ttusb->i2c_adap);
1506 dvb_unregister_adapter (ttusb->adapter); 1506 dvb_unregister_adapter (&ttusb->adapter);
1507 return -ENODEV; 1507 return -ENODEV;
1508 } 1508 }
1509//FIXME dmxdev (nur WAS?) 1509//FIXME dmxdev (nur WAS?)
@@ -1511,21 +1511,21 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1511 ttusb->dmxdev.demux = &ttusb->dvb_demux.dmx; 1511 ttusb->dmxdev.demux = &ttusb->dvb_demux.dmx;
1512 ttusb->dmxdev.capabilities = 0; 1512 ttusb->dmxdev.capabilities = 0;
1513 1513
1514 if ((result = dvb_dmxdev_init(&ttusb->dmxdev, ttusb->adapter)) < 0) { 1514 if ((result = dvb_dmxdev_init(&ttusb->dmxdev, &ttusb->adapter)) < 0) {
1515 printk("ttusb_dvb: dvb_dmxdev_init failed (errno = %d)\n", 1515 printk("ttusb_dvb: dvb_dmxdev_init failed (errno = %d)\n",
1516 result); 1516 result);
1517 dvb_dmx_release(&ttusb->dvb_demux); 1517 dvb_dmx_release(&ttusb->dvb_demux);
1518 i2c_del_adapter(&ttusb->i2c_adap); 1518 i2c_del_adapter(&ttusb->i2c_adap);
1519 dvb_unregister_adapter (ttusb->adapter); 1519 dvb_unregister_adapter (&ttusb->adapter);
1520 return -ENODEV; 1520 return -ENODEV;
1521 } 1521 }
1522 1522
1523 if (dvb_net_init(ttusb->adapter, &ttusb->dvbnet, &ttusb->dvb_demux.dmx)) { 1523 if (dvb_net_init(&ttusb->adapter, &ttusb->dvbnet, &ttusb->dvb_demux.dmx)) {
1524 printk("ttusb_dvb: dvb_net_init failed!\n"); 1524 printk("ttusb_dvb: dvb_net_init failed!\n");
1525 dvb_dmxdev_release(&ttusb->dmxdev); 1525 dvb_dmxdev_release(&ttusb->dmxdev);
1526 dvb_dmx_release(&ttusb->dvb_demux); 1526 dvb_dmx_release(&ttusb->dvb_demux);
1527 i2c_del_adapter(&ttusb->i2c_adap); 1527 i2c_del_adapter(&ttusb->i2c_adap);
1528 dvb_unregister_adapter (ttusb->adapter); 1528 dvb_unregister_adapter (&ttusb->adapter);
1529 return -ENODEV; 1529 return -ENODEV;
1530 } 1530 }
1531 1531
@@ -1559,7 +1559,7 @@ static void ttusb_disconnect(struct usb_interface *intf)
1559 dvb_dmx_release(&ttusb->dvb_demux); 1559 dvb_dmx_release(&ttusb->dvb_demux);
1560 if (ttusb->fe != NULL) dvb_unregister_frontend(ttusb->fe); 1560 if (ttusb->fe != NULL) dvb_unregister_frontend(ttusb->fe);
1561 i2c_del_adapter(&ttusb->i2c_adap); 1561 i2c_del_adapter(&ttusb->i2c_adap);
1562 dvb_unregister_adapter(ttusb->adapter); 1562 dvb_unregister_adapter(&ttusb->adapter);
1563 1563
1564 ttusb_free_iso_urbs(ttusb); 1564 ttusb_free_iso_urbs(ttusb);
1565 1565
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index 64e771bd8907..505bdaff5a7e 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -98,7 +98,7 @@ struct ttusb_dec {
98 int can_playback; 98 int can_playback;
99 99
100 /* DVB bits */ 100 /* DVB bits */
101 struct dvb_adapter *adapter; 101 struct dvb_adapter adapter;
102 struct dmxdev dmxdev; 102 struct dmxdev dmxdev;
103 struct dvb_demux demux; 103 struct dvb_demux demux;
104 struct dmx_frontend frontend; 104 struct dmx_frontend frontend;
@@ -1435,7 +1435,7 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec)
1435 printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__, 1435 printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__,
1436 result); 1436 result);
1437 1437
1438 dvb_unregister_adapter(dec->adapter); 1438 dvb_unregister_adapter(&dec->adapter);
1439 1439
1440 return result; 1440 return result;
1441 } 1441 }
@@ -1444,12 +1444,12 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec)
1444 dec->dmxdev.demux = &dec->demux.dmx; 1444 dec->dmxdev.demux = &dec->demux.dmx;
1445 dec->dmxdev.capabilities = 0; 1445 dec->dmxdev.capabilities = 0;
1446 1446
1447 if ((result = dvb_dmxdev_init(&dec->dmxdev, dec->adapter)) < 0) { 1447 if ((result = dvb_dmxdev_init(&dec->dmxdev, &dec->adapter)) < 0) {
1448 printk("%s: dvb_dmxdev_init failed: error %d\n", 1448 printk("%s: dvb_dmxdev_init failed: error %d\n",
1449 __FUNCTION__, result); 1449 __FUNCTION__, result);
1450 1450
1451 dvb_dmx_release(&dec->demux); 1451 dvb_dmx_release(&dec->demux);
1452 dvb_unregister_adapter(dec->adapter); 1452 dvb_unregister_adapter(&dec->adapter);
1453 1453
1454 return result; 1454 return result;
1455 } 1455 }
@@ -1463,7 +1463,7 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec)
1463 1463
1464 dvb_dmxdev_release(&dec->dmxdev); 1464 dvb_dmxdev_release(&dec->dmxdev);
1465 dvb_dmx_release(&dec->demux); 1465 dvb_dmx_release(&dec->demux);
1466 dvb_unregister_adapter(dec->adapter); 1466 dvb_unregister_adapter(&dec->adapter);
1467 1467
1468 return result; 1468 return result;
1469 } 1469 }
@@ -1476,12 +1476,12 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec)
1476 dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend); 1476 dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend);
1477 dvb_dmxdev_release(&dec->dmxdev); 1477 dvb_dmxdev_release(&dec->dmxdev);
1478 dvb_dmx_release(&dec->demux); 1478 dvb_dmx_release(&dec->demux);
1479 dvb_unregister_adapter(dec->adapter); 1479 dvb_unregister_adapter(&dec->adapter);
1480 1480
1481 return result; 1481 return result;
1482 } 1482 }
1483 1483
1484 dvb_net_init(dec->adapter, &dec->dvb_net, &dec->demux.dmx); 1484 dvb_net_init(&dec->adapter, &dec->dvb_net, &dec->demux.dmx);
1485 1485
1486 return 0; 1486 return 0;
1487} 1487}
@@ -1496,7 +1496,7 @@ static void ttusb_dec_exit_dvb(struct ttusb_dec *dec)
1496 dvb_dmxdev_release(&dec->dmxdev); 1496 dvb_dmxdev_release(&dec->dmxdev);
1497 dvb_dmx_release(&dec->demux); 1497 dvb_dmx_release(&dec->demux);
1498 if (dec->fe) dvb_unregister_frontend(dec->fe); 1498 if (dec->fe) dvb_unregister_frontend(dec->fe);
1499 dvb_unregister_adapter(dec->adapter); 1499 dvb_unregister_adapter(&dec->adapter);
1500} 1500}
1501 1501
1502static void ttusb_dec_exit_rc(struct ttusb_dec *dec) 1502static void ttusb_dec_exit_rc(struct ttusb_dec *dec)
@@ -1565,15 +1565,15 @@ static void ttusb_dec_exit_filters(struct ttusb_dec *dec)
1565 } 1565 }
1566} 1566}
1567 1567
1568int fe_send_command(struct dvb_frontend* fe, const u8 command, 1568static int fe_send_command(struct dvb_frontend* fe, const u8 command,
1569 int param_length, const u8 params[], 1569 int param_length, const u8 params[],
1570 int *result_length, u8 cmd_result[]) 1570 int *result_length, u8 cmd_result[])
1571{ 1571{
1572 struct ttusb_dec* dec = (struct ttusb_dec*) fe->dvb->priv; 1572 struct ttusb_dec* dec = (struct ttusb_dec*) fe->dvb->priv;
1573 return ttusb_dec_send_command(dec, command, param_length, params, result_length, cmd_result); 1573 return ttusb_dec_send_command(dec, command, param_length, params, result_length, cmd_result);
1574} 1574}
1575 1575
1576struct ttusbdecfe_config fe_config = { 1576static struct ttusbdecfe_config fe_config = {
1577 .send_command = fe_send_command 1577 .send_command = fe_send_command
1578}; 1578};
1579 1579
@@ -1620,7 +1620,7 @@ static int ttusb_dec_probe(struct usb_interface *intf,
1620 } 1620 }
1621 ttusb_dec_init_dvb(dec); 1621 ttusb_dec_init_dvb(dec);
1622 1622
1623 dec->adapter->priv = dec; 1623 dec->adapter.priv = dec;
1624 switch (le16_to_cpu(id->idProduct)) { 1624 switch (le16_to_cpu(id->idProduct)) {
1625 case 0x1006: 1625 case 0x1006:
1626 dec->fe = ttusbdecfe_dvbs_attach(&fe_config); 1626 dec->fe = ttusbdecfe_dvbs_attach(&fe_config);
@@ -1637,7 +1637,7 @@ static int ttusb_dec_probe(struct usb_interface *intf,
1637 le16_to_cpu(dec->udev->descriptor.idVendor), 1637 le16_to_cpu(dec->udev->descriptor.idVendor),
1638 le16_to_cpu(dec->udev->descriptor.idProduct)); 1638 le16_to_cpu(dec->udev->descriptor.idProduct));
1639 } else { 1639 } else {
1640 if (dvb_register_frontend(dec->adapter, dec->fe)) { 1640 if (dvb_register_frontend(&dec->adapter, dec->fe)) {
1641 printk("budget-ci: Frontend registration failed!\n"); 1641 printk("budget-ci: Frontend registration failed!\n");
1642 if (dec->fe->ops->release) 1642 if (dec->fe->ops->release)
1643 dec->fe->ops->release(dec->fe); 1643 dec->fe->ops->release(dec->fe);
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index d3dd4228b72d..6c05fddb69ab 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -240,6 +240,7 @@ config VIDEO_SAA7134
240 select VIDEO_BUF 240 select VIDEO_BUF
241 select VIDEO_IR 241 select VIDEO_IR
242 select VIDEO_TUNER 242 select VIDEO_TUNER
243 select CRC32
243 ---help--- 244 ---help---
244 This is a video4linux driver for Philips SAA7130/7134 based 245 This is a video4linux driver for Philips SAA7130/7134 based
245 TV cards. 246 TV cards.
diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c
index 85224b90e394..6334122704ae 100644
--- a/drivers/media/video/bttv-cards.c
+++ b/drivers/media/video/bttv-cards.c
@@ -1946,7 +1946,6 @@ struct tvcard bttv_tvcards[] = {
1946 .no_tda9875 = 1, 1946 .no_tda9875 = 1,
1947 .no_tda7432 = 1, 1947 .no_tda7432 = 1,
1948 .tuner_type = TUNER_ABSENT, 1948 .tuner_type = TUNER_ABSENT,
1949 .no_video = 1,
1950 .pll = PLL_28, 1949 .pll = PLL_28,
1951},{ 1950},{
1952 .name = "Teppro TEV-560/InterVision IV-560", 1951 .name = "Teppro TEV-560/InterVision IV-560",
diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c
index e3f477dff827..c2368bc832ed 100644
--- a/drivers/media/video/bttv-i2c.c
+++ b/drivers/media/video/bttv-i2c.c
@@ -363,6 +363,9 @@ int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
363/* read EEPROM content */ 363/* read EEPROM content */
364void __devinit bttv_readee(struct bttv *btv, unsigned char *eedata, int addr) 364void __devinit bttv_readee(struct bttv *btv, unsigned char *eedata, int addr)
365{ 365{
366 memset(eedata, 0, 256);
367 if (0 != btv->i2c_rc)
368 return;
366 btv->i2c_client.addr = addr >> 1; 369 btv->i2c_client.addr = addr >> 1;
367 tveeprom_read(&btv->i2c_client, eedata, 256); 370 tveeprom_read(&btv->i2c_client, eedata, 256);
368} 371}
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index fe6abe34168c..1db022682980 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -43,15 +43,15 @@ enum saa6752hs_videoformat {
43static const struct v4l2_format v4l2_format_table[] = 43static const struct v4l2_format v4l2_format_table[] =
44{ 44{
45 [SAA6752HS_VF_D1] = { 45 [SAA6752HS_VF_D1] = {
46 .fmt.pix.width = 720, .fmt.pix.height = 576 }, 46 .fmt = { .pix = { .width = 720, .height = 576 }, }, },
47 [SAA6752HS_VF_2_3_D1] = { 47 [SAA6752HS_VF_2_3_D1] = {
48 .fmt.pix.width = 480, .fmt.pix.height = 576 }, 48 .fmt = { .pix = { .width = 480, .height = 576 }, }, },
49 [SAA6752HS_VF_1_2_D1] = { 49 [SAA6752HS_VF_1_2_D1] = {
50 .fmt.pix.width = 352, .fmt.pix.height = 576 }, 50 .fmt = { .pix = { .width = 352, .height = 576 }, }, },
51 [SAA6752HS_VF_SIF] = { 51 [SAA6752HS_VF_SIF] = {
52 .fmt.pix.width = 352, .fmt.pix.height = 288 }, 52 .fmt = { .pix = { .width = 352, .height = 288 }, }, },
53 [SAA6752HS_VF_UNKNOWN] = { 53 [SAA6752HS_VF_UNKNOWN] = {
54 .fmt.pix.width = 0, .fmt.pix.height = 0}, 54 .fmt = { .pix = { .width = 0, .height = 0 }, }, },
55}; 55};
56 56
57struct saa6752hs_state { 57struct saa6752hs_state {
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
index 31cc4ed9b747..5f870075b55e 100644
--- a/drivers/media/video/video-buf-dvb.c
+++ b/drivers/media/video/video-buf-dvb.c
@@ -149,10 +149,10 @@ int videobuf_dvb_register(struct videobuf_dvb *dvb,
149 dvb->name, result); 149 dvb->name, result);
150 goto fail_adapter; 150 goto fail_adapter;
151 } 151 }
152 dvb->adapter->priv = adapter_priv; 152 dvb->adapter.priv = adapter_priv;
153 153
154 /* register frontend */ 154 /* register frontend */
155 result = dvb_register_frontend(dvb->adapter, dvb->frontend); 155 result = dvb_register_frontend(&dvb->adapter, dvb->frontend);
156 if (result < 0) { 156 if (result < 0) {
157 printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", 157 printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n",
158 dvb->name, result); 158 dvb->name, result);
@@ -178,7 +178,7 @@ int videobuf_dvb_register(struct videobuf_dvb *dvb,
178 dvb->dmxdev.filternum = 256; 178 dvb->dmxdev.filternum = 256;
179 dvb->dmxdev.demux = &dvb->demux.dmx; 179 dvb->dmxdev.demux = &dvb->demux.dmx;
180 dvb->dmxdev.capabilities = 0; 180 dvb->dmxdev.capabilities = 0;
181 result = dvb_dmxdev_init(&dvb->dmxdev, dvb->adapter); 181 result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter);
182 if (result < 0) { 182 if (result < 0) {
183 printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", 183 printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n",
184 dvb->name, result); 184 dvb->name, result);
@@ -209,7 +209,7 @@ int videobuf_dvb_register(struct videobuf_dvb *dvb,
209 } 209 }
210 210
211 /* register network adapter */ 211 /* register network adapter */
212 dvb_net_init(dvb->adapter, &dvb->net, &dvb->demux.dmx); 212 dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
213 return 0; 213 return 0;
214 214
215fail_fe_conn: 215fail_fe_conn:
@@ -223,7 +223,7 @@ fail_dmxdev:
223fail_dmx: 223fail_dmx:
224 dvb_unregister_frontend(dvb->frontend); 224 dvb_unregister_frontend(dvb->frontend);
225fail_frontend: 225fail_frontend:
226 dvb_unregister_adapter(dvb->adapter); 226 dvb_unregister_adapter(&dvb->adapter);
227fail_adapter: 227fail_adapter:
228 return result; 228 return result;
229} 229}
@@ -236,7 +236,7 @@ void videobuf_dvb_unregister(struct videobuf_dvb *dvb)
236 dvb_dmxdev_release(&dvb->dmxdev); 236 dvb_dmxdev_release(&dvb->dmxdev);
237 dvb_dmx_release(&dvb->demux); 237 dvb_dmx_release(&dvb->demux);
238 dvb_unregister_frontend(dvb->frontend); 238 dvb_unregister_frontend(dvb->frontend);
239 dvb_unregister_adapter(dvb->adapter); 239 dvb_unregister_adapter(&dvb->adapter);
240} 240}
241 241
242EXPORT_SYMBOL(videobuf_dvb_register); 242EXPORT_SYMBOL(videobuf_dvb_register);
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 2e70d74fbdee..4991bbd054f3 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -51,7 +51,7 @@ config MMC_PXA
51 51
52config MMC_WBSD 52config MMC_WBSD
53 tristate "Winbond W83L51xD SD/MMC Card Interface support" 53 tristate "Winbond W83L51xD SD/MMC Card Interface support"
54 depends on MMC && ISA && ISA_DMA_API 54 depends on MMC && ISA_DMA_API
55 help 55 help
56 This selects the Winbond(R) W83L51xD Secure digital and 56 This selects the Winbond(R) W83L51xD Secure digital and
57 Multimedia card Interface. 57 Multimedia card Interface.
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
index b5b4a7b11903..d4eee99c2bf6 100644
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -383,7 +383,10 @@ static int mmc_blk_probe(struct mmc_card *card)
383 struct mmc_blk_data *md; 383 struct mmc_blk_data *md;
384 int err; 384 int err;
385 385
386 if (card->csd.cmdclass & ~0x1ff) 386 /*
387 * Check that the card supports the command class(es) we need.
388 */
389 if (!(card->csd.cmdclass & CCC_BLOCK_READ))
387 return -ENODEV; 390 return -ENODEV;
388 391
389 if (card->csd.read_blkbits < 9) { 392 if (card->csd.read_blkbits < 9) {
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index 39747526c719..b7fbd30b49a0 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -28,7 +28,9 @@
28#include <linux/ioport.h> 28#include <linux/ioport.h>
29#include <linux/device.h> 29#include <linux/device.h>
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/dma-mapping.h>
31#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/pnp.h>
32#include <linux/highmem.h> 34#include <linux/highmem.h>
33#include <linux/mmc/host.h> 35#include <linux/mmc/host.h>
34#include <linux/mmc/protocol.h> 36#include <linux/mmc/protocol.h>
@@ -40,7 +42,7 @@
40#include "wbsd.h" 42#include "wbsd.h"
41 43
42#define DRIVER_NAME "wbsd" 44#define DRIVER_NAME "wbsd"
43#define DRIVER_VERSION "1.1" 45#define DRIVER_VERSION "1.2"
44 46
45#ifdef CONFIG_MMC_DEBUG 47#ifdef CONFIG_MMC_DEBUG
46#define DBG(x...) \ 48#define DBG(x...) \
@@ -52,10 +54,6 @@
52#define DBGF(x...) do { } while (0) 54#define DBGF(x...) do { } while (0)
53#endif 55#endif
54 56
55static unsigned int io = 0x248;
56static unsigned int irq = 6;
57static int dma = 2;
58
59#ifdef CONFIG_MMC_DEBUG 57#ifdef CONFIG_MMC_DEBUG
60void DBG_REG(int reg, u8 value) 58void DBG_REG(int reg, u8 value)
61{ 59{
@@ -79,28 +77,61 @@ void DBG_REG(int reg, u8 value)
79#endif 77#endif
80 78
81/* 79/*
80 * Device resources
81 */
82
83#ifdef CONFIG_PNP
84
85static const struct pnp_device_id pnp_dev_table[] = {
86 { "WEC0517", 0 },
87 { "WEC0518", 0 },
88 { "", 0 },
89};
90
91MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
92
93#endif /* CONFIG_PNP */
94
95#ifdef CONFIG_PNP
96static unsigned int nopnp = 0;
97#else
98static const unsigned int nopnp = 1;
99#endif
100static unsigned int io = 0x248;
101static unsigned int irq = 6;
102static int dma = 2;
103
104/*
82 * Basic functions 105 * Basic functions
83 */ 106 */
84 107
85static inline void wbsd_unlock_config(struct wbsd_host* host) 108static inline void wbsd_unlock_config(struct wbsd_host* host)
86{ 109{
110 BUG_ON(host->config == 0);
111
87 outb(host->unlock_code, host->config); 112 outb(host->unlock_code, host->config);
88 outb(host->unlock_code, host->config); 113 outb(host->unlock_code, host->config);
89} 114}
90 115
91static inline void wbsd_lock_config(struct wbsd_host* host) 116static inline void wbsd_lock_config(struct wbsd_host* host)
92{ 117{
118 BUG_ON(host->config == 0);
119
93 outb(LOCK_CODE, host->config); 120 outb(LOCK_CODE, host->config);
94} 121}
95 122
96static inline void wbsd_write_config(struct wbsd_host* host, u8 reg, u8 value) 123static inline void wbsd_write_config(struct wbsd_host* host, u8 reg, u8 value)
97{ 124{
125 BUG_ON(host->config == 0);
126
98 outb(reg, host->config); 127 outb(reg, host->config);
99 outb(value, host->config + 1); 128 outb(value, host->config + 1);
100} 129}
101 130
102static inline u8 wbsd_read_config(struct wbsd_host* host, u8 reg) 131static inline u8 wbsd_read_config(struct wbsd_host* host, u8 reg)
103{ 132{
133 BUG_ON(host->config == 0);
134
104 outb(reg, host->config); 135 outb(reg, host->config);
105 return inb(host->config + 1); 136 return inb(host->config + 1);
106} 137}
@@ -133,6 +164,13 @@ static void wbsd_init_device(struct wbsd_host* host)
133 wbsd_write_index(host, WBSD_IDX_SETUP, setup); 164 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
134 165
135 /* 166 /*
167 * Set DAT3 to input
168 */
169 setup &= ~WBSD_DAT3_H;
170 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
171 host->flags &= ~WBSD_FIGNORE_DETECT;
172
173 /*
136 * Read back default clock. 174 * Read back default clock.
137 */ 175 */
138 host->clk = wbsd_read_index(host, WBSD_IDX_CLK); 176 host->clk = wbsd_read_index(host, WBSD_IDX_CLK);
@@ -148,6 +186,14 @@ static void wbsd_init_device(struct wbsd_host* host)
148 wbsd_write_index(host, WBSD_IDX_TAAC, 0x7F); 186 wbsd_write_index(host, WBSD_IDX_TAAC, 0x7F);
149 187
150 /* 188 /*
189 * Test for card presence
190 */
191 if (inb(host->base + WBSD_CSR) & WBSD_CARDPRESENT)
192 host->flags |= WBSD_FCARD_PRESENT;
193 else
194 host->flags &= ~WBSD_FCARD_PRESENT;
195
196 /*
151 * Enable interesting interrupts. 197 * Enable interesting interrupts.
152 */ 198 */
153 ier = 0; 199 ier = 0;
@@ -407,8 +453,6 @@ static inline void wbsd_get_long_reply(struct wbsd_host* host,
407 } 453 }
408} 454}
409 455
410static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs);
411
412static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd) 456static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd)
413{ 457{
414 int i; 458 int i;
@@ -646,6 +690,13 @@ static void wbsd_fill_fifo(struct wbsd_host* host)
646 } 690 }
647 691
648 wbsd_kunmap_sg(host); 692 wbsd_kunmap_sg(host);
693
694 /*
695 * The controller stops sending interrupts for
696 * 'FIFO empty' under certain conditions. So we
697 * need to be a bit more pro-active.
698 */
699 tasklet_schedule(&host->fifo_tasklet);
649} 700}
650 701
651static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data) 702static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data)
@@ -850,9 +901,11 @@ static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data)
850 wbsd_request_end(host, host->mrq); 901 wbsd_request_end(host, host->mrq);
851} 902}
852 903
853/* 904/*****************************************************************************\
854 * MMC Callbacks 905 * *
855 */ 906 * MMC layer callbacks *
907 * *
908\*****************************************************************************/
856 909
857static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq) 910static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq)
858{ 911{
@@ -874,7 +927,7 @@ static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq)
874 * If there is no card in the slot then 927 * If there is no card in the slot then
875 * timeout immediatly. 928 * timeout immediatly.
876 */ 929 */
877 if (!(inb(host->base + WBSD_CSR) & WBSD_CARDPRESENT)) 930 if (!(host->flags & WBSD_FCARD_PRESENT))
878 { 931 {
879 cmd->error = MMC_ERR_TIMEOUT; 932 cmd->error = MMC_ERR_TIMEOUT;
880 goto done; 933 goto done;
@@ -953,33 +1006,50 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
953 host->clk = clk; 1006 host->clk = clk;
954 } 1007 }
955 1008
1009 /*
1010 * Power up card.
1011 */
956 if (ios->power_mode != MMC_POWER_OFF) 1012 if (ios->power_mode != MMC_POWER_OFF)
957 { 1013 {
958 /*
959 * Power up card.
960 */
961 pwr = inb(host->base + WBSD_CSR); 1014 pwr = inb(host->base + WBSD_CSR);
962 pwr &= ~WBSD_POWER_N; 1015 pwr &= ~WBSD_POWER_N;
963 outb(pwr, host->base + WBSD_CSR); 1016 outb(pwr, host->base + WBSD_CSR);
964
965 /*
966 * This behaviour is stolen from the
967 * Windows driver. Don't know why, but
968 * it is needed.
969 */
970 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
971 if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
972 setup |= WBSD_DAT3_H;
973 else
974 setup &= ~WBSD_DAT3_H;
975 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
976
977 mdelay(1);
978 } 1017 }
979 1018
1019 /*
1020 * MMC cards need to have pin 1 high during init.
1021 * Init time corresponds rather nicely with the bus mode.
1022 * It wreaks havoc with the card detection though so
1023 * that needs to be disabed.
1024 */
1025 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
1026 if ((ios->power_mode == MMC_POWER_ON) &&
1027 (ios->bus_mode == MMC_BUSMODE_OPENDRAIN))
1028 {
1029 setup |= WBSD_DAT3_H;
1030 host->flags |= WBSD_FIGNORE_DETECT;
1031 }
1032 else
1033 {
1034 setup &= ~WBSD_DAT3_H;
1035 host->flags &= ~WBSD_FIGNORE_DETECT;
1036 }
1037 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
1038
980 spin_unlock_bh(&host->lock); 1039 spin_unlock_bh(&host->lock);
981} 1040}
982 1041
1042static struct mmc_host_ops wbsd_ops = {
1043 .request = wbsd_request,
1044 .set_ios = wbsd_set_ios,
1045};
1046
1047/*****************************************************************************\
1048 * *
1049 * Interrupt handling *
1050 * *
1051\*****************************************************************************/
1052
983/* 1053/*
984 * Tasklets 1054 * Tasklets
985 */ 1055 */
@@ -1005,17 +1075,33 @@ static void wbsd_tasklet_card(unsigned long param)
1005{ 1075{
1006 struct wbsd_host* host = (struct wbsd_host*)param; 1076 struct wbsd_host* host = (struct wbsd_host*)param;
1007 u8 csr; 1077 u8 csr;
1078 int change = 0;
1008 1079
1009 spin_lock(&host->lock); 1080 spin_lock(&host->lock);
1010 1081
1082 if (host->flags & WBSD_FIGNORE_DETECT)
1083 {
1084 spin_unlock(&host->lock);
1085 return;
1086 }
1087
1011 csr = inb(host->base + WBSD_CSR); 1088 csr = inb(host->base + WBSD_CSR);
1012 WARN_ON(csr == 0xff); 1089 WARN_ON(csr == 0xff);
1013 1090
1014 if (csr & WBSD_CARDPRESENT) 1091 if (csr & WBSD_CARDPRESENT)
1015 DBG("Card inserted\n"); 1092 {
1016 else 1093 if (!(host->flags & WBSD_FCARD_PRESENT))
1094 {
1095 DBG("Card inserted\n");
1096 host->flags |= WBSD_FCARD_PRESENT;
1097 change = 1;
1098 }
1099 }
1100 else if (host->flags & WBSD_FCARD_PRESENT)
1017 { 1101 {
1018 DBG("Card removed\n"); 1102 DBG("Card removed\n");
1103 host->flags &= ~WBSD_FCARD_PRESENT;
1104 change = 1;
1019 1105
1020 if (host->mrq) 1106 if (host->mrq)
1021 { 1107 {
@@ -1033,7 +1119,8 @@ static void wbsd_tasklet_card(unsigned long param)
1033 */ 1119 */
1034 spin_unlock(&host->lock); 1120 spin_unlock(&host->lock);
1035 1121
1036 mmc_detect_change(host->mmc); 1122 if (change)
1123 mmc_detect_change(host->mmc);
1037} 1124}
1038 1125
1039static void wbsd_tasklet_fifo(unsigned long param) 1126static void wbsd_tasklet_fifo(unsigned long param)
@@ -1200,11 +1287,85 @@ static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs)
1200 return IRQ_HANDLED; 1287 return IRQ_HANDLED;
1201} 1288}
1202 1289
1290/*****************************************************************************\
1291 * *
1292 * Device initialisation and shutdown *
1293 * *
1294\*****************************************************************************/
1295
1203/* 1296/*
1204 * Support functions for probe 1297 * Allocate/free MMC structure.
1205 */ 1298 */
1206 1299
1207static int wbsd_scan(struct wbsd_host* host) 1300static int __devinit wbsd_alloc_mmc(struct device* dev)
1301{
1302 struct mmc_host* mmc;
1303 struct wbsd_host* host;
1304
1305 /*
1306 * Allocate MMC structure.
1307 */
1308 mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev);
1309 if (!mmc)
1310 return -ENOMEM;
1311
1312 host = mmc_priv(mmc);
1313 host->mmc = mmc;
1314
1315 host->dma = -1;
1316
1317 /*
1318 * Set host parameters.
1319 */
1320 mmc->ops = &wbsd_ops;
1321 mmc->f_min = 375000;
1322 mmc->f_max = 24000000;
1323 mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34;
1324
1325 spin_lock_init(&host->lock);
1326
1327 /*
1328 * Maximum number of segments. Worst case is one sector per segment
1329 * so this will be 64kB/512.
1330 */
1331 mmc->max_hw_segs = 128;
1332 mmc->max_phys_segs = 128;
1333
1334 /*
1335 * Maximum number of sectors in one transfer. Also limited by 64kB
1336 * buffer.
1337 */
1338 mmc->max_sectors = 128;
1339
1340 /*
1341 * Maximum segment size. Could be one segment with the maximum number
1342 * of segments.
1343 */
1344 mmc->max_seg_size = mmc->max_sectors * 512;
1345
1346 dev_set_drvdata(dev, mmc);
1347
1348 return 0;
1349}
1350
1351static void __devexit wbsd_free_mmc(struct device* dev)
1352{
1353 struct mmc_host* mmc;
1354
1355 mmc = dev_get_drvdata(dev);
1356 if (!mmc)
1357 return;
1358
1359 mmc_free_host(mmc);
1360
1361 dev_set_drvdata(dev, NULL);
1362}
1363
1364/*
1365 * Scan for known chip id:s
1366 */
1367
1368static int __devinit wbsd_scan(struct wbsd_host* host)
1208{ 1369{
1209 int i, j, k; 1370 int i, j, k;
1210 int id; 1371 int id;
@@ -1258,12 +1419,16 @@ static int wbsd_scan(struct wbsd_host* host)
1258 return -ENODEV; 1419 return -ENODEV;
1259} 1420}
1260 1421
1261static int wbsd_request_regions(struct wbsd_host* host) 1422/*
1423 * Allocate/free io port ranges
1424 */
1425
1426static int __devinit wbsd_request_region(struct wbsd_host* host, int base)
1262{ 1427{
1263 if (io & 0x7) 1428 if (io & 0x7)
1264 return -EINVAL; 1429 return -EINVAL;
1265 1430
1266 if (!request_region(io, 8, DRIVER_NAME)) 1431 if (!request_region(base, 8, DRIVER_NAME))
1267 return -EIO; 1432 return -EIO;
1268 1433
1269 host->base = io; 1434 host->base = io;
@@ -1271,19 +1436,25 @@ static int wbsd_request_regions(struct wbsd_host* host)
1271 return 0; 1436 return 0;
1272} 1437}
1273 1438
1274static void wbsd_release_regions(struct wbsd_host* host) 1439static void __devexit wbsd_release_regions(struct wbsd_host* host)
1275{ 1440{
1276 if (host->base) 1441 if (host->base)
1277 release_region(host->base, 8); 1442 release_region(host->base, 8);
1443
1444 host->base = 0;
1278 1445
1279 if (host->config) 1446 if (host->config)
1280 release_region(host->config, 2); 1447 release_region(host->config, 2);
1448
1449 host->config = 0;
1281} 1450}
1282 1451
1283static void wbsd_init_dma(struct wbsd_host* host) 1452/*
1453 * Allocate/free DMA port and buffer
1454 */
1455
1456static void __devinit wbsd_request_dma(struct wbsd_host* host, int dma)
1284{ 1457{
1285 host->dma = -1;
1286
1287 if (dma < 0) 1458 if (dma < 0)
1288 return; 1459 return;
1289 1460
@@ -1294,7 +1465,7 @@ static void wbsd_init_dma(struct wbsd_host* host)
1294 * We need to allocate a special buffer in 1465 * We need to allocate a special buffer in
1295 * order for ISA to be able to DMA to it. 1466 * order for ISA to be able to DMA to it.
1296 */ 1467 */
1297 host->dma_buffer = kmalloc(65536, 1468 host->dma_buffer = kmalloc(WBSD_DMA_SIZE,
1298 GFP_NOIO | GFP_DMA | __GFP_REPEAT | __GFP_NOWARN); 1469 GFP_NOIO | GFP_DMA | __GFP_REPEAT | __GFP_NOWARN);
1299 if (!host->dma_buffer) 1470 if (!host->dma_buffer)
1300 goto free; 1471 goto free;
@@ -1302,7 +1473,8 @@ static void wbsd_init_dma(struct wbsd_host* host)
1302 /* 1473 /*
1303 * Translate the address to a physical address. 1474 * Translate the address to a physical address.
1304 */ 1475 */
1305 host->dma_addr = isa_virt_to_bus(host->dma_buffer); 1476 host->dma_addr = dma_map_single(host->mmc->dev, host->dma_buffer,
1477 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1306 1478
1307 /* 1479 /*
1308 * ISA DMA must be aligned on a 64k basis. 1480 * ISA DMA must be aligned on a 64k basis.
@@ -1325,6 +1497,10 @@ kfree:
1325 */ 1497 */
1326 BUG_ON(1); 1498 BUG_ON(1);
1327 1499
1500 dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE,
1501 DMA_BIDIRECTIONAL);
1502 host->dma_addr = (dma_addr_t)NULL;
1503
1328 kfree(host->dma_buffer); 1504 kfree(host->dma_buffer);
1329 host->dma_buffer = NULL; 1505 host->dma_buffer = NULL;
1330 1506
@@ -1336,60 +1512,122 @@ err:
1336 "Falling back on FIFO.\n", dma); 1512 "Falling back on FIFO.\n", dma);
1337} 1513}
1338 1514
1339static struct mmc_host_ops wbsd_ops = { 1515static void __devexit wbsd_release_dma(struct wbsd_host* host)
1340 .request = wbsd_request, 1516{
1341 .set_ios = wbsd_set_ios, 1517 if (host->dma_addr)
1342}; 1518 dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE,
1519 DMA_BIDIRECTIONAL);
1520 if (host->dma_buffer)
1521 kfree(host->dma_buffer);
1522 if (host->dma >= 0)
1523 free_dma(host->dma);
1524
1525 host->dma = -1;
1526 host->dma_buffer = NULL;
1527 host->dma_addr = (dma_addr_t)NULL;
1528}
1343 1529
1344/* 1530/*
1345 * Device probe 1531 * Allocate/free IRQ.
1346 */ 1532 */
1347 1533
1348static int wbsd_probe(struct device* dev) 1534static int __devinit wbsd_request_irq(struct wbsd_host* host, int irq)
1349{ 1535{
1350 struct wbsd_host* host = NULL;
1351 struct mmc_host* mmc = NULL;
1352 int ret; 1536 int ret;
1353 1537
1354 /* 1538 /*
1355 * Allocate MMC structure. 1539 * Allocate interrupt.
1356 */ 1540 */
1357 mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev); 1541
1358 if (!mmc) 1542 ret = request_irq(irq, wbsd_irq, SA_SHIRQ, DRIVER_NAME, host);
1359 return -ENOMEM; 1543 if (ret)
1360 1544 return ret;
1361 host = mmc_priv(mmc);
1362 host->mmc = mmc;
1363 1545
1546 host->irq = irq;
1547
1364 /* 1548 /*
1365 * Scan for hardware. 1549 * Set up tasklets.
1366 */ 1550 */
1367 ret = wbsd_scan(host); 1551 tasklet_init(&host->card_tasklet, wbsd_tasklet_card, (unsigned long)host);
1368 if (ret) 1552 tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo, (unsigned long)host);
1369 goto freemmc; 1553 tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc, (unsigned long)host);
1554 tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout, (unsigned long)host);
1555 tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, (unsigned long)host);
1556 tasklet_init(&host->block_tasklet, wbsd_tasklet_block, (unsigned long)host);
1557
1558 return 0;
1559}
1370 1560
1371 /* 1561static void __devexit wbsd_release_irq(struct wbsd_host* host)
1372 * Reset the chip. 1562{
1373 */ 1563 if (!host->irq)
1374 wbsd_write_config(host, WBSD_CONF_SWRST, 1); 1564 return;
1375 wbsd_write_config(host, WBSD_CONF_SWRST, 0);
1376 1565
1566 free_irq(host->irq, host);
1567
1568 host->irq = 0;
1569
1570 tasklet_kill(&host->card_tasklet);
1571 tasklet_kill(&host->fifo_tasklet);
1572 tasklet_kill(&host->crc_tasklet);
1573 tasklet_kill(&host->timeout_tasklet);
1574 tasklet_kill(&host->finish_tasklet);
1575 tasklet_kill(&host->block_tasklet);
1576}
1577
1578/*
1579 * Allocate all resources for the host.
1580 */
1581
1582static int __devinit wbsd_request_resources(struct wbsd_host* host,
1583 int base, int irq, int dma)
1584{
1585 int ret;
1586
1377 /* 1587 /*
1378 * Allocate I/O ports. 1588 * Allocate I/O ports.
1379 */ 1589 */
1380 ret = wbsd_request_regions(host); 1590 ret = wbsd_request_region(host, base);
1381 if (ret) 1591 if (ret)
1382 goto release; 1592 return ret;
1383 1593
1384 /* 1594 /*
1385 * Set host parameters. 1595 * Allocate interrupt.
1386 */ 1596 */
1387 mmc->ops = &wbsd_ops; 1597 ret = wbsd_request_irq(host, irq);
1388 mmc->f_min = 375000; 1598 if (ret)
1389 mmc->f_max = 24000000; 1599 return ret;
1390 mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34; 1600
1601 /*
1602 * Allocate DMA.
1603 */
1604 wbsd_request_dma(host, dma);
1391 1605
1392 spin_lock_init(&host->lock); 1606 return 0;
1607}
1608
1609/*
1610 * Release all resources for the host.
1611 */
1612
1613static void __devexit wbsd_release_resources(struct wbsd_host* host)
1614{
1615 wbsd_release_dma(host);
1616 wbsd_release_irq(host);
1617 wbsd_release_regions(host);
1618}
1619
1620/*
1621 * Configure the resources the chip should use.
1622 */
1623
1624static void __devinit wbsd_chip_config(struct wbsd_host* host)
1625{
1626 /*
1627 * Reset the chip.
1628 */
1629 wbsd_write_config(host, WBSD_CONF_SWRST, 1);
1630 wbsd_write_config(host, WBSD_CONF_SWRST, 0);
1393 1631
1394 /* 1632 /*
1395 * Select SD/MMC function. 1633 * Select SD/MMC function.
@@ -1399,165 +1637,241 @@ static int wbsd_probe(struct device* dev)
1399 /* 1637 /*
1400 * Set up card detection. 1638 * Set up card detection.
1401 */ 1639 */
1402 wbsd_write_config(host, WBSD_CONF_PINS, 0x02); 1640 wbsd_write_config(host, WBSD_CONF_PINS, WBSD_PINS_DETECT_GP11);
1403 1641
1404 /* 1642 /*
1405 * Configure I/O port. 1643 * Configure chip
1406 */ 1644 */
1407 wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8); 1645 wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8);
1408 wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff); 1646 wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff);
1409
1410 /*
1411 * Allocate interrupt.
1412 */
1413 ret = request_irq(irq, wbsd_irq, SA_SHIRQ, DRIVER_NAME, host);
1414 if (ret)
1415 goto release;
1416 1647
1417 host->irq = irq; 1648 wbsd_write_config(host, WBSD_CONF_IRQ, host->irq);
1418 1649
1419 /* 1650 if (host->dma >= 0)
1420 * Set up tasklets. 1651 wbsd_write_config(host, WBSD_CONF_DRQ, host->dma);
1421 */
1422 tasklet_init(&host->card_tasklet, wbsd_tasklet_card, (unsigned long)host);
1423 tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo, (unsigned long)host);
1424 tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc, (unsigned long)host);
1425 tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout, (unsigned long)host);
1426 tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, (unsigned long)host);
1427 tasklet_init(&host->block_tasklet, wbsd_tasklet_block, (unsigned long)host);
1428 1652
1429 /* 1653 /*
1430 * Configure interrupt. 1654 * Enable and power up chip.
1431 */ 1655 */
1432 wbsd_write_config(host, WBSD_CONF_IRQ, host->irq); 1656 wbsd_write_config(host, WBSD_CONF_ENABLE, 1);
1657 wbsd_write_config(host, WBSD_CONF_POWER, 0x20);
1658}
1659
1660/*
1661 * Check that configured resources are correct.
1662 */
1663
1664static int __devinit wbsd_chip_validate(struct wbsd_host* host)
1665{
1666 int base, irq, dma;
1433 1667
1434 /* 1668 /*
1435 * Allocate DMA. 1669 * Select SD/MMC function.
1436 */ 1670 */
1437 wbsd_init_dma(host); 1671 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1438 1672
1439 /* 1673 /*
1440 * If all went well, then configure DMA. 1674 * Read configuration.
1441 */ 1675 */
1442 if (host->dma >= 0) 1676 base = wbsd_read_config(host, WBSD_CONF_PORT_HI) << 8;
1443 wbsd_write_config(host, WBSD_CONF_DRQ, host->dma); 1677 base |= wbsd_read_config(host, WBSD_CONF_PORT_LO);
1444 1678
1445 /* 1679 irq = wbsd_read_config(host, WBSD_CONF_IRQ);
1446 * Maximum number of segments. Worst case is one sector per segment 1680
1447 * so this will be 64kB/512. 1681 dma = wbsd_read_config(host, WBSD_CONF_DRQ);
1448 */
1449 mmc->max_hw_segs = 128;
1450 mmc->max_phys_segs = 128;
1451 1682
1452 /* 1683 /*
1453 * Maximum number of sectors in one transfer. Also limited by 64kB 1684 * Validate against given configuration.
1454 * buffer.
1455 */ 1685 */
1456 mmc->max_sectors = 128; 1686 if (base != host->base)
1687 return 0;
1688 if (irq != host->irq)
1689 return 0;
1690 if ((dma != host->dma) && (host->dma != -1))
1691 return 0;
1692
1693 return 1;
1694}
1695
1696/*****************************************************************************\
1697 * *
1698 * Devices setup and shutdown *
1699 * *
1700\*****************************************************************************/
1701
1702static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma,
1703 int pnp)
1704{
1705 struct wbsd_host* host = NULL;
1706 struct mmc_host* mmc = NULL;
1707 int ret;
1708
1709 ret = wbsd_alloc_mmc(dev);
1710 if (ret)
1711 return ret;
1712
1713 mmc = dev_get_drvdata(dev);
1714 host = mmc_priv(mmc);
1457 1715
1458 /* 1716 /*
1459 * Maximum segment size. Could be one segment with the maximum number 1717 * Scan for hardware.
1460 * of segments.
1461 */ 1718 */
1462 mmc->max_seg_size = mmc->max_sectors * 512; 1719 ret = wbsd_scan(host);
1720 if (ret)
1721 {
1722 if (pnp && (ret == -ENODEV))
1723 {
1724 printk(KERN_WARNING DRIVER_NAME
1725 ": Unable to confirm device presence. You may "
1726 "experience lock-ups.\n");
1727 }
1728 else
1729 {
1730 wbsd_free_mmc(dev);
1731 return ret;
1732 }
1733 }
1463 1734
1464 /* 1735 /*
1465 * Enable chip. 1736 * Request resources.
1466 */ 1737 */
1467 wbsd_write_config(host, WBSD_CONF_ENABLE, 1); 1738 ret = wbsd_request_resources(host, io, irq, dma);
1739 if (ret)
1740 {
1741 wbsd_release_resources(host);
1742 wbsd_free_mmc(dev);
1743 return ret;
1744 }
1468 1745
1469 /* 1746 /*
1470 * Power up chip. 1747 * See if chip needs to be configured.
1471 */ 1748 */
1472 wbsd_write_config(host, WBSD_CONF_POWER, 0x20); 1749 if (pnp && (host->config != 0))
1750 {
1751 if (!wbsd_chip_validate(host))
1752 {
1753 printk(KERN_WARNING DRIVER_NAME
1754 ": PnP active but chip not configured! "
1755 "You probably have a buggy BIOS. "
1756 "Configuring chip manually.\n");
1757 wbsd_chip_config(host);
1758 }
1759 }
1760 else
1761 wbsd_chip_config(host);
1473 1762
1474 /* 1763 /*
1475 * Power Management stuff. No idea how this works. 1764 * Power Management stuff. No idea how this works.
1476 * Not tested. 1765 * Not tested.
1477 */ 1766 */
1478#ifdef CONFIG_PM 1767#ifdef CONFIG_PM
1479 wbsd_write_config(host, WBSD_CONF_PME, 0xA0); 1768 if (host->config)
1769 wbsd_write_config(host, WBSD_CONF_PME, 0xA0);
1480#endif 1770#endif
1771 /*
1772 * Allow device to initialise itself properly.
1773 */
1774 mdelay(5);
1481 1775
1482 /* 1776 /*
1483 * Reset the chip into a known state. 1777 * Reset the chip into a known state.
1484 */ 1778 */
1485 wbsd_init_device(host); 1779 wbsd_init_device(host);
1486 1780
1487 dev_set_drvdata(dev, mmc);
1488
1489 /*
1490 * Add host to MMC layer.
1491 */
1492 mmc_add_host(mmc); 1781 mmc_add_host(mmc);
1493 1782
1494 printk(KERN_INFO "%s: W83L51xD id %x at 0x%x irq %d dma %d\n", 1783 printk(KERN_INFO "%s: W83L51xD", mmc->host_name);
1495 mmc->host_name, (int)host->chip_id, (int)host->base, 1784 if (host->chip_id != 0)
1496 (int)host->irq, (int)host->dma); 1785 printk(" id %x", (int)host->chip_id);
1786 printk(" at 0x%x irq %d", (int)host->base, (int)host->irq);
1787 if (host->dma >= 0)
1788 printk(" dma %d", (int)host->dma);
1789 else
1790 printk(" FIFO");
1791 if (pnp)
1792 printk(" PnP");
1793 printk("\n");
1497 1794
1498 return 0; 1795 return 0;
1499
1500release:
1501 wbsd_release_regions(host);
1502
1503freemmc:
1504 mmc_free_host(mmc);
1505
1506 return ret;
1507} 1796}
1508 1797
1509/* 1798static void __devexit wbsd_shutdown(struct device* dev, int pnp)
1510 * Device remove
1511 */
1512
1513static int wbsd_remove(struct device* dev)
1514{ 1799{
1515 struct mmc_host* mmc = dev_get_drvdata(dev); 1800 struct mmc_host* mmc = dev_get_drvdata(dev);
1516 struct wbsd_host* host; 1801 struct wbsd_host* host;
1517 1802
1518 if (!mmc) 1803 if (!mmc)
1519 return 0; 1804 return;
1520 1805
1521 host = mmc_priv(mmc); 1806 host = mmc_priv(mmc);
1522 1807
1523 /*
1524 * Unregister host with MMC layer.
1525 */
1526 mmc_remove_host(mmc); 1808 mmc_remove_host(mmc);
1527 1809
1528 /* 1810 if (!pnp)
1529 * Power down the SD/MMC function. 1811 {
1530 */ 1812 /*
1531 wbsd_unlock_config(host); 1813 * Power down the SD/MMC function.
1532 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD); 1814 */
1533 wbsd_write_config(host, WBSD_CONF_ENABLE, 0); 1815 wbsd_unlock_config(host);
1534 wbsd_lock_config(host); 1816 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1817 wbsd_write_config(host, WBSD_CONF_ENABLE, 0);
1818 wbsd_lock_config(host);
1819 }
1535 1820
1536 /* 1821 wbsd_release_resources(host);
1537 * Free resources.
1538 */
1539 if (host->dma_buffer)
1540 kfree(host->dma_buffer);
1541 1822
1542 if (host->dma >= 0) 1823 wbsd_free_mmc(dev);
1543 free_dma(host->dma); 1824}
1544 1825
1545 free_irq(host->irq, host); 1826/*
1827 * Non-PnP
1828 */
1829
1830static int __devinit wbsd_probe(struct device* dev)
1831{
1832 return wbsd_init(dev, io, irq, dma, 0);
1833}
1834
1835static int __devexit wbsd_remove(struct device* dev)
1836{
1837 wbsd_shutdown(dev, 0);
1838
1839 return 0;
1840}
1841
1842/*
1843 * PnP
1844 */
1845
1846#ifdef CONFIG_PNP
1847
1848static int __devinit
1849wbsd_pnp_probe(struct pnp_dev * pnpdev, const struct pnp_device_id *dev_id)
1850{
1851 int io, irq, dma;
1546 1852
1547 tasklet_kill(&host->card_tasklet); 1853 /*
1548 tasklet_kill(&host->fifo_tasklet); 1854 * Get resources from PnP layer.
1549 tasklet_kill(&host->crc_tasklet); 1855 */
1550 tasklet_kill(&host->timeout_tasklet); 1856 io = pnp_port_start(pnpdev, 0);
1551 tasklet_kill(&host->finish_tasklet); 1857 irq = pnp_irq(pnpdev, 0);
1552 tasklet_kill(&host->block_tasklet); 1858 if (pnp_dma_valid(pnpdev, 0))
1859 dma = pnp_dma(pnpdev, 0);
1860 else
1861 dma = -1;
1553 1862
1554 wbsd_release_regions(host); 1863 DBGF("PnP resources: port %3x irq %d dma %d\n", io, irq, dma);
1555 1864
1556 mmc_free_host(mmc); 1865 return wbsd_init(&pnpdev->dev, io, irq, dma, 1);
1866}
1557 1867
1558 return 0; 1868static void __devexit wbsd_pnp_remove(struct pnp_dev * dev)
1869{
1870 wbsd_shutdown(&dev->dev, 1);
1559} 1871}
1560 1872
1873#endif /* CONFIG_PNP */
1874
1561/* 1875/*
1562 * Power management 1876 * Power management
1563 */ 1877 */
@@ -1581,17 +1895,7 @@ static int wbsd_resume(struct device *dev, u32 level)
1581#define wbsd_resume NULL 1895#define wbsd_resume NULL
1582#endif 1896#endif
1583 1897
1584static void wbsd_release(struct device *dev) 1898static struct platform_device *wbsd_device;
1585{
1586}
1587
1588static struct platform_device wbsd_device = {
1589 .name = DRIVER_NAME,
1590 .id = -1,
1591 .dev = {
1592 .release = wbsd_release,
1593 },
1594};
1595 1899
1596static struct device_driver wbsd_driver = { 1900static struct device_driver wbsd_driver = {
1597 .name = DRIVER_NAME, 1901 .name = DRIVER_NAME,
@@ -1603,6 +1907,17 @@ static struct device_driver wbsd_driver = {
1603 .resume = wbsd_resume, 1907 .resume = wbsd_resume,
1604}; 1908};
1605 1909
1910#ifdef CONFIG_PNP
1911
1912static struct pnp_driver wbsd_pnp_driver = {
1913 .name = DRIVER_NAME,
1914 .id_table = pnp_dev_table,
1915 .probe = wbsd_pnp_probe,
1916 .remove = wbsd_pnp_remove,
1917};
1918
1919#endif /* CONFIG_PNP */
1920
1606/* 1921/*
1607 * Module loading/unloading 1922 * Module loading/unloading
1608 */ 1923 */
@@ -1615,29 +1930,57 @@ static int __init wbsd_drv_init(void)
1615 ": Winbond W83L51xD SD/MMC card interface driver, " 1930 ": Winbond W83L51xD SD/MMC card interface driver, "
1616 DRIVER_VERSION "\n"); 1931 DRIVER_VERSION "\n");
1617 printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n"); 1932 printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n");
1618
1619 result = driver_register(&wbsd_driver);
1620 if (result < 0)
1621 return result;
1622 1933
1623 result = platform_device_register(&wbsd_device); 1934#ifdef CONFIG_PNP
1624 if (result < 0) 1935
1625 return result; 1936 if (!nopnp)
1937 {
1938 result = pnp_register_driver(&wbsd_pnp_driver);
1939 if (result < 0)
1940 return result;
1941 }
1942
1943#endif /* CONFIG_PNP */
1944
1945 if (nopnp)
1946 {
1947 result = driver_register(&wbsd_driver);
1948 if (result < 0)
1949 return result;
1950
1951 wbsd_device = platform_device_register_simple(DRIVER_NAME, -1,
1952 NULL, 0);
1953 if (IS_ERR(wbsd_device))
1954 return PTR_ERR(wbsd_device);
1955 }
1626 1956
1627 return 0; 1957 return 0;
1628} 1958}
1629 1959
1630static void __exit wbsd_drv_exit(void) 1960static void __exit wbsd_drv_exit(void)
1631{ 1961{
1632 platform_device_unregister(&wbsd_device); 1962#ifdef CONFIG_PNP
1963
1964 if (!nopnp)
1965 pnp_unregister_driver(&wbsd_pnp_driver);
1633 1966
1634 driver_unregister(&wbsd_driver); 1967#endif /* CONFIG_PNP */
1968
1969 if (nopnp)
1970 {
1971 platform_device_unregister(wbsd_device);
1972
1973 driver_unregister(&wbsd_driver);
1974 }
1635 1975
1636 DBG("unloaded\n"); 1976 DBG("unloaded\n");
1637} 1977}
1638 1978
1639module_init(wbsd_drv_init); 1979module_init(wbsd_drv_init);
1640module_exit(wbsd_drv_exit); 1980module_exit(wbsd_drv_exit);
1981#ifdef CONFIG_PNP
1982module_param(nopnp, uint, 0444);
1983#endif
1641module_param(io, uint, 0444); 1984module_param(io, uint, 0444);
1642module_param(irq, uint, 0444); 1985module_param(irq, uint, 0444);
1643module_param(dma, int, 0444); 1986module_param(dma, int, 0444);
@@ -1646,6 +1989,9 @@ MODULE_LICENSE("GPL");
1646MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver"); 1989MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver");
1647MODULE_VERSION(DRIVER_VERSION); 1990MODULE_VERSION(DRIVER_VERSION);
1648 1991
1992#ifdef CONFIG_PNP
1993MODULE_PARM_DESC(nopnp, "Scan for device instead of relying on PNP. (default 0)");
1994#endif
1649MODULE_PARM_DESC(io, "I/O base to allocate. Must be 8 byte aligned. (default 0x248)"); 1995MODULE_PARM_DESC(io, "I/O base to allocate. Must be 8 byte aligned. (default 0x248)");
1650MODULE_PARM_DESC(irq, "IRQ to allocate. (default 6)"); 1996MODULE_PARM_DESC(irq, "IRQ to allocate. (default 6)");
1651MODULE_PARM_DESC(dma, "DMA channel to allocate. -1 for no DMA. (default 2)"); 1997MODULE_PARM_DESC(dma, "DMA channel to allocate. -1 for no DMA. (default 2)");
diff --git a/drivers/mmc/wbsd.h b/drivers/mmc/wbsd.h
index fdc03b56a81f..864f30828d01 100644
--- a/drivers/mmc/wbsd.h
+++ b/drivers/mmc/wbsd.h
@@ -35,6 +35,12 @@ const int valid_ids[] = {
35 35
36#define DEVICE_SD 0x03 36#define DEVICE_SD 0x03
37 37
38#define WBSD_PINS_DAT3_HI 0x20
39#define WBSD_PINS_DAT3_OUT 0x10
40#define WBSD_PINS_GP11_HI 0x04
41#define WBSD_PINS_DETECT_GP11 0x02
42#define WBSD_PINS_DETECT_DAT3 0x01
43
38#define WBSD_CMDR 0x00 44#define WBSD_CMDR 0x00
39#define WBSD_DFR 0x01 45#define WBSD_DFR 0x01
40#define WBSD_EIR 0x02 46#define WBSD_EIR 0x02
@@ -133,6 +139,7 @@ const int valid_ids[] = {
133#define WBSD_CRC_OK 0x05 /* S010E (00101) */ 139#define WBSD_CRC_OK 0x05 /* S010E (00101) */
134#define WBSD_CRC_FAIL 0x0B /* S101E (01011) */ 140#define WBSD_CRC_FAIL 0x0B /* S101E (01011) */
135 141
142#define WBSD_DMA_SIZE 65536
136 143
137struct wbsd_host 144struct wbsd_host
138{ 145{
@@ -140,6 +147,11 @@ struct wbsd_host
140 147
141 spinlock_t lock; /* Mutex */ 148 spinlock_t lock; /* Mutex */
142 149
150 int flags; /* Driver states */
151
152#define WBSD_FCARD_PRESENT (1<<0) /* Card is present */
153#define WBSD_FIGNORE_DETECT (1<<1) /* Ignore card detection */
154
143 struct mmc_request* mrq; /* Current request */ 155 struct mmc_request* mrq; /* Current request */
144 156
145 u8 isr; /* Accumulated ISR */ 157 u8 isr; /* Accumulated ISR */
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 3a0a55b62aaf..f08e01b2fd19 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1555,6 +1555,7 @@ config SIS900
1555 tristate "SiS 900/7016 PCI Fast Ethernet Adapter support" 1555 tristate "SiS 900/7016 PCI Fast Ethernet Adapter support"
1556 depends on NET_PCI && PCI 1556 depends on NET_PCI && PCI
1557 select CRC32 1557 select CRC32
1558 select MII
1558 ---help--- 1559 ---help---
1559 This is a driver for the Fast Ethernet PCI network cards based on 1560 This is a driver for the Fast Ethernet PCI network cards based on
1560 the SiS 900 and SiS 7016 chips. The SiS 900 core is also embedded in 1561 the SiS 900 and SiS 7016 chips. The SiS 900 core is also embedded in
@@ -2031,6 +2032,15 @@ config TIGON3
2031 To compile this driver as a module, choose M here: the module 2032 To compile this driver as a module, choose M here: the module
2032 will be called tg3. This is recommended. 2033 will be called tg3. This is recommended.
2033 2034
2035config BNX2
2036 tristate "Broadcom NetXtremeII support"
2037 depends on PCI
2038 help
2039 This driver supports Broadcom NetXtremeII gigabit Ethernet cards.
2040
2041 To compile this driver as a module, choose M here: the module
2042 will be called bnx2. This is recommended.
2043
2034config GIANFAR 2044config GIANFAR
2035 tristate "Gianfar Ethernet" 2045 tristate "Gianfar Ethernet"
2036 depends on 85xx || 83xx 2046 depends on 85xx || 83xx
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 6202b10dbb4d..30c7567001fe 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_NS83820) += ns83820.o
51obj-$(CONFIG_STNIC) += stnic.o 8390.o 51obj-$(CONFIG_STNIC) += stnic.o 8390.o
52obj-$(CONFIG_FEALNX) += fealnx.o 52obj-$(CONFIG_FEALNX) += fealnx.o
53obj-$(CONFIG_TIGON3) += tg3.o 53obj-$(CONFIG_TIGON3) += tg3.o
54obj-$(CONFIG_BNX2) += bnx2.o
54obj-$(CONFIG_TC35815) += tc35815.o 55obj-$(CONFIG_TC35815) += tc35815.o
55obj-$(CONFIG_SK98LIN) += sk98lin/ 56obj-$(CONFIG_SK98LIN) += sk98lin/
56obj-$(CONFIG_SKFP) += skfp/ 57obj-$(CONFIG_SKFP) += skfp/
@@ -187,7 +188,7 @@ obj-$(CONFIG_TR) += tokenring/
187obj-$(CONFIG_WAN) += wan/ 188obj-$(CONFIG_WAN) += wan/
188obj-$(CONFIG_ARCNET) += arcnet/ 189obj-$(CONFIG_ARCNET) += arcnet/
189obj-$(CONFIG_NET_PCMCIA) += pcmcia/ 190obj-$(CONFIG_NET_PCMCIA) += pcmcia/
190obj-$(CONFIG_NET_WIRELESS) += wireless/ 191obj-$(CONFIG_NET_RADIO) += wireless/
191obj-$(CONFIG_NET_TULIP) += tulip/ 192obj-$(CONFIG_NET_TULIP) += tulip/
192obj-$(CONFIG_HAMRADIO) += hamradio/ 193obj-$(CONFIG_HAMRADIO) += hamradio/
193obj-$(CONFIG_IRDA) += irda/ 194obj-$(CONFIG_IRDA) += irda/
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index f2e937abf7b4..b7dd7260cafb 100755
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -738,6 +738,7 @@ static int amd8111e_rx_poll(struct net_device *dev, int * budget)
738 short vtag; 738 short vtag;
739#endif 739#endif
740 int rx_pkt_limit = dev->quota; 740 int rx_pkt_limit = dev->quota;
741 unsigned long flags;
741 742
742 do{ 743 do{
743 /* process receive packets until we use the quota*/ 744 /* process receive packets until we use the quota*/
@@ -841,18 +842,19 @@ static int amd8111e_rx_poll(struct net_device *dev, int * budget)
841 /* Receive descriptor is empty now */ 842 /* Receive descriptor is empty now */
842 dev->quota -= num_rx_pkt; 843 dev->quota -= num_rx_pkt;
843 *budget -= num_rx_pkt; 844 *budget -= num_rx_pkt;
845
846 spin_lock_irqsave(&lp->lock, flags);
844 netif_rx_complete(dev); 847 netif_rx_complete(dev);
845 /* enable receive interrupt */
846 writel(VAL0|RINTEN0, mmio + INTEN0); 848 writel(VAL0|RINTEN0, mmio + INTEN0);
847 writel(VAL2 | RDMD0, mmio + CMD0); 849 writel(VAL2 | RDMD0, mmio + CMD0);
850 spin_unlock_irqrestore(&lp->lock, flags);
848 return 0; 851 return 0;
852
849rx_not_empty: 853rx_not_empty:
850 /* Do not call a netif_rx_complete */ 854 /* Do not call a netif_rx_complete */
851 dev->quota -= num_rx_pkt; 855 dev->quota -= num_rx_pkt;
852 *budget -= num_rx_pkt; 856 *budget -= num_rx_pkt;
853 return 1; 857 return 1;
854
855
856} 858}
857 859
858#else 860#else
@@ -1261,18 +1263,20 @@ static irqreturn_t amd8111e_interrupt(int irq, void *dev_id, struct pt_regs *reg
1261 struct net_device * dev = (struct net_device *) dev_id; 1263 struct net_device * dev = (struct net_device *) dev_id;
1262 struct amd8111e_priv *lp = netdev_priv(dev); 1264 struct amd8111e_priv *lp = netdev_priv(dev);
1263 void __iomem *mmio = lp->mmio; 1265 void __iomem *mmio = lp->mmio;
1264 unsigned int intr0; 1266 unsigned int intr0, intren0;
1265 unsigned int handled = 1; 1267 unsigned int handled = 1;
1266 1268
1267 if(dev == NULL) 1269 if(unlikely(dev == NULL))
1268 return IRQ_NONE; 1270 return IRQ_NONE;
1269 1271
1270 if (regs) spin_lock (&lp->lock); 1272 spin_lock(&lp->lock);
1273
1271 /* disabling interrupt */ 1274 /* disabling interrupt */
1272 writel(INTREN, mmio + CMD0); 1275 writel(INTREN, mmio + CMD0);
1273 1276
1274 /* Read interrupt status */ 1277 /* Read interrupt status */
1275 intr0 = readl(mmio + INT0); 1278 intr0 = readl(mmio + INT0);
1279 intren0 = readl(mmio + INTEN0);
1276 1280
1277 /* Process all the INT event until INTR bit is clear. */ 1281 /* Process all the INT event until INTR bit is clear. */
1278 1282
@@ -1293,11 +1297,11 @@ static irqreturn_t amd8111e_interrupt(int irq, void *dev_id, struct pt_regs *reg
1293 /* Schedule a polling routine */ 1297 /* Schedule a polling routine */
1294 __netif_rx_schedule(dev); 1298 __netif_rx_schedule(dev);
1295 } 1299 }
1296 else { 1300 else if (intren0 & RINTEN0) {
1297 printk("************Driver bug! \ 1301 printk("************Driver bug! \
1298 interrupt while in poll\n"); 1302 interrupt while in poll\n");
1299 /* Fix by disabling interrupts */ 1303 /* Fix by disable receive interrupts */
1300 writel(RINT0, mmio + INT0); 1304 writel(RINTEN0, mmio + INTEN0);
1301 } 1305 }
1302 } 1306 }
1303#else 1307#else
@@ -1321,7 +1325,7 @@ static irqreturn_t amd8111e_interrupt(int irq, void *dev_id, struct pt_regs *reg
1321err_no_interrupt: 1325err_no_interrupt:
1322 writel( VAL0 | INTREN,mmio + CMD0); 1326 writel( VAL0 | INTREN,mmio + CMD0);
1323 1327
1324 if (regs) spin_unlock(&lp->lock); 1328 spin_unlock(&lp->lock);
1325 1329
1326 return IRQ_RETVAL(handled); 1330 return IRQ_RETVAL(handled);
1327} 1331}
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
new file mode 100644
index 000000000000..8acc655ec1e8
--- /dev/null
+++ b/drivers/net/bnx2.c
@@ -0,0 +1,5530 @@
1/* bnx2.c: Broadcom NX2 network driver.
2 *
3 * Copyright (c) 2004, 2005 Broadcom 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.
8 *
9 * Written by: Michael Chan (mchan@broadcom.com)
10 */
11
12#include "bnx2.h"
13#include "bnx2_fw.h"
14
15#define DRV_MODULE_NAME "bnx2"
16#define PFX DRV_MODULE_NAME ": "
17#define DRV_MODULE_VERSION "1.2.19"
18#define DRV_MODULE_RELDATE "May 23, 2005"
19
20#define RUN_AT(x) (jiffies + (x))
21
22/* Time in jiffies before concluding the transmitter is hung. */
23#define TX_TIMEOUT (5*HZ)
24
25static char version[] __devinitdata =
26 "Broadcom NetXtreme II Gigabit Ethernet Driver " DRV_MODULE_NAME " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
27
28MODULE_AUTHOR("Michael Chan <mchan@broadcom.com>");
29MODULE_DESCRIPTION("Broadcom NetXtreme II BCM5706 Driver");
30MODULE_LICENSE("GPL");
31MODULE_VERSION(DRV_MODULE_VERSION);
32
33static int disable_msi = 0;
34
35module_param(disable_msi, int, 0);
36MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
37
38typedef enum {
39 BCM5706 = 0,
40 NC370T,
41 NC370I,
42 BCM5706S,
43 NC370F,
44} board_t;
45
46/* indexed by board_t, above */
47static struct {
48 char *name;
49} board_info[] __devinitdata = {
50 { "Broadcom NetXtreme II BCM5706 1000Base-T" },
51 { "HP NC370T Multifunction Gigabit Server Adapter" },
52 { "HP NC370i Multifunction Gigabit Server Adapter" },
53 { "Broadcom NetXtreme II BCM5706 1000Base-SX" },
54 { "HP NC370F Multifunction Gigabit Server Adapter" },
55 { 0 },
56 };
57
58static struct pci_device_id bnx2_pci_tbl[] = {
59 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706,
60 PCI_VENDOR_ID_HP, 0x3101, 0, 0, NC370T },
61 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706,
62 PCI_VENDOR_ID_HP, 0x3106, 0, 0, NC370I },
63 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706,
64 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706 },
65 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706S,
66 PCI_VENDOR_ID_HP, 0x3102, 0, 0, NC370F },
67 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706S,
68 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706S },
69 { 0, }
70};
71
72static struct flash_spec flash_table[] =
73{
74 /* Slow EEPROM */
75 {0x00000000, 0x40030380, 0x009f0081, 0xa184a053, 0xaf000400,
76 1, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE,
77 SEEPROM_BYTE_ADDR_MASK, SEEPROM_TOTAL_SIZE,
78 "EEPROM - slow"},
79 /* Fast EEPROM */
80 {0x02000000, 0x62008380, 0x009f0081, 0xa184a053, 0xaf000400,
81 1, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE,
82 SEEPROM_BYTE_ADDR_MASK, SEEPROM_TOTAL_SIZE,
83 "EEPROM - fast"},
84 /* ATMEL AT45DB011B (buffered flash) */
85 {0x02000003, 0x6e008173, 0x00570081, 0x68848353, 0xaf000400,
86 1, BUFFERED_FLASH_PAGE_BITS, BUFFERED_FLASH_PAGE_SIZE,
87 BUFFERED_FLASH_BYTE_ADDR_MASK, BUFFERED_FLASH_TOTAL_SIZE,
88 "Buffered flash"},
89 /* Saifun SA25F005 (non-buffered flash) */
90 /* strap, cfg1, & write1 need updates */
91 {0x01000003, 0x5f008081, 0x00050081, 0x03840253, 0xaf020406,
92 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
93 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE,
94 "Non-buffered flash (64kB)"},
95 /* Saifun SA25F010 (non-buffered flash) */
96 /* strap, cfg1, & write1 need updates */
97 {0x00000001, 0x47008081, 0x00050081, 0x03840253, 0xaf020406,
98 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
99 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE*2,
100 "Non-buffered flash (128kB)"},
101 /* Saifun SA25F020 (non-buffered flash) */
102 /* strap, cfg1, & write1 need updates */
103 {0x00000003, 0x4f008081, 0x00050081, 0x03840253, 0xaf020406,
104 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
105 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE*4,
106 "Non-buffered flash (256kB)"},
107};
108
109MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl);
110
111static u32
112bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset)
113{
114 REG_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset);
115 return (REG_RD(bp, BNX2_PCICFG_REG_WINDOW));
116}
117
118static void
119bnx2_reg_wr_ind(struct bnx2 *bp, u32 offset, u32 val)
120{
121 REG_WR(bp, BNX2_PCICFG_REG_WINDOW_ADDRESS, offset);
122 REG_WR(bp, BNX2_PCICFG_REG_WINDOW, val);
123}
124
125static void
126bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
127{
128 offset += cid_addr;
129 REG_WR(bp, BNX2_CTX_DATA_ADR, offset);
130 REG_WR(bp, BNX2_CTX_DATA, val);
131}
132
133static int
134bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
135{
136 u32 val1;
137 int i, ret;
138
139 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) {
140 val1 = REG_RD(bp, BNX2_EMAC_MDIO_MODE);
141 val1 &= ~BNX2_EMAC_MDIO_MODE_AUTO_POLL;
142
143 REG_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
144 REG_RD(bp, BNX2_EMAC_MDIO_MODE);
145
146 udelay(40);
147 }
148
149 val1 = (bp->phy_addr << 21) | (reg << 16) |
150 BNX2_EMAC_MDIO_COMM_COMMAND_READ | BNX2_EMAC_MDIO_COMM_DISEXT |
151 BNX2_EMAC_MDIO_COMM_START_BUSY;
152 REG_WR(bp, BNX2_EMAC_MDIO_COMM, val1);
153
154 for (i = 0; i < 50; i++) {
155 udelay(10);
156
157 val1 = REG_RD(bp, BNX2_EMAC_MDIO_COMM);
158 if (!(val1 & BNX2_EMAC_MDIO_COMM_START_BUSY)) {
159 udelay(5);
160
161 val1 = REG_RD(bp, BNX2_EMAC_MDIO_COMM);
162 val1 &= BNX2_EMAC_MDIO_COMM_DATA;
163
164 break;
165 }
166 }
167
168 if (val1 & BNX2_EMAC_MDIO_COMM_START_BUSY) {
169 *val = 0x0;
170 ret = -EBUSY;
171 }
172 else {
173 *val = val1;
174 ret = 0;
175 }
176
177 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) {
178 val1 = REG_RD(bp, BNX2_EMAC_MDIO_MODE);
179 val1 |= BNX2_EMAC_MDIO_MODE_AUTO_POLL;
180
181 REG_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
182 REG_RD(bp, BNX2_EMAC_MDIO_MODE);
183
184 udelay(40);
185 }
186
187 return ret;
188}
189
190static int
191bnx2_write_phy(struct bnx2 *bp, u32 reg, u32 val)
192{
193 u32 val1;
194 int i, ret;
195
196 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) {
197 val1 = REG_RD(bp, BNX2_EMAC_MDIO_MODE);
198 val1 &= ~BNX2_EMAC_MDIO_MODE_AUTO_POLL;
199
200 REG_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
201 REG_RD(bp, BNX2_EMAC_MDIO_MODE);
202
203 udelay(40);
204 }
205
206 val1 = (bp->phy_addr << 21) | (reg << 16) | val |
207 BNX2_EMAC_MDIO_COMM_COMMAND_WRITE |
208 BNX2_EMAC_MDIO_COMM_START_BUSY | BNX2_EMAC_MDIO_COMM_DISEXT;
209 REG_WR(bp, BNX2_EMAC_MDIO_COMM, val1);
210
211 for (i = 0; i < 50; i++) {
212 udelay(10);
213
214 val1 = REG_RD(bp, BNX2_EMAC_MDIO_COMM);
215 if (!(val1 & BNX2_EMAC_MDIO_COMM_START_BUSY)) {
216 udelay(5);
217 break;
218 }
219 }
220
221 if (val1 & BNX2_EMAC_MDIO_COMM_START_BUSY)
222 ret = -EBUSY;
223 else
224 ret = 0;
225
226 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) {
227 val1 = REG_RD(bp, BNX2_EMAC_MDIO_MODE);
228 val1 |= BNX2_EMAC_MDIO_MODE_AUTO_POLL;
229
230 REG_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
231 REG_RD(bp, BNX2_EMAC_MDIO_MODE);
232
233 udelay(40);
234 }
235
236 return ret;
237}
238
239static void
240bnx2_disable_int(struct bnx2 *bp)
241{
242 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
243 BNX2_PCICFG_INT_ACK_CMD_MASK_INT);
244 REG_RD(bp, BNX2_PCICFG_INT_ACK_CMD);
245}
246
247static void
248bnx2_enable_int(struct bnx2 *bp)
249{
250 u32 val;
251
252 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
253 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | bp->last_status_idx);
254
255 val = REG_RD(bp, BNX2_HC_COMMAND);
256 REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW);
257}
258
259static void
260bnx2_disable_int_sync(struct bnx2 *bp)
261{
262 atomic_inc(&bp->intr_sem);
263 bnx2_disable_int(bp);
264 synchronize_irq(bp->pdev->irq);
265}
266
267static void
268bnx2_netif_stop(struct bnx2 *bp)
269{
270 bnx2_disable_int_sync(bp);
271 if (netif_running(bp->dev)) {
272 netif_poll_disable(bp->dev);
273 netif_tx_disable(bp->dev);
274 bp->dev->trans_start = jiffies; /* prevent tx timeout */
275 }
276}
277
278static void
279bnx2_netif_start(struct bnx2 *bp)
280{
281 if (atomic_dec_and_test(&bp->intr_sem)) {
282 if (netif_running(bp->dev)) {
283 netif_wake_queue(bp->dev);
284 netif_poll_enable(bp->dev);
285 bnx2_enable_int(bp);
286 }
287 }
288}
289
290static void
291bnx2_free_mem(struct bnx2 *bp)
292{
293 if (bp->stats_blk) {
294 pci_free_consistent(bp->pdev, sizeof(struct statistics_block),
295 bp->stats_blk, bp->stats_blk_mapping);
296 bp->stats_blk = NULL;
297 }
298 if (bp->status_blk) {
299 pci_free_consistent(bp->pdev, sizeof(struct status_block),
300 bp->status_blk, bp->status_blk_mapping);
301 bp->status_blk = NULL;
302 }
303 if (bp->tx_desc_ring) {
304 pci_free_consistent(bp->pdev,
305 sizeof(struct tx_bd) * TX_DESC_CNT,
306 bp->tx_desc_ring, bp->tx_desc_mapping);
307 bp->tx_desc_ring = NULL;
308 }
309 if (bp->tx_buf_ring) {
310 kfree(bp->tx_buf_ring);
311 bp->tx_buf_ring = NULL;
312 }
313 if (bp->rx_desc_ring) {
314 pci_free_consistent(bp->pdev,
315 sizeof(struct rx_bd) * RX_DESC_CNT,
316 bp->rx_desc_ring, bp->rx_desc_mapping);
317 bp->rx_desc_ring = NULL;
318 }
319 if (bp->rx_buf_ring) {
320 kfree(bp->rx_buf_ring);
321 bp->rx_buf_ring = NULL;
322 }
323}
324
325static int
326bnx2_alloc_mem(struct bnx2 *bp)
327{
328 bp->tx_buf_ring = kmalloc(sizeof(struct sw_bd) * TX_DESC_CNT,
329 GFP_KERNEL);
330 if (bp->tx_buf_ring == NULL)
331 return -ENOMEM;
332
333 memset(bp->tx_buf_ring, 0, sizeof(struct sw_bd) * TX_DESC_CNT);
334 bp->tx_desc_ring = pci_alloc_consistent(bp->pdev,
335 sizeof(struct tx_bd) *
336 TX_DESC_CNT,
337 &bp->tx_desc_mapping);
338 if (bp->tx_desc_ring == NULL)
339 goto alloc_mem_err;
340
341 bp->rx_buf_ring = kmalloc(sizeof(struct sw_bd) * RX_DESC_CNT,
342 GFP_KERNEL);
343 if (bp->rx_buf_ring == NULL)
344 goto alloc_mem_err;
345
346 memset(bp->rx_buf_ring, 0, sizeof(struct sw_bd) * RX_DESC_CNT);
347 bp->rx_desc_ring = pci_alloc_consistent(bp->pdev,
348 sizeof(struct rx_bd) *
349 RX_DESC_CNT,
350 &bp->rx_desc_mapping);
351 if (bp->rx_desc_ring == NULL)
352 goto alloc_mem_err;
353
354 bp->status_blk = pci_alloc_consistent(bp->pdev,
355 sizeof(struct status_block),
356 &bp->status_blk_mapping);
357 if (bp->status_blk == NULL)
358 goto alloc_mem_err;
359
360 memset(bp->status_blk, 0, sizeof(struct status_block));
361
362 bp->stats_blk = pci_alloc_consistent(bp->pdev,
363 sizeof(struct statistics_block),
364 &bp->stats_blk_mapping);
365 if (bp->stats_blk == NULL)
366 goto alloc_mem_err;
367
368 memset(bp->stats_blk, 0, sizeof(struct statistics_block));
369
370 return 0;
371
372alloc_mem_err:
373 bnx2_free_mem(bp);
374 return -ENOMEM;
375}
376
377static void
378bnx2_report_link(struct bnx2 *bp)
379{
380 if (bp->link_up) {
381 netif_carrier_on(bp->dev);
382 printk(KERN_INFO PFX "%s NIC Link is Up, ", bp->dev->name);
383
384 printk("%d Mbps ", bp->line_speed);
385
386 if (bp->duplex == DUPLEX_FULL)
387 printk("full duplex");
388 else
389 printk("half duplex");
390
391 if (bp->flow_ctrl) {
392 if (bp->flow_ctrl & FLOW_CTRL_RX) {
393 printk(", receive ");
394 if (bp->flow_ctrl & FLOW_CTRL_TX)
395 printk("& transmit ");
396 }
397 else {
398 printk(", transmit ");
399 }
400 printk("flow control ON");
401 }
402 printk("\n");
403 }
404 else {
405 netif_carrier_off(bp->dev);
406 printk(KERN_ERR PFX "%s NIC Link is Down\n", bp->dev->name);
407 }
408}
409
410static void
411bnx2_resolve_flow_ctrl(struct bnx2 *bp)
412{
413 u32 local_adv, remote_adv;
414
415 bp->flow_ctrl = 0;
416 if ((bp->autoneg & (AUTONEG_SPEED | AUTONEG_FLOW_CTRL)) !=
417 (AUTONEG_SPEED | AUTONEG_FLOW_CTRL)) {
418
419 if (bp->duplex == DUPLEX_FULL) {
420 bp->flow_ctrl = bp->req_flow_ctrl;
421 }
422 return;
423 }
424
425 if (bp->duplex != DUPLEX_FULL) {
426 return;
427 }
428
429 bnx2_read_phy(bp, MII_ADVERTISE, &local_adv);
430 bnx2_read_phy(bp, MII_LPA, &remote_adv);
431
432 if (bp->phy_flags & PHY_SERDES_FLAG) {
433 u32 new_local_adv = 0;
434 u32 new_remote_adv = 0;
435
436 if (local_adv & ADVERTISE_1000XPAUSE)
437 new_local_adv |= ADVERTISE_PAUSE_CAP;
438 if (local_adv & ADVERTISE_1000XPSE_ASYM)
439 new_local_adv |= ADVERTISE_PAUSE_ASYM;
440 if (remote_adv & ADVERTISE_1000XPAUSE)
441 new_remote_adv |= ADVERTISE_PAUSE_CAP;
442 if (remote_adv & ADVERTISE_1000XPSE_ASYM)
443 new_remote_adv |= ADVERTISE_PAUSE_ASYM;
444
445 local_adv = new_local_adv;
446 remote_adv = new_remote_adv;
447 }
448
449 /* See Table 28B-3 of 802.3ab-1999 spec. */
450 if (local_adv & ADVERTISE_PAUSE_CAP) {
451 if(local_adv & ADVERTISE_PAUSE_ASYM) {
452 if (remote_adv & ADVERTISE_PAUSE_CAP) {
453 bp->flow_ctrl = FLOW_CTRL_TX | FLOW_CTRL_RX;
454 }
455 else if (remote_adv & ADVERTISE_PAUSE_ASYM) {
456 bp->flow_ctrl = FLOW_CTRL_RX;
457 }
458 }
459 else {
460 if (remote_adv & ADVERTISE_PAUSE_CAP) {
461 bp->flow_ctrl = FLOW_CTRL_TX | FLOW_CTRL_RX;
462 }
463 }
464 }
465 else if (local_adv & ADVERTISE_PAUSE_ASYM) {
466 if ((remote_adv & ADVERTISE_PAUSE_CAP) &&
467 (remote_adv & ADVERTISE_PAUSE_ASYM)) {
468
469 bp->flow_ctrl = FLOW_CTRL_TX;
470 }
471 }
472}
473
474static int
475bnx2_serdes_linkup(struct bnx2 *bp)
476{
477 u32 bmcr, local_adv, remote_adv, common;
478
479 bp->link_up = 1;
480 bp->line_speed = SPEED_1000;
481
482 bnx2_read_phy(bp, MII_BMCR, &bmcr);
483 if (bmcr & BMCR_FULLDPLX) {
484 bp->duplex = DUPLEX_FULL;
485 }
486 else {
487 bp->duplex = DUPLEX_HALF;
488 }
489
490 if (!(bmcr & BMCR_ANENABLE)) {
491 return 0;
492 }
493
494 bnx2_read_phy(bp, MII_ADVERTISE, &local_adv);
495 bnx2_read_phy(bp, MII_LPA, &remote_adv);
496
497 common = local_adv & remote_adv;
498 if (common & (ADVERTISE_1000XHALF | ADVERTISE_1000XFULL)) {
499
500 if (common & ADVERTISE_1000XFULL) {
501 bp->duplex = DUPLEX_FULL;
502 }
503 else {
504 bp->duplex = DUPLEX_HALF;
505 }
506 }
507
508 return 0;
509}
510
511static int
512bnx2_copper_linkup(struct bnx2 *bp)
513{
514 u32 bmcr;
515
516 bnx2_read_phy(bp, MII_BMCR, &bmcr);
517 if (bmcr & BMCR_ANENABLE) {
518 u32 local_adv, remote_adv, common;
519
520 bnx2_read_phy(bp, MII_CTRL1000, &local_adv);
521 bnx2_read_phy(bp, MII_STAT1000, &remote_adv);
522
523 common = local_adv & (remote_adv >> 2);
524 if (common & ADVERTISE_1000FULL) {
525 bp->line_speed = SPEED_1000;
526 bp->duplex = DUPLEX_FULL;
527 }
528 else if (common & ADVERTISE_1000HALF) {
529 bp->line_speed = SPEED_1000;
530 bp->duplex = DUPLEX_HALF;
531 }
532 else {
533 bnx2_read_phy(bp, MII_ADVERTISE, &local_adv);
534 bnx2_read_phy(bp, MII_LPA, &remote_adv);
535
536 common = local_adv & remote_adv;
537 if (common & ADVERTISE_100FULL) {
538 bp->line_speed = SPEED_100;
539 bp->duplex = DUPLEX_FULL;
540 }
541 else if (common & ADVERTISE_100HALF) {
542 bp->line_speed = SPEED_100;
543 bp->duplex = DUPLEX_HALF;
544 }
545 else if (common & ADVERTISE_10FULL) {
546 bp->line_speed = SPEED_10;
547 bp->duplex = DUPLEX_FULL;
548 }
549 else if (common & ADVERTISE_10HALF) {
550 bp->line_speed = SPEED_10;
551 bp->duplex = DUPLEX_HALF;
552 }
553 else {
554 bp->line_speed = 0;
555 bp->link_up = 0;
556 }
557 }
558 }
559 else {
560 if (bmcr & BMCR_SPEED100) {
561 bp->line_speed = SPEED_100;
562 }
563 else {
564 bp->line_speed = SPEED_10;
565 }
566 if (bmcr & BMCR_FULLDPLX) {
567 bp->duplex = DUPLEX_FULL;
568 }
569 else {
570 bp->duplex = DUPLEX_HALF;
571 }
572 }
573
574 return 0;
575}
576
577static int
578bnx2_set_mac_link(struct bnx2 *bp)
579{
580 u32 val;
581
582 REG_WR(bp, BNX2_EMAC_TX_LENGTHS, 0x2620);
583 if (bp->link_up && (bp->line_speed == SPEED_1000) &&
584 (bp->duplex == DUPLEX_HALF)) {
585 REG_WR(bp, BNX2_EMAC_TX_LENGTHS, 0x26ff);
586 }
587
588 /* Configure the EMAC mode register. */
589 val = REG_RD(bp, BNX2_EMAC_MODE);
590
591 val &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX |
592 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK);
593
594 if (bp->link_up) {
595 if (bp->line_speed != SPEED_1000)
596 val |= BNX2_EMAC_MODE_PORT_MII;
597 else
598 val |= BNX2_EMAC_MODE_PORT_GMII;
599 }
600 else {
601 val |= BNX2_EMAC_MODE_PORT_GMII;
602 }
603
604 /* Set the MAC to operate in the appropriate duplex mode. */
605 if (bp->duplex == DUPLEX_HALF)
606 val |= BNX2_EMAC_MODE_HALF_DUPLEX;
607 REG_WR(bp, BNX2_EMAC_MODE, val);
608
609 /* Enable/disable rx PAUSE. */
610 bp->rx_mode &= ~BNX2_EMAC_RX_MODE_FLOW_EN;
611
612 if (bp->flow_ctrl & FLOW_CTRL_RX)
613 bp->rx_mode |= BNX2_EMAC_RX_MODE_FLOW_EN;
614 REG_WR(bp, BNX2_EMAC_RX_MODE, bp->rx_mode);
615
616 /* Enable/disable tx PAUSE. */
617 val = REG_RD(bp, BNX2_EMAC_TX_MODE);
618 val &= ~BNX2_EMAC_TX_MODE_FLOW_EN;
619
620 if (bp->flow_ctrl & FLOW_CTRL_TX)
621 val |= BNX2_EMAC_TX_MODE_FLOW_EN;
622 REG_WR(bp, BNX2_EMAC_TX_MODE, val);
623
624 /* Acknowledge the interrupt. */
625 REG_WR(bp, BNX2_EMAC_STATUS, BNX2_EMAC_STATUS_LINK_CHANGE);
626
627 return 0;
628}
629
630static int
631bnx2_set_link(struct bnx2 *bp)
632{
633 u32 bmsr;
634 u8 link_up;
635
636 if (bp->loopback == MAC_LOOPBACK) {
637 bp->link_up = 1;
638 return 0;
639 }
640
641 link_up = bp->link_up;
642
643 bnx2_read_phy(bp, MII_BMSR, &bmsr);
644 bnx2_read_phy(bp, MII_BMSR, &bmsr);
645
646 if ((bp->phy_flags & PHY_SERDES_FLAG) &&
647 (CHIP_NUM(bp) == CHIP_NUM_5706)) {
648 u32 val;
649
650 val = REG_RD(bp, BNX2_EMAC_STATUS);
651 if (val & BNX2_EMAC_STATUS_LINK)
652 bmsr |= BMSR_LSTATUS;
653 else
654 bmsr &= ~BMSR_LSTATUS;
655 }
656
657 if (bmsr & BMSR_LSTATUS) {
658 bp->link_up = 1;
659
660 if (bp->phy_flags & PHY_SERDES_FLAG) {
661 bnx2_serdes_linkup(bp);
662 }
663 else {
664 bnx2_copper_linkup(bp);
665 }
666 bnx2_resolve_flow_ctrl(bp);
667 }
668 else {
669 if ((bp->phy_flags & PHY_SERDES_FLAG) &&
670 (bp->autoneg & AUTONEG_SPEED)) {
671
672 u32 bmcr;
673
674 bnx2_read_phy(bp, MII_BMCR, &bmcr);
675 if (!(bmcr & BMCR_ANENABLE)) {
676 bnx2_write_phy(bp, MII_BMCR, bmcr |
677 BMCR_ANENABLE);
678 }
679 }
680 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
681 bp->link_up = 0;
682 }
683
684 if (bp->link_up != link_up) {
685 bnx2_report_link(bp);
686 }
687
688 bnx2_set_mac_link(bp);
689
690 return 0;
691}
692
693static int
694bnx2_reset_phy(struct bnx2 *bp)
695{
696 int i;
697 u32 reg;
698
699 bnx2_write_phy(bp, MII_BMCR, BMCR_RESET);
700
701#define PHY_RESET_MAX_WAIT 100
702 for (i = 0; i < PHY_RESET_MAX_WAIT; i++) {
703 udelay(10);
704
705 bnx2_read_phy(bp, MII_BMCR, &reg);
706 if (!(reg & BMCR_RESET)) {
707 udelay(20);
708 break;
709 }
710 }
711 if (i == PHY_RESET_MAX_WAIT) {
712 return -EBUSY;
713 }
714 return 0;
715}
716
717static u32
718bnx2_phy_get_pause_adv(struct bnx2 *bp)
719{
720 u32 adv = 0;
721
722 if ((bp->req_flow_ctrl & (FLOW_CTRL_RX | FLOW_CTRL_TX)) ==
723 (FLOW_CTRL_RX | FLOW_CTRL_TX)) {
724
725 if (bp->phy_flags & PHY_SERDES_FLAG) {
726 adv = ADVERTISE_1000XPAUSE;
727 }
728 else {
729 adv = ADVERTISE_PAUSE_CAP;
730 }
731 }
732 else if (bp->req_flow_ctrl & FLOW_CTRL_TX) {
733 if (bp->phy_flags & PHY_SERDES_FLAG) {
734 adv = ADVERTISE_1000XPSE_ASYM;
735 }
736 else {
737 adv = ADVERTISE_PAUSE_ASYM;
738 }
739 }
740 else if (bp->req_flow_ctrl & FLOW_CTRL_RX) {
741 if (bp->phy_flags & PHY_SERDES_FLAG) {
742 adv = ADVERTISE_1000XPAUSE | ADVERTISE_1000XPSE_ASYM;
743 }
744 else {
745 adv = ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
746 }
747 }
748 return adv;
749}
750
751static int
752bnx2_setup_serdes_phy(struct bnx2 *bp)
753{
754 u32 adv, bmcr;
755 u32 new_adv = 0;
756
757 if (!(bp->autoneg & AUTONEG_SPEED)) {
758 u32 new_bmcr;
759
760 bnx2_read_phy(bp, MII_BMCR, &bmcr);
761 new_bmcr = bmcr & ~BMCR_ANENABLE;
762 new_bmcr |= BMCR_SPEED1000;
763 if (bp->req_duplex == DUPLEX_FULL) {
764 new_bmcr |= BMCR_FULLDPLX;
765 }
766 else {
767 new_bmcr &= ~BMCR_FULLDPLX;
768 }
769 if (new_bmcr != bmcr) {
770 /* Force a link down visible on the other side */
771 if (bp->link_up) {
772 bnx2_read_phy(bp, MII_ADVERTISE, &adv);
773 adv &= ~(ADVERTISE_1000XFULL |
774 ADVERTISE_1000XHALF);
775 bnx2_write_phy(bp, MII_ADVERTISE, adv);
776 bnx2_write_phy(bp, MII_BMCR, bmcr |
777 BMCR_ANRESTART | BMCR_ANENABLE);
778
779 bp->link_up = 0;
780 netif_carrier_off(bp->dev);
781 }
782 bnx2_write_phy(bp, MII_BMCR, new_bmcr);
783 }
784 return 0;
785 }
786
787 if (bp->advertising & ADVERTISED_1000baseT_Full)
788 new_adv |= ADVERTISE_1000XFULL;
789
790 new_adv |= bnx2_phy_get_pause_adv(bp);
791
792 bnx2_read_phy(bp, MII_ADVERTISE, &adv);
793 bnx2_read_phy(bp, MII_BMCR, &bmcr);
794
795 bp->serdes_an_pending = 0;
796 if ((adv != new_adv) || ((bmcr & BMCR_ANENABLE) == 0)) {
797 /* Force a link down visible on the other side */
798 if (bp->link_up) {
799 int i;
800
801 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK);
802 for (i = 0; i < 110; i++) {
803 udelay(100);
804 }
805 }
806
807 bnx2_write_phy(bp, MII_ADVERTISE, new_adv);
808 bnx2_write_phy(bp, MII_BMCR, bmcr | BMCR_ANRESTART |
809 BMCR_ANENABLE);
810 bp->serdes_an_pending = SERDES_AN_TIMEOUT / bp->timer_interval;
811 }
812
813 return 0;
814}
815
816#define ETHTOOL_ALL_FIBRE_SPEED \
817 (ADVERTISED_1000baseT_Full)
818
819#define ETHTOOL_ALL_COPPER_SPEED \
820 (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full | \
821 ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | \
822 ADVERTISED_1000baseT_Full)
823
824#define PHY_ALL_10_100_SPEED (ADVERTISE_10HALF | ADVERTISE_10FULL | \
825 ADVERTISE_100HALF | ADVERTISE_100FULL | ADVERTISE_CSMA)
826
827#define PHY_ALL_1000_SPEED (ADVERTISE_1000HALF | ADVERTISE_1000FULL)
828
829static int
830bnx2_setup_copper_phy(struct bnx2 *bp)
831{
832 u32 bmcr;
833 u32 new_bmcr;
834
835 bnx2_read_phy(bp, MII_BMCR, &bmcr);
836
837 if (bp->autoneg & AUTONEG_SPEED) {
838 u32 adv_reg, adv1000_reg;
839 u32 new_adv_reg = 0;
840 u32 new_adv1000_reg = 0;
841
842 bnx2_read_phy(bp, MII_ADVERTISE, &adv_reg);
843 adv_reg &= (PHY_ALL_10_100_SPEED | ADVERTISE_PAUSE_CAP |
844 ADVERTISE_PAUSE_ASYM);
845
846 bnx2_read_phy(bp, MII_CTRL1000, &adv1000_reg);
847 adv1000_reg &= PHY_ALL_1000_SPEED;
848
849 if (bp->advertising & ADVERTISED_10baseT_Half)
850 new_adv_reg |= ADVERTISE_10HALF;
851 if (bp->advertising & ADVERTISED_10baseT_Full)
852 new_adv_reg |= ADVERTISE_10FULL;
853 if (bp->advertising & ADVERTISED_100baseT_Half)
854 new_adv_reg |= ADVERTISE_100HALF;
855 if (bp->advertising & ADVERTISED_100baseT_Full)
856 new_adv_reg |= ADVERTISE_100FULL;
857 if (bp->advertising & ADVERTISED_1000baseT_Full)
858 new_adv1000_reg |= ADVERTISE_1000FULL;
859
860 new_adv_reg |= ADVERTISE_CSMA;
861
862 new_adv_reg |= bnx2_phy_get_pause_adv(bp);
863
864 if ((adv1000_reg != new_adv1000_reg) ||
865 (adv_reg != new_adv_reg) ||
866 ((bmcr & BMCR_ANENABLE) == 0)) {
867
868 bnx2_write_phy(bp, MII_ADVERTISE, new_adv_reg);
869 bnx2_write_phy(bp, MII_CTRL1000, new_adv1000_reg);
870 bnx2_write_phy(bp, MII_BMCR, BMCR_ANRESTART |
871 BMCR_ANENABLE);
872 }
873 else if (bp->link_up) {
874 /* Flow ctrl may have changed from auto to forced */
875 /* or vice-versa. */
876
877 bnx2_resolve_flow_ctrl(bp);
878 bnx2_set_mac_link(bp);
879 }
880 return 0;
881 }
882
883 new_bmcr = 0;
884 if (bp->req_line_speed == SPEED_100) {
885 new_bmcr |= BMCR_SPEED100;
886 }
887 if (bp->req_duplex == DUPLEX_FULL) {
888 new_bmcr |= BMCR_FULLDPLX;
889 }
890 if (new_bmcr != bmcr) {
891 u32 bmsr;
892 int i = 0;
893
894 bnx2_read_phy(bp, MII_BMSR, &bmsr);
895 bnx2_read_phy(bp, MII_BMSR, &bmsr);
896
897 if (bmsr & BMSR_LSTATUS) {
898 /* Force link down */
899 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK);
900 do {
901 udelay(100);
902 bnx2_read_phy(bp, MII_BMSR, &bmsr);
903 bnx2_read_phy(bp, MII_BMSR, &bmsr);
904 i++;
905 } while ((bmsr & BMSR_LSTATUS) && (i < 620));
906 }
907
908 bnx2_write_phy(bp, MII_BMCR, new_bmcr);
909
910 /* Normally, the new speed is setup after the link has
911 * gone down and up again. In some cases, link will not go
912 * down so we need to set up the new speed here.
913 */
914 if (bmsr & BMSR_LSTATUS) {
915 bp->line_speed = bp->req_line_speed;
916 bp->duplex = bp->req_duplex;
917 bnx2_resolve_flow_ctrl(bp);
918 bnx2_set_mac_link(bp);
919 }
920 }
921 return 0;
922}
923
924static int
925bnx2_setup_phy(struct bnx2 *bp)
926{
927 if (bp->loopback == MAC_LOOPBACK)
928 return 0;
929
930 if (bp->phy_flags & PHY_SERDES_FLAG) {
931 return (bnx2_setup_serdes_phy(bp));
932 }
933 else {
934 return (bnx2_setup_copper_phy(bp));
935 }
936}
937
938static int
939bnx2_init_serdes_phy(struct bnx2 *bp)
940{
941 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
942
943 if (CHIP_NUM(bp) == CHIP_NUM_5706) {
944 REG_WR(bp, BNX2_MISC_UNUSED0, 0x300);
945 }
946
947 if (bp->dev->mtu > 1500) {
948 u32 val;
949
950 /* Set extended packet length bit */
951 bnx2_write_phy(bp, 0x18, 0x7);
952 bnx2_read_phy(bp, 0x18, &val);
953 bnx2_write_phy(bp, 0x18, (val & 0xfff8) | 0x4000);
954
955 bnx2_write_phy(bp, 0x1c, 0x6c00);
956 bnx2_read_phy(bp, 0x1c, &val);
957 bnx2_write_phy(bp, 0x1c, (val & 0x3ff) | 0xec02);
958 }
959 else {
960 u32 val;
961
962 bnx2_write_phy(bp, 0x18, 0x7);
963 bnx2_read_phy(bp, 0x18, &val);
964 bnx2_write_phy(bp, 0x18, val & ~0x4007);
965
966 bnx2_write_phy(bp, 0x1c, 0x6c00);
967 bnx2_read_phy(bp, 0x1c, &val);
968 bnx2_write_phy(bp, 0x1c, (val & 0x3fd) | 0xec00);
969 }
970
971 return 0;
972}
973
974static int
975bnx2_init_copper_phy(struct bnx2 *bp)
976{
977 bp->phy_flags |= PHY_CRC_FIX_FLAG;
978
979 if (bp->phy_flags & PHY_CRC_FIX_FLAG) {
980 bnx2_write_phy(bp, 0x18, 0x0c00);
981 bnx2_write_phy(bp, 0x17, 0x000a);
982 bnx2_write_phy(bp, 0x15, 0x310b);
983 bnx2_write_phy(bp, 0x17, 0x201f);
984 bnx2_write_phy(bp, 0x15, 0x9506);
985 bnx2_write_phy(bp, 0x17, 0x401f);
986 bnx2_write_phy(bp, 0x15, 0x14e2);
987 bnx2_write_phy(bp, 0x18, 0x0400);
988 }
989
990 if (bp->dev->mtu > 1500) {
991 u32 val;
992
993 /* Set extended packet length bit */
994 bnx2_write_phy(bp, 0x18, 0x7);
995 bnx2_read_phy(bp, 0x18, &val);
996 bnx2_write_phy(bp, 0x18, val | 0x4000);
997
998 bnx2_read_phy(bp, 0x10, &val);
999 bnx2_write_phy(bp, 0x10, val | 0x1);
1000 }
1001 else {
1002 u32 val;
1003
1004 bnx2_write_phy(bp, 0x18, 0x7);
1005 bnx2_read_phy(bp, 0x18, &val);
1006 bnx2_write_phy(bp, 0x18, val & ~0x4007);
1007
1008 bnx2_read_phy(bp, 0x10, &val);
1009 bnx2_write_phy(bp, 0x10, val & ~0x1);
1010 }
1011
1012 return 0;
1013}
1014
1015
1016static int
1017bnx2_init_phy(struct bnx2 *bp)
1018{
1019 u32 val;
1020 int rc = 0;
1021
1022 bp->phy_flags &= ~PHY_INT_MODE_MASK_FLAG;
1023 bp->phy_flags |= PHY_INT_MODE_LINK_READY_FLAG;
1024
1025 REG_WR(bp, BNX2_EMAC_ATTENTION_ENA, BNX2_EMAC_ATTENTION_ENA_LINK);
1026
1027 bnx2_reset_phy(bp);
1028
1029 bnx2_read_phy(bp, MII_PHYSID1, &val);
1030 bp->phy_id = val << 16;
1031 bnx2_read_phy(bp, MII_PHYSID2, &val);
1032 bp->phy_id |= val & 0xffff;
1033
1034 if (bp->phy_flags & PHY_SERDES_FLAG) {
1035 rc = bnx2_init_serdes_phy(bp);
1036 }
1037 else {
1038 rc = bnx2_init_copper_phy(bp);
1039 }
1040
1041 bnx2_setup_phy(bp);
1042
1043 return rc;
1044}
1045
1046static int
1047bnx2_set_mac_loopback(struct bnx2 *bp)
1048{
1049 u32 mac_mode;
1050
1051 mac_mode = REG_RD(bp, BNX2_EMAC_MODE);
1052 mac_mode &= ~BNX2_EMAC_MODE_PORT;
1053 mac_mode |= BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK;
1054 REG_WR(bp, BNX2_EMAC_MODE, mac_mode);
1055 bp->link_up = 1;
1056 return 0;
1057}
1058
1059static int
1060bnx2_fw_sync(struct bnx2 *bp, u32 msg_data)
1061{
1062 int i;
1063 u32 val;
1064
1065 if (bp->fw_timed_out)
1066 return -EBUSY;
1067
1068 bp->fw_wr_seq++;
1069 msg_data |= bp->fw_wr_seq;
1070
1071 REG_WR_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_DRV_MB, msg_data);
1072
1073 /* wait for an acknowledgement. */
1074 for (i = 0; i < (FW_ACK_TIME_OUT_MS * 1000)/5; i++) {
1075 udelay(5);
1076
1077 val = REG_RD_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_FW_MB);
1078
1079 if ((val & BNX2_FW_MSG_ACK) == (msg_data & BNX2_DRV_MSG_SEQ))
1080 break;
1081 }
1082
1083 /* If we timed out, inform the firmware that this is the case. */
1084 if (((val & BNX2_FW_MSG_ACK) != (msg_data & BNX2_DRV_MSG_SEQ)) &&
1085 ((msg_data & BNX2_DRV_MSG_DATA) != BNX2_DRV_MSG_DATA_WAIT0)) {
1086
1087 msg_data &= ~BNX2_DRV_MSG_CODE;
1088 msg_data |= BNX2_DRV_MSG_CODE_FW_TIMEOUT;
1089
1090 REG_WR_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_DRV_MB, msg_data);
1091
1092 bp->fw_timed_out = 1;
1093
1094 return -EBUSY;
1095 }
1096
1097 return 0;
1098}
1099
1100static void
1101bnx2_init_context(struct bnx2 *bp)
1102{
1103 u32 vcid;
1104
1105 vcid = 96;
1106 while (vcid) {
1107 u32 vcid_addr, pcid_addr, offset;
1108
1109 vcid--;
1110
1111 if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
1112 u32 new_vcid;
1113
1114 vcid_addr = GET_PCID_ADDR(vcid);
1115 if (vcid & 0x8) {
1116 new_vcid = 0x60 + (vcid & 0xf0) + (vcid & 0x7);
1117 }
1118 else {
1119 new_vcid = vcid;
1120 }
1121 pcid_addr = GET_PCID_ADDR(new_vcid);
1122 }
1123 else {
1124 vcid_addr = GET_CID_ADDR(vcid);
1125 pcid_addr = vcid_addr;
1126 }
1127
1128 REG_WR(bp, BNX2_CTX_VIRT_ADDR, 0x00);
1129 REG_WR(bp, BNX2_CTX_PAGE_TBL, pcid_addr);
1130
1131 /* Zero out the context. */
1132 for (offset = 0; offset < PHY_CTX_SIZE; offset += 4) {
1133 CTX_WR(bp, 0x00, offset, 0);
1134 }
1135
1136 REG_WR(bp, BNX2_CTX_VIRT_ADDR, vcid_addr);
1137 REG_WR(bp, BNX2_CTX_PAGE_TBL, pcid_addr);
1138 }
1139}
1140
1141static int
1142bnx2_alloc_bad_rbuf(struct bnx2 *bp)
1143{
1144 u16 *good_mbuf;
1145 u32 good_mbuf_cnt;
1146 u32 val;
1147
1148 good_mbuf = kmalloc(512 * sizeof(u16), GFP_KERNEL);
1149 if (good_mbuf == NULL) {
1150 printk(KERN_ERR PFX "Failed to allocate memory in "
1151 "bnx2_alloc_bad_rbuf\n");
1152 return -ENOMEM;
1153 }
1154
1155 REG_WR(bp, BNX2_MISC_ENABLE_SET_BITS,
1156 BNX2_MISC_ENABLE_SET_BITS_RX_MBUF_ENABLE);
1157
1158 good_mbuf_cnt = 0;
1159
1160 /* Allocate a bunch of mbufs and save the good ones in an array. */
1161 val = REG_RD_IND(bp, BNX2_RBUF_STATUS1);
1162 while (val & BNX2_RBUF_STATUS1_FREE_COUNT) {
1163 REG_WR_IND(bp, BNX2_RBUF_COMMAND, BNX2_RBUF_COMMAND_ALLOC_REQ);
1164
1165 val = REG_RD_IND(bp, BNX2_RBUF_FW_BUF_ALLOC);
1166
1167 val &= BNX2_RBUF_FW_BUF_ALLOC_VALUE;
1168
1169 /* The addresses with Bit 9 set are bad memory blocks. */
1170 if (!(val & (1 << 9))) {
1171 good_mbuf[good_mbuf_cnt] = (u16) val;
1172 good_mbuf_cnt++;
1173 }
1174
1175 val = REG_RD_IND(bp, BNX2_RBUF_STATUS1);
1176 }
1177
1178 /* Free the good ones back to the mbuf pool thus discarding
1179 * all the bad ones. */
1180 while (good_mbuf_cnt) {
1181 good_mbuf_cnt--;
1182
1183 val = good_mbuf[good_mbuf_cnt];
1184 val = (val << 9) | val | 1;
1185
1186 REG_WR_IND(bp, BNX2_RBUF_FW_BUF_FREE, val);
1187 }
1188 kfree(good_mbuf);
1189 return 0;
1190}
1191
1192static void
1193bnx2_set_mac_addr(struct bnx2 *bp)
1194{
1195 u32 val;
1196 u8 *mac_addr = bp->dev->dev_addr;
1197
1198 val = (mac_addr[0] << 8) | mac_addr[1];
1199
1200 REG_WR(bp, BNX2_EMAC_MAC_MATCH0, val);
1201
1202 val = (mac_addr[2] << 24) | (mac_addr[3] << 16) |
1203 (mac_addr[4] << 8) | mac_addr[5];
1204
1205 REG_WR(bp, BNX2_EMAC_MAC_MATCH1, val);
1206}
1207
1208static inline int
1209bnx2_alloc_rx_skb(struct bnx2 *bp, u16 index)
1210{
1211 struct sk_buff *skb;
1212 struct sw_bd *rx_buf = &bp->rx_buf_ring[index];
1213 dma_addr_t mapping;
1214 struct rx_bd *rxbd = &bp->rx_desc_ring[index];
1215 unsigned long align;
1216
1217 skb = dev_alloc_skb(bp->rx_buf_size);
1218 if (skb == NULL) {
1219 return -ENOMEM;
1220 }
1221
1222 if (unlikely((align = (unsigned long) skb->data & 0x7))) {
1223 skb_reserve(skb, 8 - align);
1224 }
1225
1226 skb->dev = bp->dev;
1227 mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size,
1228 PCI_DMA_FROMDEVICE);
1229
1230 rx_buf->skb = skb;
1231 pci_unmap_addr_set(rx_buf, mapping, mapping);
1232
1233 rxbd->rx_bd_haddr_hi = (u64) mapping >> 32;
1234 rxbd->rx_bd_haddr_lo = (u64) mapping & 0xffffffff;
1235
1236 bp->rx_prod_bseq += bp->rx_buf_use_size;
1237
1238 return 0;
1239}
1240
1241static void
1242bnx2_phy_int(struct bnx2 *bp)
1243{
1244 u32 new_link_state, old_link_state;
1245
1246 new_link_state = bp->status_blk->status_attn_bits &
1247 STATUS_ATTN_BITS_LINK_STATE;
1248 old_link_state = bp->status_blk->status_attn_bits_ack &
1249 STATUS_ATTN_BITS_LINK_STATE;
1250 if (new_link_state != old_link_state) {
1251 if (new_link_state) {
1252 REG_WR(bp, BNX2_PCICFG_STATUS_BIT_SET_CMD,
1253 STATUS_ATTN_BITS_LINK_STATE);
1254 }
1255 else {
1256 REG_WR(bp, BNX2_PCICFG_STATUS_BIT_CLEAR_CMD,
1257 STATUS_ATTN_BITS_LINK_STATE);
1258 }
1259 bnx2_set_link(bp);
1260 }
1261}
1262
1263static void
1264bnx2_tx_int(struct bnx2 *bp)
1265{
1266 u16 hw_cons, sw_cons, sw_ring_cons;
1267 int tx_free_bd = 0;
1268
1269 hw_cons = bp->status_blk->status_tx_quick_consumer_index0;
1270 if ((hw_cons & MAX_TX_DESC_CNT) == MAX_TX_DESC_CNT) {
1271 hw_cons++;
1272 }
1273 sw_cons = bp->tx_cons;
1274
1275 while (sw_cons != hw_cons) {
1276 struct sw_bd *tx_buf;
1277 struct sk_buff *skb;
1278 int i, last;
1279
1280 sw_ring_cons = TX_RING_IDX(sw_cons);
1281
1282 tx_buf = &bp->tx_buf_ring[sw_ring_cons];
1283 skb = tx_buf->skb;
1284#ifdef BCM_TSO
1285 /* partial BD completions possible with TSO packets */
1286 if (skb_shinfo(skb)->tso_size) {
1287 u16 last_idx, last_ring_idx;
1288
1289 last_idx = sw_cons +
1290 skb_shinfo(skb)->nr_frags + 1;
1291 last_ring_idx = sw_ring_cons +
1292 skb_shinfo(skb)->nr_frags + 1;
1293 if (unlikely(last_ring_idx >= MAX_TX_DESC_CNT)) {
1294 last_idx++;
1295 }
1296 if (((s16) ((s16) last_idx - (s16) hw_cons)) > 0) {
1297 break;
1298 }
1299 }
1300#endif
1301 pci_unmap_single(bp->pdev, pci_unmap_addr(tx_buf, mapping),
1302 skb_headlen(skb), PCI_DMA_TODEVICE);
1303
1304 tx_buf->skb = NULL;
1305 last = skb_shinfo(skb)->nr_frags;
1306
1307 for (i = 0; i < last; i++) {
1308 sw_cons = NEXT_TX_BD(sw_cons);
1309
1310 pci_unmap_page(bp->pdev,
1311 pci_unmap_addr(
1312 &bp->tx_buf_ring[TX_RING_IDX(sw_cons)],
1313 mapping),
1314 skb_shinfo(skb)->frags[i].size,
1315 PCI_DMA_TODEVICE);
1316 }
1317
1318 sw_cons = NEXT_TX_BD(sw_cons);
1319
1320 tx_free_bd += last + 1;
1321
1322 dev_kfree_skb_irq(skb);
1323
1324 hw_cons = bp->status_blk->status_tx_quick_consumer_index0;
1325 if ((hw_cons & MAX_TX_DESC_CNT) == MAX_TX_DESC_CNT) {
1326 hw_cons++;
1327 }
1328 }
1329
1330 atomic_add(tx_free_bd, &bp->tx_avail_bd);
1331
1332 if (unlikely(netif_queue_stopped(bp->dev))) {
1333 unsigned long flags;
1334
1335 spin_lock_irqsave(&bp->tx_lock, flags);
1336 if ((netif_queue_stopped(bp->dev)) &&
1337 (atomic_read(&bp->tx_avail_bd) > MAX_SKB_FRAGS)) {
1338
1339 netif_wake_queue(bp->dev);
1340 }
1341 spin_unlock_irqrestore(&bp->tx_lock, flags);
1342 }
1343
1344 bp->tx_cons = sw_cons;
1345
1346}
1347
1348static inline void
1349bnx2_reuse_rx_skb(struct bnx2 *bp, struct sk_buff *skb,
1350 u16 cons, u16 prod)
1351{
1352 struct sw_bd *cons_rx_buf = &bp->rx_buf_ring[cons];
1353 struct sw_bd *prod_rx_buf = &bp->rx_buf_ring[prod];
1354 struct rx_bd *cons_bd = &bp->rx_desc_ring[cons];
1355 struct rx_bd *prod_bd = &bp->rx_desc_ring[prod];
1356
1357 pci_dma_sync_single_for_device(bp->pdev,
1358 pci_unmap_addr(cons_rx_buf, mapping),
1359 bp->rx_offset + RX_COPY_THRESH, PCI_DMA_FROMDEVICE);
1360
1361 prod_rx_buf->skb = cons_rx_buf->skb;
1362 pci_unmap_addr_set(prod_rx_buf, mapping,
1363 pci_unmap_addr(cons_rx_buf, mapping));
1364
1365 memcpy(prod_bd, cons_bd, 8);
1366
1367 bp->rx_prod_bseq += bp->rx_buf_use_size;
1368
1369}
1370
1371static int
1372bnx2_rx_int(struct bnx2 *bp, int budget)
1373{
1374 u16 hw_cons, sw_cons, sw_ring_cons, sw_prod, sw_ring_prod;
1375 struct l2_fhdr *rx_hdr;
1376 int rx_pkt = 0;
1377
1378 hw_cons = bp->status_blk->status_rx_quick_consumer_index0;
1379 if ((hw_cons & MAX_RX_DESC_CNT) == MAX_RX_DESC_CNT) {
1380 hw_cons++;
1381 }
1382 sw_cons = bp->rx_cons;
1383 sw_prod = bp->rx_prod;
1384
1385 /* Memory barrier necessary as speculative reads of the rx
1386 * buffer can be ahead of the index in the status block
1387 */
1388 rmb();
1389 while (sw_cons != hw_cons) {
1390 unsigned int len;
1391 u16 status;
1392 struct sw_bd *rx_buf;
1393 struct sk_buff *skb;
1394
1395 sw_ring_cons = RX_RING_IDX(sw_cons);
1396 sw_ring_prod = RX_RING_IDX(sw_prod);
1397
1398 rx_buf = &bp->rx_buf_ring[sw_ring_cons];
1399 skb = rx_buf->skb;
1400 pci_dma_sync_single_for_cpu(bp->pdev,
1401 pci_unmap_addr(rx_buf, mapping),
1402 bp->rx_offset + RX_COPY_THRESH, PCI_DMA_FROMDEVICE);
1403
1404 rx_hdr = (struct l2_fhdr *) skb->data;
1405 len = rx_hdr->l2_fhdr_pkt_len - 4;
1406
1407 if (rx_hdr->l2_fhdr_errors &
1408 (L2_FHDR_ERRORS_BAD_CRC |
1409 L2_FHDR_ERRORS_PHY_DECODE |
1410 L2_FHDR_ERRORS_ALIGNMENT |
1411 L2_FHDR_ERRORS_TOO_SHORT |
1412 L2_FHDR_ERRORS_GIANT_FRAME)) {
1413
1414 goto reuse_rx;
1415 }
1416
1417 /* Since we don't have a jumbo ring, copy small packets
1418 * if mtu > 1500
1419 */
1420 if ((bp->dev->mtu > 1500) && (len <= RX_COPY_THRESH)) {
1421 struct sk_buff *new_skb;
1422
1423 new_skb = dev_alloc_skb(len + 2);
1424 if (new_skb == NULL)
1425 goto reuse_rx;
1426
1427 /* aligned copy */
1428 memcpy(new_skb->data,
1429 skb->data + bp->rx_offset - 2,
1430 len + 2);
1431
1432 skb_reserve(new_skb, 2);
1433 skb_put(new_skb, len);
1434 new_skb->dev = bp->dev;
1435
1436 bnx2_reuse_rx_skb(bp, skb,
1437 sw_ring_cons, sw_ring_prod);
1438
1439 skb = new_skb;
1440 }
1441 else if (bnx2_alloc_rx_skb(bp, sw_ring_prod) == 0) {
1442 pci_unmap_single(bp->pdev,
1443 pci_unmap_addr(rx_buf, mapping),
1444 bp->rx_buf_use_size, PCI_DMA_FROMDEVICE);
1445
1446 skb_reserve(skb, bp->rx_offset);
1447 skb_put(skb, len);
1448 }
1449 else {
1450reuse_rx:
1451 bnx2_reuse_rx_skb(bp, skb,
1452 sw_ring_cons, sw_ring_prod);
1453 goto next_rx;
1454 }
1455
1456 skb->protocol = eth_type_trans(skb, bp->dev);
1457
1458 if ((len > (bp->dev->mtu + ETH_HLEN)) &&
1459 (htons(skb->protocol) != 0x8100)) {
1460
1461 dev_kfree_skb_irq(skb);
1462 goto next_rx;
1463
1464 }
1465
1466 status = rx_hdr->l2_fhdr_status;
1467 skb->ip_summed = CHECKSUM_NONE;
1468 if (bp->rx_csum &&
1469 (status & (L2_FHDR_STATUS_TCP_SEGMENT |
1470 L2_FHDR_STATUS_UDP_DATAGRAM))) {
1471
1472 u16 cksum = rx_hdr->l2_fhdr_tcp_udp_xsum;
1473
1474 if (cksum == 0xffff)
1475 skb->ip_summed = CHECKSUM_UNNECESSARY;
1476 }
1477
1478#ifdef BCM_VLAN
1479 if ((status & L2_FHDR_STATUS_L2_VLAN_TAG) && (bp->vlgrp != 0)) {
1480 vlan_hwaccel_receive_skb(skb, bp->vlgrp,
1481 rx_hdr->l2_fhdr_vlan_tag);
1482 }
1483 else
1484#endif
1485 netif_receive_skb(skb);
1486
1487 bp->dev->last_rx = jiffies;
1488 rx_pkt++;
1489
1490next_rx:
1491 rx_buf->skb = NULL;
1492
1493 sw_cons = NEXT_RX_BD(sw_cons);
1494 sw_prod = NEXT_RX_BD(sw_prod);
1495
1496 if ((rx_pkt == budget))
1497 break;
1498 }
1499 bp->rx_cons = sw_cons;
1500 bp->rx_prod = sw_prod;
1501
1502 REG_WR16(bp, MB_RX_CID_ADDR + BNX2_L2CTX_HOST_BDIDX, sw_prod);
1503
1504 REG_WR(bp, MB_RX_CID_ADDR + BNX2_L2CTX_HOST_BSEQ, bp->rx_prod_bseq);
1505
1506 mmiowb();
1507
1508 return rx_pkt;
1509
1510}
1511
1512/* MSI ISR - The only difference between this and the INTx ISR
1513 * is that the MSI interrupt is always serviced.
1514 */
1515static irqreturn_t
1516bnx2_msi(int irq, void *dev_instance, struct pt_regs *regs)
1517{
1518 struct net_device *dev = dev_instance;
1519 struct bnx2 *bp = dev->priv;
1520
1521 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
1522 BNX2_PCICFG_INT_ACK_CMD_USE_INT_HC_PARAM |
1523 BNX2_PCICFG_INT_ACK_CMD_MASK_INT);
1524
1525 /* Return here if interrupt is disabled. */
1526 if (unlikely(atomic_read(&bp->intr_sem) != 0)) {
1527 return IRQ_RETVAL(1);
1528 }
1529
1530 if (netif_rx_schedule_prep(dev)) {
1531 __netif_rx_schedule(dev);
1532 }
1533
1534 return IRQ_RETVAL(1);
1535}
1536
1537static irqreturn_t
1538bnx2_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
1539{
1540 struct net_device *dev = dev_instance;
1541 struct bnx2 *bp = dev->priv;
1542
1543 /* When using INTx, it is possible for the interrupt to arrive
1544 * at the CPU before the status block posted prior to the
1545 * interrupt. Reading a register will flush the status block.
1546 * When using MSI, the MSI message will always complete after
1547 * the status block write.
1548 */
1549 if ((bp->status_blk->status_idx == bp->last_status_idx) ||
1550 (REG_RD(bp, BNX2_PCICFG_MISC_STATUS) &
1551 BNX2_PCICFG_MISC_STATUS_INTA_VALUE))
1552 return IRQ_RETVAL(0);
1553
1554 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
1555 BNX2_PCICFG_INT_ACK_CMD_USE_INT_HC_PARAM |
1556 BNX2_PCICFG_INT_ACK_CMD_MASK_INT);
1557
1558 /* Return here if interrupt is shared and is disabled. */
1559 if (unlikely(atomic_read(&bp->intr_sem) != 0)) {
1560 return IRQ_RETVAL(1);
1561 }
1562
1563 if (netif_rx_schedule_prep(dev)) {
1564 __netif_rx_schedule(dev);
1565 }
1566
1567 return IRQ_RETVAL(1);
1568}
1569
1570static int
1571bnx2_poll(struct net_device *dev, int *budget)
1572{
1573 struct bnx2 *bp = dev->priv;
1574 int rx_done = 1;
1575
1576 bp->last_status_idx = bp->status_blk->status_idx;
1577
1578 rmb();
1579 if ((bp->status_blk->status_attn_bits &
1580 STATUS_ATTN_BITS_LINK_STATE) !=
1581 (bp->status_blk->status_attn_bits_ack &
1582 STATUS_ATTN_BITS_LINK_STATE)) {
1583
1584 unsigned long flags;
1585
1586 spin_lock_irqsave(&bp->phy_lock, flags);
1587 bnx2_phy_int(bp);
1588 spin_unlock_irqrestore(&bp->phy_lock, flags);
1589 }
1590
1591 if (bp->status_blk->status_tx_quick_consumer_index0 != bp->tx_cons) {
1592 bnx2_tx_int(bp);
1593 }
1594
1595 if (bp->status_blk->status_rx_quick_consumer_index0 != bp->rx_cons) {
1596 int orig_budget = *budget;
1597 int work_done;
1598
1599 if (orig_budget > dev->quota)
1600 orig_budget = dev->quota;
1601
1602 work_done = bnx2_rx_int(bp, orig_budget);
1603 *budget -= work_done;
1604 dev->quota -= work_done;
1605
1606 if (work_done >= orig_budget) {
1607 rx_done = 0;
1608 }
1609 }
1610
1611 if (rx_done) {
1612 netif_rx_complete(dev);
1613 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
1614 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
1615 bp->last_status_idx);
1616 return 0;
1617 }
1618
1619 return 1;
1620}
1621
1622/* Called with rtnl_lock from vlan functions and also dev->xmit_lock
1623 * from set_multicast.
1624 */
1625static void
1626bnx2_set_rx_mode(struct net_device *dev)
1627{
1628 struct bnx2 *bp = dev->priv;
1629 u32 rx_mode, sort_mode;
1630 int i;
1631 unsigned long flags;
1632
1633 spin_lock_irqsave(&bp->phy_lock, flags);
1634
1635 rx_mode = bp->rx_mode & ~(BNX2_EMAC_RX_MODE_PROMISCUOUS |
1636 BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG);
1637 sort_mode = 1 | BNX2_RPM_SORT_USER0_BC_EN;
1638#ifdef BCM_VLAN
1639 if (!bp->vlgrp) {
1640 rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG;
1641 }
1642#else
1643 rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG;
1644#endif
1645 if (dev->flags & IFF_PROMISC) {
1646 /* Promiscuous mode. */
1647 rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS;
1648 sort_mode |= BNX2_RPM_SORT_USER0_PROM_EN;
1649 }
1650 else if (dev->flags & IFF_ALLMULTI) {
1651 for (i = 0; i < NUM_MC_HASH_REGISTERS; i++) {
1652 REG_WR(bp, BNX2_EMAC_MULTICAST_HASH0 + (i * 4),
1653 0xffffffff);
1654 }
1655 sort_mode |= BNX2_RPM_SORT_USER0_MC_EN;
1656 }
1657 else {
1658 /* Accept one or more multicast(s). */
1659 struct dev_mc_list *mclist;
1660 u32 mc_filter[NUM_MC_HASH_REGISTERS];
1661 u32 regidx;
1662 u32 bit;
1663 u32 crc;
1664
1665 memset(mc_filter, 0, 4 * NUM_MC_HASH_REGISTERS);
1666
1667 for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
1668 i++, mclist = mclist->next) {
1669
1670 crc = ether_crc_le(ETH_ALEN, mclist->dmi_addr);
1671 bit = crc & 0xff;
1672 regidx = (bit & 0xe0) >> 5;
1673 bit &= 0x1f;
1674 mc_filter[regidx] |= (1 << bit);
1675 }
1676
1677 for (i = 0; i < NUM_MC_HASH_REGISTERS; i++) {
1678 REG_WR(bp, BNX2_EMAC_MULTICAST_HASH0 + (i * 4),
1679 mc_filter[i]);
1680 }
1681
1682 sort_mode |= BNX2_RPM_SORT_USER0_MC_HSH_EN;
1683 }
1684
1685 if (rx_mode != bp->rx_mode) {
1686 bp->rx_mode = rx_mode;
1687 REG_WR(bp, BNX2_EMAC_RX_MODE, rx_mode);
1688 }
1689
1690 REG_WR(bp, BNX2_RPM_SORT_USER0, 0x0);
1691 REG_WR(bp, BNX2_RPM_SORT_USER0, sort_mode);
1692 REG_WR(bp, BNX2_RPM_SORT_USER0, sort_mode | BNX2_RPM_SORT_USER0_ENA);
1693
1694 spin_unlock_irqrestore(&bp->phy_lock, flags);
1695}
1696
1697static void
1698load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len,
1699 u32 rv2p_proc)
1700{
1701 int i;
1702 u32 val;
1703
1704
1705 for (i = 0; i < rv2p_code_len; i += 8) {
1706 REG_WR(bp, BNX2_RV2P_INSTR_HIGH, *rv2p_code);
1707 rv2p_code++;
1708 REG_WR(bp, BNX2_RV2P_INSTR_LOW, *rv2p_code);
1709 rv2p_code++;
1710
1711 if (rv2p_proc == RV2P_PROC1) {
1712 val = (i / 8) | BNX2_RV2P_PROC1_ADDR_CMD_RDWR;
1713 REG_WR(bp, BNX2_RV2P_PROC1_ADDR_CMD, val);
1714 }
1715 else {
1716 val = (i / 8) | BNX2_RV2P_PROC2_ADDR_CMD_RDWR;
1717 REG_WR(bp, BNX2_RV2P_PROC2_ADDR_CMD, val);
1718 }
1719 }
1720
1721 /* Reset the processor, un-stall is done later. */
1722 if (rv2p_proc == RV2P_PROC1) {
1723 REG_WR(bp, BNX2_RV2P_COMMAND, BNX2_RV2P_COMMAND_PROC1_RESET);
1724 }
1725 else {
1726 REG_WR(bp, BNX2_RV2P_COMMAND, BNX2_RV2P_COMMAND_PROC2_RESET);
1727 }
1728}
1729
1730static void
1731load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
1732{
1733 u32 offset;
1734 u32 val;
1735
1736 /* Halt the CPU. */
1737 val = REG_RD_IND(bp, cpu_reg->mode);
1738 val |= cpu_reg->mode_value_halt;
1739 REG_WR_IND(bp, cpu_reg->mode, val);
1740 REG_WR_IND(bp, cpu_reg->state, cpu_reg->state_value_clear);
1741
1742 /* Load the Text area. */
1743 offset = cpu_reg->spad_base + (fw->text_addr - cpu_reg->mips_view_base);
1744 if (fw->text) {
1745 int j;
1746
1747 for (j = 0; j < (fw->text_len / 4); j++, offset += 4) {
1748 REG_WR_IND(bp, offset, fw->text[j]);
1749 }
1750 }
1751
1752 /* Load the Data area. */
1753 offset = cpu_reg->spad_base + (fw->data_addr - cpu_reg->mips_view_base);
1754 if (fw->data) {
1755 int j;
1756
1757 for (j = 0; j < (fw->data_len / 4); j++, offset += 4) {
1758 REG_WR_IND(bp, offset, fw->data[j]);
1759 }
1760 }
1761
1762 /* Load the SBSS area. */
1763 offset = cpu_reg->spad_base + (fw->sbss_addr - cpu_reg->mips_view_base);
1764 if (fw->sbss) {
1765 int j;
1766
1767 for (j = 0; j < (fw->sbss_len / 4); j++, offset += 4) {
1768 REG_WR_IND(bp, offset, fw->sbss[j]);
1769 }
1770 }
1771
1772 /* Load the BSS area. */
1773 offset = cpu_reg->spad_base + (fw->bss_addr - cpu_reg->mips_view_base);
1774 if (fw->bss) {
1775 int j;
1776
1777 for (j = 0; j < (fw->bss_len/4); j++, offset += 4) {
1778 REG_WR_IND(bp, offset, fw->bss[j]);
1779 }
1780 }
1781
1782 /* Load the Read-Only area. */
1783 offset = cpu_reg->spad_base +
1784 (fw->rodata_addr - cpu_reg->mips_view_base);
1785 if (fw->rodata) {
1786 int j;
1787
1788 for (j = 0; j < (fw->rodata_len / 4); j++, offset += 4) {
1789 REG_WR_IND(bp, offset, fw->rodata[j]);
1790 }
1791 }
1792
1793 /* Clear the pre-fetch instruction. */
1794 REG_WR_IND(bp, cpu_reg->inst, 0);
1795 REG_WR_IND(bp, cpu_reg->pc, fw->start_addr);
1796
1797 /* Start the CPU. */
1798 val = REG_RD_IND(bp, cpu_reg->mode);
1799 val &= ~cpu_reg->mode_value_halt;
1800 REG_WR_IND(bp, cpu_reg->state, cpu_reg->state_value_clear);
1801 REG_WR_IND(bp, cpu_reg->mode, val);
1802}
1803
1804static void
1805bnx2_init_cpus(struct bnx2 *bp)
1806{
1807 struct cpu_reg cpu_reg;
1808 struct fw_info fw;
1809
1810 /* Initialize the RV2P processor. */
1811 load_rv2p_fw(bp, bnx2_rv2p_proc1, sizeof(bnx2_rv2p_proc1), RV2P_PROC1);
1812 load_rv2p_fw(bp, bnx2_rv2p_proc2, sizeof(bnx2_rv2p_proc2), RV2P_PROC2);
1813
1814 /* Initialize the RX Processor. */
1815 cpu_reg.mode = BNX2_RXP_CPU_MODE;
1816 cpu_reg.mode_value_halt = BNX2_RXP_CPU_MODE_SOFT_HALT;
1817 cpu_reg.mode_value_sstep = BNX2_RXP_CPU_MODE_STEP_ENA;
1818 cpu_reg.state = BNX2_RXP_CPU_STATE;
1819 cpu_reg.state_value_clear = 0xffffff;
1820 cpu_reg.gpr0 = BNX2_RXP_CPU_REG_FILE;
1821 cpu_reg.evmask = BNX2_RXP_CPU_EVENT_MASK;
1822 cpu_reg.pc = BNX2_RXP_CPU_PROGRAM_COUNTER;
1823 cpu_reg.inst = BNX2_RXP_CPU_INSTRUCTION;
1824 cpu_reg.bp = BNX2_RXP_CPU_HW_BREAKPOINT;
1825 cpu_reg.spad_base = BNX2_RXP_SCRATCH;
1826 cpu_reg.mips_view_base = 0x8000000;
1827
1828 fw.ver_major = bnx2_RXP_b06FwReleaseMajor;
1829 fw.ver_minor = bnx2_RXP_b06FwReleaseMinor;
1830 fw.ver_fix = bnx2_RXP_b06FwReleaseFix;
1831 fw.start_addr = bnx2_RXP_b06FwStartAddr;
1832
1833 fw.text_addr = bnx2_RXP_b06FwTextAddr;
1834 fw.text_len = bnx2_RXP_b06FwTextLen;
1835 fw.text_index = 0;
1836 fw.text = bnx2_RXP_b06FwText;
1837
1838 fw.data_addr = bnx2_RXP_b06FwDataAddr;
1839 fw.data_len = bnx2_RXP_b06FwDataLen;
1840 fw.data_index = 0;
1841 fw.data = bnx2_RXP_b06FwData;
1842
1843 fw.sbss_addr = bnx2_RXP_b06FwSbssAddr;
1844 fw.sbss_len = bnx2_RXP_b06FwSbssLen;
1845 fw.sbss_index = 0;
1846 fw.sbss = bnx2_RXP_b06FwSbss;
1847
1848 fw.bss_addr = bnx2_RXP_b06FwBssAddr;
1849 fw.bss_len = bnx2_RXP_b06FwBssLen;
1850 fw.bss_index = 0;
1851 fw.bss = bnx2_RXP_b06FwBss;
1852
1853 fw.rodata_addr = bnx2_RXP_b06FwRodataAddr;
1854 fw.rodata_len = bnx2_RXP_b06FwRodataLen;
1855 fw.rodata_index = 0;
1856 fw.rodata = bnx2_RXP_b06FwRodata;
1857
1858 load_cpu_fw(bp, &cpu_reg, &fw);
1859
1860 /* Initialize the TX Processor. */
1861 cpu_reg.mode = BNX2_TXP_CPU_MODE;
1862 cpu_reg.mode_value_halt = BNX2_TXP_CPU_MODE_SOFT_HALT;
1863 cpu_reg.mode_value_sstep = BNX2_TXP_CPU_MODE_STEP_ENA;
1864 cpu_reg.state = BNX2_TXP_CPU_STATE;
1865 cpu_reg.state_value_clear = 0xffffff;
1866 cpu_reg.gpr0 = BNX2_TXP_CPU_REG_FILE;
1867 cpu_reg.evmask = BNX2_TXP_CPU_EVENT_MASK;
1868 cpu_reg.pc = BNX2_TXP_CPU_PROGRAM_COUNTER;
1869 cpu_reg.inst = BNX2_TXP_CPU_INSTRUCTION;
1870 cpu_reg.bp = BNX2_TXP_CPU_HW_BREAKPOINT;
1871 cpu_reg.spad_base = BNX2_TXP_SCRATCH;
1872 cpu_reg.mips_view_base = 0x8000000;
1873
1874 fw.ver_major = bnx2_TXP_b06FwReleaseMajor;
1875 fw.ver_minor = bnx2_TXP_b06FwReleaseMinor;
1876 fw.ver_fix = bnx2_TXP_b06FwReleaseFix;
1877 fw.start_addr = bnx2_TXP_b06FwStartAddr;
1878
1879 fw.text_addr = bnx2_TXP_b06FwTextAddr;
1880 fw.text_len = bnx2_TXP_b06FwTextLen;
1881 fw.text_index = 0;
1882 fw.text = bnx2_TXP_b06FwText;
1883
1884 fw.data_addr = bnx2_TXP_b06FwDataAddr;
1885 fw.data_len = bnx2_TXP_b06FwDataLen;
1886 fw.data_index = 0;
1887 fw.data = bnx2_TXP_b06FwData;
1888
1889 fw.sbss_addr = bnx2_TXP_b06FwSbssAddr;
1890 fw.sbss_len = bnx2_TXP_b06FwSbssLen;
1891 fw.sbss_index = 0;
1892 fw.sbss = bnx2_TXP_b06FwSbss;
1893
1894 fw.bss_addr = bnx2_TXP_b06FwBssAddr;
1895 fw.bss_len = bnx2_TXP_b06FwBssLen;
1896 fw.bss_index = 0;
1897 fw.bss = bnx2_TXP_b06FwBss;
1898
1899 fw.rodata_addr = bnx2_TXP_b06FwRodataAddr;
1900 fw.rodata_len = bnx2_TXP_b06FwRodataLen;
1901 fw.rodata_index = 0;
1902 fw.rodata = bnx2_TXP_b06FwRodata;
1903
1904 load_cpu_fw(bp, &cpu_reg, &fw);
1905
1906 /* Initialize the TX Patch-up Processor. */
1907 cpu_reg.mode = BNX2_TPAT_CPU_MODE;
1908 cpu_reg.mode_value_halt = BNX2_TPAT_CPU_MODE_SOFT_HALT;
1909 cpu_reg.mode_value_sstep = BNX2_TPAT_CPU_MODE_STEP_ENA;
1910 cpu_reg.state = BNX2_TPAT_CPU_STATE;
1911 cpu_reg.state_value_clear = 0xffffff;
1912 cpu_reg.gpr0 = BNX2_TPAT_CPU_REG_FILE;
1913 cpu_reg.evmask = BNX2_TPAT_CPU_EVENT_MASK;
1914 cpu_reg.pc = BNX2_TPAT_CPU_PROGRAM_COUNTER;
1915 cpu_reg.inst = BNX2_TPAT_CPU_INSTRUCTION;
1916 cpu_reg.bp = BNX2_TPAT_CPU_HW_BREAKPOINT;
1917 cpu_reg.spad_base = BNX2_TPAT_SCRATCH;
1918 cpu_reg.mips_view_base = 0x8000000;
1919
1920 fw.ver_major = bnx2_TPAT_b06FwReleaseMajor;
1921 fw.ver_minor = bnx2_TPAT_b06FwReleaseMinor;
1922 fw.ver_fix = bnx2_TPAT_b06FwReleaseFix;
1923 fw.start_addr = bnx2_TPAT_b06FwStartAddr;
1924
1925 fw.text_addr = bnx2_TPAT_b06FwTextAddr;
1926 fw.text_len = bnx2_TPAT_b06FwTextLen;
1927 fw.text_index = 0;
1928 fw.text = bnx2_TPAT_b06FwText;
1929
1930 fw.data_addr = bnx2_TPAT_b06FwDataAddr;
1931 fw.data_len = bnx2_TPAT_b06FwDataLen;
1932 fw.data_index = 0;
1933 fw.data = bnx2_TPAT_b06FwData;
1934
1935 fw.sbss_addr = bnx2_TPAT_b06FwSbssAddr;
1936 fw.sbss_len = bnx2_TPAT_b06FwSbssLen;
1937 fw.sbss_index = 0;
1938 fw.sbss = bnx2_TPAT_b06FwSbss;
1939
1940 fw.bss_addr = bnx2_TPAT_b06FwBssAddr;
1941 fw.bss_len = bnx2_TPAT_b06FwBssLen;
1942 fw.bss_index = 0;
1943 fw.bss = bnx2_TPAT_b06FwBss;
1944
1945 fw.rodata_addr = bnx2_TPAT_b06FwRodataAddr;
1946 fw.rodata_len = bnx2_TPAT_b06FwRodataLen;
1947 fw.rodata_index = 0;
1948 fw.rodata = bnx2_TPAT_b06FwRodata;
1949
1950 load_cpu_fw(bp, &cpu_reg, &fw);
1951
1952 /* Initialize the Completion Processor. */
1953 cpu_reg.mode = BNX2_COM_CPU_MODE;
1954 cpu_reg.mode_value_halt = BNX2_COM_CPU_MODE_SOFT_HALT;
1955 cpu_reg.mode_value_sstep = BNX2_COM_CPU_MODE_STEP_ENA;
1956 cpu_reg.state = BNX2_COM_CPU_STATE;
1957 cpu_reg.state_value_clear = 0xffffff;
1958 cpu_reg.gpr0 = BNX2_COM_CPU_REG_FILE;
1959 cpu_reg.evmask = BNX2_COM_CPU_EVENT_MASK;
1960 cpu_reg.pc = BNX2_COM_CPU_PROGRAM_COUNTER;
1961 cpu_reg.inst = BNX2_COM_CPU_INSTRUCTION;
1962 cpu_reg.bp = BNX2_COM_CPU_HW_BREAKPOINT;
1963 cpu_reg.spad_base = BNX2_COM_SCRATCH;
1964 cpu_reg.mips_view_base = 0x8000000;
1965
1966 fw.ver_major = bnx2_COM_b06FwReleaseMajor;
1967 fw.ver_minor = bnx2_COM_b06FwReleaseMinor;
1968 fw.ver_fix = bnx2_COM_b06FwReleaseFix;
1969 fw.start_addr = bnx2_COM_b06FwStartAddr;
1970
1971 fw.text_addr = bnx2_COM_b06FwTextAddr;
1972 fw.text_len = bnx2_COM_b06FwTextLen;
1973 fw.text_index = 0;
1974 fw.text = bnx2_COM_b06FwText;
1975
1976 fw.data_addr = bnx2_COM_b06FwDataAddr;
1977 fw.data_len = bnx2_COM_b06FwDataLen;
1978 fw.data_index = 0;
1979 fw.data = bnx2_COM_b06FwData;
1980
1981 fw.sbss_addr = bnx2_COM_b06FwSbssAddr;
1982 fw.sbss_len = bnx2_COM_b06FwSbssLen;
1983 fw.sbss_index = 0;
1984 fw.sbss = bnx2_COM_b06FwSbss;
1985
1986 fw.bss_addr = bnx2_COM_b06FwBssAddr;
1987 fw.bss_len = bnx2_COM_b06FwBssLen;
1988 fw.bss_index = 0;
1989 fw.bss = bnx2_COM_b06FwBss;
1990
1991 fw.rodata_addr = bnx2_COM_b06FwRodataAddr;
1992 fw.rodata_len = bnx2_COM_b06FwRodataLen;
1993 fw.rodata_index = 0;
1994 fw.rodata = bnx2_COM_b06FwRodata;
1995
1996 load_cpu_fw(bp, &cpu_reg, &fw);
1997
1998}
1999
2000static int
2001bnx2_set_power_state(struct bnx2 *bp, int state)
2002{
2003 u16 pmcsr;
2004
2005 pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, &pmcsr);
2006
2007 switch (state) {
2008 case 0: {
2009 u32 val;
2010
2011 pci_write_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL,
2012 (pmcsr & ~PCI_PM_CTRL_STATE_MASK) |
2013 PCI_PM_CTRL_PME_STATUS);
2014
2015 if (pmcsr & PCI_PM_CTRL_STATE_MASK)
2016 /* delay required during transition out of D3hot */
2017 msleep(20);
2018
2019 val = REG_RD(bp, BNX2_EMAC_MODE);
2020 val |= BNX2_EMAC_MODE_MPKT_RCVD | BNX2_EMAC_MODE_ACPI_RCVD;
2021 val &= ~BNX2_EMAC_MODE_MPKT;
2022 REG_WR(bp, BNX2_EMAC_MODE, val);
2023
2024 val = REG_RD(bp, BNX2_RPM_CONFIG);
2025 val &= ~BNX2_RPM_CONFIG_ACPI_ENA;
2026 REG_WR(bp, BNX2_RPM_CONFIG, val);
2027 break;
2028 }
2029 case 3: {
2030 int i;
2031 u32 val, wol_msg;
2032
2033 if (bp->wol) {
2034 u32 advertising;
2035 u8 autoneg;
2036
2037 autoneg = bp->autoneg;
2038 advertising = bp->advertising;
2039
2040 bp->autoneg = AUTONEG_SPEED;
2041 bp->advertising = ADVERTISED_10baseT_Half |
2042 ADVERTISED_10baseT_Full |
2043 ADVERTISED_100baseT_Half |
2044 ADVERTISED_100baseT_Full |
2045 ADVERTISED_Autoneg;
2046
2047 bnx2_setup_copper_phy(bp);
2048
2049 bp->autoneg = autoneg;
2050 bp->advertising = advertising;
2051
2052 bnx2_set_mac_addr(bp);
2053
2054 val = REG_RD(bp, BNX2_EMAC_MODE);
2055
2056 /* Enable port mode. */
2057 val &= ~BNX2_EMAC_MODE_PORT;
2058 val |= BNX2_EMAC_MODE_PORT_MII |
2059 BNX2_EMAC_MODE_MPKT_RCVD |
2060 BNX2_EMAC_MODE_ACPI_RCVD |
2061 BNX2_EMAC_MODE_FORCE_LINK |
2062 BNX2_EMAC_MODE_MPKT;
2063
2064 REG_WR(bp, BNX2_EMAC_MODE, val);
2065
2066 /* receive all multicast */
2067 for (i = 0; i < NUM_MC_HASH_REGISTERS; i++) {
2068 REG_WR(bp, BNX2_EMAC_MULTICAST_HASH0 + (i * 4),
2069 0xffffffff);
2070 }
2071 REG_WR(bp, BNX2_EMAC_RX_MODE,
2072 BNX2_EMAC_RX_MODE_SORT_MODE);
2073
2074 val = 1 | BNX2_RPM_SORT_USER0_BC_EN |
2075 BNX2_RPM_SORT_USER0_MC_EN;
2076 REG_WR(bp, BNX2_RPM_SORT_USER0, 0x0);
2077 REG_WR(bp, BNX2_RPM_SORT_USER0, val);
2078 REG_WR(bp, BNX2_RPM_SORT_USER0, val |
2079 BNX2_RPM_SORT_USER0_ENA);
2080
2081 /* Need to enable EMAC and RPM for WOL. */
2082 REG_WR(bp, BNX2_MISC_ENABLE_SET_BITS,
2083 BNX2_MISC_ENABLE_SET_BITS_RX_PARSER_MAC_ENABLE |
2084 BNX2_MISC_ENABLE_SET_BITS_TX_HEADER_Q_ENABLE |
2085 BNX2_MISC_ENABLE_SET_BITS_EMAC_ENABLE);
2086
2087 val = REG_RD(bp, BNX2_RPM_CONFIG);
2088 val &= ~BNX2_RPM_CONFIG_ACPI_ENA;
2089 REG_WR(bp, BNX2_RPM_CONFIG, val);
2090
2091 wol_msg = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
2092 }
2093 else {
2094 wol_msg = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
2095 }
2096
2097 bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT3 | wol_msg);
2098
2099 pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
2100 if ((CHIP_ID(bp) == CHIP_ID_5706_A0) ||
2101 (CHIP_ID(bp) == CHIP_ID_5706_A1)) {
2102
2103 if (bp->wol)
2104 pmcsr |= 3;
2105 }
2106 else {
2107 pmcsr |= 3;
2108 }
2109 if (bp->wol) {
2110 pmcsr |= PCI_PM_CTRL_PME_ENABLE;
2111 }
2112 pci_write_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL,
2113 pmcsr);
2114
2115 /* No more memory access after this point until
2116 * device is brought back to D0.
2117 */
2118 udelay(50);
2119 break;
2120 }
2121 default:
2122 return -EINVAL;
2123 }
2124 return 0;
2125}
2126
2127static int
2128bnx2_acquire_nvram_lock(struct bnx2 *bp)
2129{
2130 u32 val;
2131 int j;
2132
2133 /* Request access to the flash interface. */
2134 REG_WR(bp, BNX2_NVM_SW_ARB, BNX2_NVM_SW_ARB_ARB_REQ_SET2);
2135 for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
2136 val = REG_RD(bp, BNX2_NVM_SW_ARB);
2137 if (val & BNX2_NVM_SW_ARB_ARB_ARB2)
2138 break;
2139
2140 udelay(5);
2141 }
2142
2143 if (j >= NVRAM_TIMEOUT_COUNT)
2144 return -EBUSY;
2145
2146 return 0;
2147}
2148
2149static int
2150bnx2_release_nvram_lock(struct bnx2 *bp)
2151{
2152 int j;
2153 u32 val;
2154
2155 /* Relinquish nvram interface. */
2156 REG_WR(bp, BNX2_NVM_SW_ARB, BNX2_NVM_SW_ARB_ARB_REQ_CLR2);
2157
2158 for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
2159 val = REG_RD(bp, BNX2_NVM_SW_ARB);
2160 if (!(val & BNX2_NVM_SW_ARB_ARB_ARB2))
2161 break;
2162
2163 udelay(5);
2164 }
2165
2166 if (j >= NVRAM_TIMEOUT_COUNT)
2167 return -EBUSY;
2168
2169 return 0;
2170}
2171
2172
2173static int
2174bnx2_enable_nvram_write(struct bnx2 *bp)
2175{
2176 u32 val;
2177
2178 val = REG_RD(bp, BNX2_MISC_CFG);
2179 REG_WR(bp, BNX2_MISC_CFG, val | BNX2_MISC_CFG_NVM_WR_EN_PCI);
2180
2181 if (!bp->flash_info->buffered) {
2182 int j;
2183
2184 REG_WR(bp, BNX2_NVM_COMMAND, BNX2_NVM_COMMAND_DONE);
2185 REG_WR(bp, BNX2_NVM_COMMAND,
2186 BNX2_NVM_COMMAND_WREN | BNX2_NVM_COMMAND_DOIT);
2187
2188 for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
2189 udelay(5);
2190
2191 val = REG_RD(bp, BNX2_NVM_COMMAND);
2192 if (val & BNX2_NVM_COMMAND_DONE)
2193 break;
2194 }
2195
2196 if (j >= NVRAM_TIMEOUT_COUNT)
2197 return -EBUSY;
2198 }
2199 return 0;
2200}
2201
2202static void
2203bnx2_disable_nvram_write(struct bnx2 *bp)
2204{
2205 u32 val;
2206
2207 val = REG_RD(bp, BNX2_MISC_CFG);
2208 REG_WR(bp, BNX2_MISC_CFG, val & ~BNX2_MISC_CFG_NVM_WR_EN);
2209}
2210
2211
2212static void
2213bnx2_enable_nvram_access(struct bnx2 *bp)
2214{
2215 u32 val;
2216
2217 val = REG_RD(bp, BNX2_NVM_ACCESS_ENABLE);
2218 /* Enable both bits, even on read. */
2219 REG_WR(bp, BNX2_NVM_ACCESS_ENABLE,
2220 val | BNX2_NVM_ACCESS_ENABLE_EN | BNX2_NVM_ACCESS_ENABLE_WR_EN);
2221}
2222
2223static void
2224bnx2_disable_nvram_access(struct bnx2 *bp)
2225{
2226 u32 val;
2227
2228 val = REG_RD(bp, BNX2_NVM_ACCESS_ENABLE);
2229 /* Disable both bits, even after read. */
2230 REG_WR(bp, BNX2_NVM_ACCESS_ENABLE,
2231 val & ~(BNX2_NVM_ACCESS_ENABLE_EN |
2232 BNX2_NVM_ACCESS_ENABLE_WR_EN));
2233}
2234
2235static int
2236bnx2_nvram_erase_page(struct bnx2 *bp, u32 offset)
2237{
2238 u32 cmd;
2239 int j;
2240
2241 if (bp->flash_info->buffered)
2242 /* Buffered flash, no erase needed */
2243 return 0;
2244
2245 /* Build an erase command */
2246 cmd = BNX2_NVM_COMMAND_ERASE | BNX2_NVM_COMMAND_WR |
2247 BNX2_NVM_COMMAND_DOIT;
2248
2249 /* Need to clear DONE bit separately. */
2250 REG_WR(bp, BNX2_NVM_COMMAND, BNX2_NVM_COMMAND_DONE);
2251
2252 /* Address of the NVRAM to read from. */
2253 REG_WR(bp, BNX2_NVM_ADDR, offset & BNX2_NVM_ADDR_NVM_ADDR_VALUE);
2254
2255 /* Issue an erase command. */
2256 REG_WR(bp, BNX2_NVM_COMMAND, cmd);
2257
2258 /* Wait for completion. */
2259 for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
2260 u32 val;
2261
2262 udelay(5);
2263
2264 val = REG_RD(bp, BNX2_NVM_COMMAND);
2265 if (val & BNX2_NVM_COMMAND_DONE)
2266 break;
2267 }
2268
2269 if (j >= NVRAM_TIMEOUT_COUNT)
2270 return -EBUSY;
2271
2272 return 0;
2273}
2274
2275static int
2276bnx2_nvram_read_dword(struct bnx2 *bp, u32 offset, u8 *ret_val, u32 cmd_flags)
2277{
2278 u32 cmd;
2279 int j;
2280
2281 /* Build the command word. */
2282 cmd = BNX2_NVM_COMMAND_DOIT | cmd_flags;
2283
2284 /* Calculate an offset of a buffered flash. */
2285 if (bp->flash_info->buffered) {
2286 offset = ((offset / bp->flash_info->page_size) <<
2287 bp->flash_info->page_bits) +
2288 (offset % bp->flash_info->page_size);
2289 }
2290
2291 /* Need to clear DONE bit separately. */
2292 REG_WR(bp, BNX2_NVM_COMMAND, BNX2_NVM_COMMAND_DONE);
2293
2294 /* Address of the NVRAM to read from. */
2295 REG_WR(bp, BNX2_NVM_ADDR, offset & BNX2_NVM_ADDR_NVM_ADDR_VALUE);
2296
2297 /* Issue a read command. */
2298 REG_WR(bp, BNX2_NVM_COMMAND, cmd);
2299
2300 /* Wait for completion. */
2301 for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
2302 u32 val;
2303
2304 udelay(5);
2305
2306 val = REG_RD(bp, BNX2_NVM_COMMAND);
2307 if (val & BNX2_NVM_COMMAND_DONE) {
2308 val = REG_RD(bp, BNX2_NVM_READ);
2309
2310 val = be32_to_cpu(val);
2311 memcpy(ret_val, &val, 4);
2312 break;
2313 }
2314 }
2315 if (j >= NVRAM_TIMEOUT_COUNT)
2316 return -EBUSY;
2317
2318 return 0;
2319}
2320
2321
2322static int
2323bnx2_nvram_write_dword(struct bnx2 *bp, u32 offset, u8 *val, u32 cmd_flags)
2324{
2325 u32 cmd, val32;
2326 int j;
2327
2328 /* Build the command word. */
2329 cmd = BNX2_NVM_COMMAND_DOIT | BNX2_NVM_COMMAND_WR | cmd_flags;
2330
2331 /* Calculate an offset of a buffered flash. */
2332 if (bp->flash_info->buffered) {
2333 offset = ((offset / bp->flash_info->page_size) <<
2334 bp->flash_info->page_bits) +
2335 (offset % bp->flash_info->page_size);
2336 }
2337
2338 /* Need to clear DONE bit separately. */
2339 REG_WR(bp, BNX2_NVM_COMMAND, BNX2_NVM_COMMAND_DONE);
2340
2341 memcpy(&val32, val, 4);
2342 val32 = cpu_to_be32(val32);
2343
2344 /* Write the data. */
2345 REG_WR(bp, BNX2_NVM_WRITE, val32);
2346
2347 /* Address of the NVRAM to write to. */
2348 REG_WR(bp, BNX2_NVM_ADDR, offset & BNX2_NVM_ADDR_NVM_ADDR_VALUE);
2349
2350 /* Issue the write command. */
2351 REG_WR(bp, BNX2_NVM_COMMAND, cmd);
2352
2353 /* Wait for completion. */
2354 for (j = 0; j < NVRAM_TIMEOUT_COUNT; j++) {
2355 udelay(5);
2356
2357 if (REG_RD(bp, BNX2_NVM_COMMAND) & BNX2_NVM_COMMAND_DONE)
2358 break;
2359 }
2360 if (j >= NVRAM_TIMEOUT_COUNT)
2361 return -EBUSY;
2362
2363 return 0;
2364}
2365
2366static int
2367bnx2_init_nvram(struct bnx2 *bp)
2368{
2369 u32 val;
2370 int j, entry_count, rc;
2371 struct flash_spec *flash;
2372
2373 /* Determine the selected interface. */
2374 val = REG_RD(bp, BNX2_NVM_CFG1);
2375
2376 entry_count = sizeof(flash_table) / sizeof(struct flash_spec);
2377
2378 rc = 0;
2379 if (val & 0x40000000) {
2380
2381 /* Flash interface has been reconfigured */
2382 for (j = 0, flash = &flash_table[0]; j < entry_count;
2383 j++, flash++) {
2384
2385 if (val == flash->config1) {
2386 bp->flash_info = flash;
2387 break;
2388 }
2389 }
2390 }
2391 else {
2392 /* Not yet been reconfigured */
2393
2394 for (j = 0, flash = &flash_table[0]; j < entry_count;
2395 j++, flash++) {
2396
2397 if ((val & FLASH_STRAP_MASK) == flash->strapping) {
2398 bp->flash_info = flash;
2399
2400 /* Request access to the flash interface. */
2401 if ((rc = bnx2_acquire_nvram_lock(bp)) != 0)
2402 return rc;
2403
2404 /* Enable access to flash interface */
2405 bnx2_enable_nvram_access(bp);
2406
2407 /* Reconfigure the flash interface */
2408 REG_WR(bp, BNX2_NVM_CFG1, flash->config1);
2409 REG_WR(bp, BNX2_NVM_CFG2, flash->config2);
2410 REG_WR(bp, BNX2_NVM_CFG3, flash->config3);
2411 REG_WR(bp, BNX2_NVM_WRITE1, flash->write1);
2412
2413 /* Disable access to flash interface */
2414 bnx2_disable_nvram_access(bp);
2415 bnx2_release_nvram_lock(bp);
2416
2417 break;
2418 }
2419 }
2420 } /* if (val & 0x40000000) */
2421
2422 if (j == entry_count) {
2423 bp->flash_info = NULL;
2424 printk(KERN_ALERT "Unknown flash/EEPROM type.\n");
2425 rc = -ENODEV;
2426 }
2427
2428 return rc;
2429}
2430
2431static int
2432bnx2_nvram_read(struct bnx2 *bp, u32 offset, u8 *ret_buf,
2433 int buf_size)
2434{
2435 int rc = 0;
2436 u32 cmd_flags, offset32, len32, extra;
2437
2438 if (buf_size == 0)
2439 return 0;
2440
2441 /* Request access to the flash interface. */
2442 if ((rc = bnx2_acquire_nvram_lock(bp)) != 0)
2443 return rc;
2444
2445 /* Enable access to flash interface */
2446 bnx2_enable_nvram_access(bp);
2447
2448 len32 = buf_size;
2449 offset32 = offset;
2450 extra = 0;
2451
2452 cmd_flags = 0;
2453
2454 if (offset32 & 3) {
2455 u8 buf[4];
2456 u32 pre_len;
2457
2458 offset32 &= ~3;
2459 pre_len = 4 - (offset & 3);
2460
2461 if (pre_len >= len32) {
2462 pre_len = len32;
2463 cmd_flags = BNX2_NVM_COMMAND_FIRST |
2464 BNX2_NVM_COMMAND_LAST;
2465 }
2466 else {
2467 cmd_flags = BNX2_NVM_COMMAND_FIRST;
2468 }
2469
2470 rc = bnx2_nvram_read_dword(bp, offset32, buf, cmd_flags);
2471
2472 if (rc)
2473 return rc;
2474
2475 memcpy(ret_buf, buf + (offset & 3), pre_len);
2476
2477 offset32 += 4;
2478 ret_buf += pre_len;
2479 len32 -= pre_len;
2480 }
2481 if (len32 & 3) {
2482 extra = 4 - (len32 & 3);
2483 len32 = (len32 + 4) & ~3;
2484 }
2485
2486 if (len32 == 4) {
2487 u8 buf[4];
2488
2489 if (cmd_flags)
2490 cmd_flags = BNX2_NVM_COMMAND_LAST;
2491 else
2492 cmd_flags = BNX2_NVM_COMMAND_FIRST |
2493 BNX2_NVM_COMMAND_LAST;
2494
2495 rc = bnx2_nvram_read_dword(bp, offset32, buf, cmd_flags);
2496
2497 memcpy(ret_buf, buf, 4 - extra);
2498 }
2499 else if (len32 > 0) {
2500 u8 buf[4];
2501
2502 /* Read the first word. */
2503 if (cmd_flags)
2504 cmd_flags = 0;
2505 else
2506 cmd_flags = BNX2_NVM_COMMAND_FIRST;
2507
2508 rc = bnx2_nvram_read_dword(bp, offset32, ret_buf, cmd_flags);
2509
2510 /* Advance to the next dword. */
2511 offset32 += 4;
2512 ret_buf += 4;
2513 len32 -= 4;
2514
2515 while (len32 > 4 && rc == 0) {
2516 rc = bnx2_nvram_read_dword(bp, offset32, ret_buf, 0);
2517
2518 /* Advance to the next dword. */
2519 offset32 += 4;
2520 ret_buf += 4;
2521 len32 -= 4;
2522 }
2523
2524 if (rc)
2525 return rc;
2526
2527 cmd_flags = BNX2_NVM_COMMAND_LAST;
2528 rc = bnx2_nvram_read_dword(bp, offset32, buf, cmd_flags);
2529
2530 memcpy(ret_buf, buf, 4 - extra);
2531 }
2532
2533 /* Disable access to flash interface */
2534 bnx2_disable_nvram_access(bp);
2535
2536 bnx2_release_nvram_lock(bp);
2537
2538 return rc;
2539}
2540
2541static int
2542bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf,
2543 int buf_size)
2544{
2545 u32 written, offset32, len32;
2546 u8 *buf, start[4], end[4];
2547 int rc = 0;
2548 int align_start, align_end;
2549
2550 buf = data_buf;
2551 offset32 = offset;
2552 len32 = buf_size;
2553 align_start = align_end = 0;
2554
2555 if ((align_start = (offset32 & 3))) {
2556 offset32 &= ~3;
2557 len32 += align_start;
2558 if ((rc = bnx2_nvram_read(bp, offset32, start, 4)))
2559 return rc;
2560 }
2561
2562 if (len32 & 3) {
2563 if ((len32 > 4) || !align_start) {
2564 align_end = 4 - (len32 & 3);
2565 len32 += align_end;
2566 if ((rc = bnx2_nvram_read(bp, offset32 + len32 - 4,
2567 end, 4))) {
2568 return rc;
2569 }
2570 }
2571 }
2572
2573 if (align_start || align_end) {
2574 buf = kmalloc(len32, GFP_KERNEL);
2575 if (buf == 0)
2576 return -ENOMEM;
2577 if (align_start) {
2578 memcpy(buf, start, 4);
2579 }
2580 if (align_end) {
2581 memcpy(buf + len32 - 4, end, 4);
2582 }
2583 memcpy(buf + align_start, data_buf, buf_size);
2584 }
2585
2586 written = 0;
2587 while ((written < len32) && (rc == 0)) {
2588 u32 page_start, page_end, data_start, data_end;
2589 u32 addr, cmd_flags;
2590 int i;
2591 u8 flash_buffer[264];
2592
2593 /* Find the page_start addr */
2594 page_start = offset32 + written;
2595 page_start -= (page_start % bp->flash_info->page_size);
2596 /* Find the page_end addr */
2597 page_end = page_start + bp->flash_info->page_size;
2598 /* Find the data_start addr */
2599 data_start = (written == 0) ? offset32 : page_start;
2600 /* Find the data_end addr */
2601 data_end = (page_end > offset32 + len32) ?
2602 (offset32 + len32) : page_end;
2603
2604 /* Request access to the flash interface. */
2605 if ((rc = bnx2_acquire_nvram_lock(bp)) != 0)
2606 goto nvram_write_end;
2607
2608 /* Enable access to flash interface */
2609 bnx2_enable_nvram_access(bp);
2610
2611 cmd_flags = BNX2_NVM_COMMAND_FIRST;
2612 if (bp->flash_info->buffered == 0) {
2613 int j;
2614
2615 /* Read the whole page into the buffer
2616 * (non-buffer flash only) */
2617 for (j = 0; j < bp->flash_info->page_size; j += 4) {
2618 if (j == (bp->flash_info->page_size - 4)) {
2619 cmd_flags |= BNX2_NVM_COMMAND_LAST;
2620 }
2621 rc = bnx2_nvram_read_dword(bp,
2622 page_start + j,
2623 &flash_buffer[j],
2624 cmd_flags);
2625
2626 if (rc)
2627 goto nvram_write_end;
2628
2629 cmd_flags = 0;
2630 }
2631 }
2632
2633 /* Enable writes to flash interface (unlock write-protect) */
2634 if ((rc = bnx2_enable_nvram_write(bp)) != 0)
2635 goto nvram_write_end;
2636
2637 /* Erase the page */
2638 if ((rc = bnx2_nvram_erase_page(bp, page_start)) != 0)
2639 goto nvram_write_end;
2640
2641 /* Re-enable the write again for the actual write */
2642 bnx2_enable_nvram_write(bp);
2643
2644 /* Loop to write back the buffer data from page_start to
2645 * data_start */
2646 i = 0;
2647 if (bp->flash_info->buffered == 0) {
2648 for (addr = page_start; addr < data_start;
2649 addr += 4, i += 4) {
2650
2651 rc = bnx2_nvram_write_dword(bp, addr,
2652 &flash_buffer[i], cmd_flags);
2653
2654 if (rc != 0)
2655 goto nvram_write_end;
2656
2657 cmd_flags = 0;
2658 }
2659 }
2660
2661 /* Loop to write the new data from data_start to data_end */
2662 for (addr = data_start; addr < data_end; addr += 4, i++) {
2663 if ((addr == page_end - 4) ||
2664 ((bp->flash_info->buffered) &&
2665 (addr == data_end - 4))) {
2666
2667 cmd_flags |= BNX2_NVM_COMMAND_LAST;
2668 }
2669 rc = bnx2_nvram_write_dword(bp, addr, buf,
2670 cmd_flags);
2671
2672 if (rc != 0)
2673 goto nvram_write_end;
2674
2675 cmd_flags = 0;
2676 buf += 4;
2677 }
2678
2679 /* Loop to write back the buffer data from data_end
2680 * to page_end */
2681 if (bp->flash_info->buffered == 0) {
2682 for (addr = data_end; addr < page_end;
2683 addr += 4, i += 4) {
2684
2685 if (addr == page_end-4) {
2686 cmd_flags = BNX2_NVM_COMMAND_LAST;
2687 }
2688 rc = bnx2_nvram_write_dword(bp, addr,
2689 &flash_buffer[i], cmd_flags);
2690
2691 if (rc != 0)
2692 goto nvram_write_end;
2693
2694 cmd_flags = 0;
2695 }
2696 }
2697
2698 /* Disable writes to flash interface (lock write-protect) */
2699 bnx2_disable_nvram_write(bp);
2700
2701 /* Disable access to flash interface */
2702 bnx2_disable_nvram_access(bp);
2703 bnx2_release_nvram_lock(bp);
2704
2705 /* Increment written */
2706 written += data_end - data_start;
2707 }
2708
2709nvram_write_end:
2710 if (align_start || align_end)
2711 kfree(buf);
2712 return rc;
2713}
2714
2715static int
2716bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
2717{
2718 u32 val;
2719 int i, rc = 0;
2720
2721 /* Wait for the current PCI transaction to complete before
2722 * issuing a reset. */
2723 REG_WR(bp, BNX2_MISC_ENABLE_CLR_BITS,
2724 BNX2_MISC_ENABLE_CLR_BITS_TX_DMA_ENABLE |
2725 BNX2_MISC_ENABLE_CLR_BITS_DMA_ENGINE_ENABLE |
2726 BNX2_MISC_ENABLE_CLR_BITS_RX_DMA_ENABLE |
2727 BNX2_MISC_ENABLE_CLR_BITS_HOST_COALESCE_ENABLE);
2728 val = REG_RD(bp, BNX2_MISC_ENABLE_CLR_BITS);
2729 udelay(5);
2730
2731 /* Deposit a driver reset signature so the firmware knows that
2732 * this is a soft reset. */
2733 REG_WR_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_DRV_RESET_SIGNATURE,
2734 BNX2_DRV_RESET_SIGNATURE_MAGIC);
2735
2736 bp->fw_timed_out = 0;
2737
2738 /* Wait for the firmware to tell us it is ok to issue a reset. */
2739 bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT0 | reset_code);
2740
2741 /* Do a dummy read to force the chip to complete all current transaction
2742 * before we issue a reset. */
2743 val = REG_RD(bp, BNX2_MISC_ID);
2744
2745 val = BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ |
2746 BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA |
2747 BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP;
2748
2749 /* Chip reset. */
2750 REG_WR(bp, BNX2_PCICFG_MISC_CONFIG, val);
2751
2752 if ((CHIP_ID(bp) == CHIP_ID_5706_A0) ||
2753 (CHIP_ID(bp) == CHIP_ID_5706_A1))
2754 msleep(15);
2755
2756 /* Reset takes approximate 30 usec */
2757 for (i = 0; i < 10; i++) {
2758 val = REG_RD(bp, BNX2_PCICFG_MISC_CONFIG);
2759 if ((val & (BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ |
2760 BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY)) == 0) {
2761 break;
2762 }
2763 udelay(10);
2764 }
2765
2766 if (val & (BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ |
2767 BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY)) {
2768 printk(KERN_ERR PFX "Chip reset did not complete\n");
2769 return -EBUSY;
2770 }
2771
2772 /* Make sure byte swapping is properly configured. */
2773 val = REG_RD(bp, BNX2_PCI_SWAP_DIAG0);
2774 if (val != 0x01020304) {
2775 printk(KERN_ERR PFX "Chip not in correct endian mode\n");
2776 return -ENODEV;
2777 }
2778
2779 bp->fw_timed_out = 0;
2780
2781 /* Wait for the firmware to finish its initialization. */
2782 bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT1 | reset_code);
2783
2784 if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
2785 /* Adjust the voltage regular to two steps lower. The default
2786 * of this register is 0x0000000e. */
2787 REG_WR(bp, BNX2_MISC_VREG_CONTROL, 0x000000fa);
2788
2789 /* Remove bad rbuf memory from the free pool. */
2790 rc = bnx2_alloc_bad_rbuf(bp);
2791 }
2792
2793 return rc;
2794}
2795
2796static int
2797bnx2_init_chip(struct bnx2 *bp)
2798{
2799 u32 val;
2800
2801 /* Make sure the interrupt is not active. */
2802 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, BNX2_PCICFG_INT_ACK_CMD_MASK_INT);
2803
2804 val = BNX2_DMA_CONFIG_DATA_BYTE_SWAP |
2805 BNX2_DMA_CONFIG_DATA_WORD_SWAP |
2806#ifdef __BIG_ENDIAN
2807 BNX2_DMA_CONFIG_CNTL_BYTE_SWAP |
2808#endif
2809 BNX2_DMA_CONFIG_CNTL_WORD_SWAP |
2810 DMA_READ_CHANS << 12 |
2811 DMA_WRITE_CHANS << 16;
2812
2813 val |= (0x2 << 20) | (1 << 11);
2814
2815 if ((bp->flags & PCIX_FLAG) && (bp->bus_speed_mhz = 133))
2816 val |= (1 << 23);
2817
2818 if ((CHIP_NUM(bp) == CHIP_NUM_5706) &&
2819 (CHIP_ID(bp) != CHIP_ID_5706_A0) && !(bp->flags & PCIX_FLAG))
2820 val |= BNX2_DMA_CONFIG_CNTL_PING_PONG_DMA;
2821
2822 REG_WR(bp, BNX2_DMA_CONFIG, val);
2823
2824 if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
2825 val = REG_RD(bp, BNX2_TDMA_CONFIG);
2826 val |= BNX2_TDMA_CONFIG_ONE_DMA;
2827 REG_WR(bp, BNX2_TDMA_CONFIG, val);
2828 }
2829
2830 if (bp->flags & PCIX_FLAG) {
2831 u16 val16;
2832
2833 pci_read_config_word(bp->pdev, bp->pcix_cap + PCI_X_CMD,
2834 &val16);
2835 pci_write_config_word(bp->pdev, bp->pcix_cap + PCI_X_CMD,
2836 val16 & ~PCI_X_CMD_ERO);
2837 }
2838
2839 REG_WR(bp, BNX2_MISC_ENABLE_SET_BITS,
2840 BNX2_MISC_ENABLE_SET_BITS_HOST_COALESCE_ENABLE |
2841 BNX2_MISC_ENABLE_STATUS_BITS_RX_V2P_ENABLE |
2842 BNX2_MISC_ENABLE_STATUS_BITS_CONTEXT_ENABLE);
2843
2844 /* Initialize context mapping and zero out the quick contexts. The
2845 * context block must have already been enabled. */
2846 bnx2_init_context(bp);
2847
2848 bnx2_init_cpus(bp);
2849 bnx2_init_nvram(bp);
2850
2851 bnx2_set_mac_addr(bp);
2852
2853 val = REG_RD(bp, BNX2_MQ_CONFIG);
2854 val &= ~BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE;
2855 val |= BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256;
2856 REG_WR(bp, BNX2_MQ_CONFIG, val);
2857
2858 val = 0x10000 + (MAX_CID_CNT * MB_KERNEL_CTX_SIZE);
2859 REG_WR(bp, BNX2_MQ_KNL_BYP_WIND_START, val);
2860 REG_WR(bp, BNX2_MQ_KNL_WIND_END, val);
2861
2862 val = (BCM_PAGE_BITS - 8) << 24;
2863 REG_WR(bp, BNX2_RV2P_CONFIG, val);
2864
2865 /* Configure page size. */
2866 val = REG_RD(bp, BNX2_TBDR_CONFIG);
2867 val &= ~BNX2_TBDR_CONFIG_PAGE_SIZE;
2868 val |= (BCM_PAGE_BITS - 8) << 24 | 0x40;
2869 REG_WR(bp, BNX2_TBDR_CONFIG, val);
2870
2871 val = bp->mac_addr[0] +
2872 (bp->mac_addr[1] << 8) +
2873 (bp->mac_addr[2] << 16) +
2874 bp->mac_addr[3] +
2875 (bp->mac_addr[4] << 8) +
2876 (bp->mac_addr[5] << 16);
2877 REG_WR(bp, BNX2_EMAC_BACKOFF_SEED, val);
2878
2879 /* Program the MTU. Also include 4 bytes for CRC32. */
2880 val = bp->dev->mtu + ETH_HLEN + 4;
2881 if (val > (MAX_ETHERNET_PACKET_SIZE + 4))
2882 val |= BNX2_EMAC_RX_MTU_SIZE_JUMBO_ENA;
2883 REG_WR(bp, BNX2_EMAC_RX_MTU_SIZE, val);
2884
2885 bp->last_status_idx = 0;
2886 bp->rx_mode = BNX2_EMAC_RX_MODE_SORT_MODE;
2887
2888 /* Set up how to generate a link change interrupt. */
2889 REG_WR(bp, BNX2_EMAC_ATTENTION_ENA, BNX2_EMAC_ATTENTION_ENA_LINK);
2890
2891 REG_WR(bp, BNX2_HC_STATUS_ADDR_L,
2892 (u64) bp->status_blk_mapping & 0xffffffff);
2893 REG_WR(bp, BNX2_HC_STATUS_ADDR_H, (u64) bp->status_blk_mapping >> 32);
2894
2895 REG_WR(bp, BNX2_HC_STATISTICS_ADDR_L,
2896 (u64) bp->stats_blk_mapping & 0xffffffff);
2897 REG_WR(bp, BNX2_HC_STATISTICS_ADDR_H,
2898 (u64) bp->stats_blk_mapping >> 32);
2899
2900 REG_WR(bp, BNX2_HC_TX_QUICK_CONS_TRIP,
2901 (bp->tx_quick_cons_trip_int << 16) | bp->tx_quick_cons_trip);
2902
2903 REG_WR(bp, BNX2_HC_RX_QUICK_CONS_TRIP,
2904 (bp->rx_quick_cons_trip_int << 16) | bp->rx_quick_cons_trip);
2905
2906 REG_WR(bp, BNX2_HC_COMP_PROD_TRIP,
2907 (bp->comp_prod_trip_int << 16) | bp->comp_prod_trip);
2908
2909 REG_WR(bp, BNX2_HC_TX_TICKS, (bp->tx_ticks_int << 16) | bp->tx_ticks);
2910
2911 REG_WR(bp, BNX2_HC_RX_TICKS, (bp->rx_ticks_int << 16) | bp->rx_ticks);
2912
2913 REG_WR(bp, BNX2_HC_COM_TICKS,
2914 (bp->com_ticks_int << 16) | bp->com_ticks);
2915
2916 REG_WR(bp, BNX2_HC_CMD_TICKS,
2917 (bp->cmd_ticks_int << 16) | bp->cmd_ticks);
2918
2919 REG_WR(bp, BNX2_HC_STATS_TICKS, bp->stats_ticks & 0xffff00);
2920 REG_WR(bp, BNX2_HC_STAT_COLLECT_TICKS, 0xbb8); /* 3ms */
2921
2922 if (CHIP_ID(bp) == CHIP_ID_5706_A1)
2923 REG_WR(bp, BNX2_HC_CONFIG, BNX2_HC_CONFIG_COLLECT_STATS);
2924 else {
2925 REG_WR(bp, BNX2_HC_CONFIG, BNX2_HC_CONFIG_RX_TMR_MODE |
2926 BNX2_HC_CONFIG_TX_TMR_MODE |
2927 BNX2_HC_CONFIG_COLLECT_STATS);
2928 }
2929
2930 /* Clear internal stats counters. */
2931 REG_WR(bp, BNX2_HC_COMMAND, BNX2_HC_COMMAND_CLR_STAT_NOW);
2932
2933 REG_WR(bp, BNX2_HC_ATTN_BITS_ENABLE, STATUS_ATTN_BITS_LINK_STATE);
2934
2935 /* Initialize the receive filter. */
2936 bnx2_set_rx_mode(bp->dev);
2937
2938 bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT2 | BNX2_DRV_MSG_CODE_RESET);
2939
2940 REG_WR(bp, BNX2_MISC_ENABLE_SET_BITS, 0x5ffffff);
2941 REG_RD(bp, BNX2_MISC_ENABLE_SET_BITS);
2942
2943 udelay(20);
2944
2945 return 0;
2946}
2947
2948
2949static void
2950bnx2_init_tx_ring(struct bnx2 *bp)
2951{
2952 struct tx_bd *txbd;
2953 u32 val;
2954
2955 txbd = &bp->tx_desc_ring[MAX_TX_DESC_CNT];
2956
2957 txbd->tx_bd_haddr_hi = (u64) bp->tx_desc_mapping >> 32;
2958 txbd->tx_bd_haddr_lo = (u64) bp->tx_desc_mapping & 0xffffffff;
2959
2960 bp->tx_prod = 0;
2961 bp->tx_cons = 0;
2962 bp->tx_prod_bseq = 0;
2963 atomic_set(&bp->tx_avail_bd, bp->tx_ring_size);
2964
2965 val = BNX2_L2CTX_TYPE_TYPE_L2;
2966 val |= BNX2_L2CTX_TYPE_SIZE_L2;
2967 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_TYPE, val);
2968
2969 val = BNX2_L2CTX_CMD_TYPE_TYPE_L2;
2970 val |= 8 << 16;
2971 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_CMD_TYPE, val);
2972
2973 val = (u64) bp->tx_desc_mapping >> 32;
2974 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_TBDR_BHADDR_HI, val);
2975
2976 val = (u64) bp->tx_desc_mapping & 0xffffffff;
2977 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_TBDR_BHADDR_LO, val);
2978}
2979
2980static void
2981bnx2_init_rx_ring(struct bnx2 *bp)
2982{
2983 struct rx_bd *rxbd;
2984 int i;
2985 u16 prod, ring_prod;
2986 u32 val;
2987
2988 /* 8 for CRC and VLAN */
2989 bp->rx_buf_use_size = bp->dev->mtu + ETH_HLEN + bp->rx_offset + 8;
2990 /* 8 for alignment */
2991 bp->rx_buf_size = bp->rx_buf_use_size + 8;
2992
2993 ring_prod = prod = bp->rx_prod = 0;
2994 bp->rx_cons = 0;
2995 bp->rx_prod_bseq = 0;
2996
2997 rxbd = &bp->rx_desc_ring[0];
2998 for (i = 0; i < MAX_RX_DESC_CNT; i++, rxbd++) {
2999 rxbd->rx_bd_len = bp->rx_buf_use_size;
3000 rxbd->rx_bd_flags = RX_BD_FLAGS_START | RX_BD_FLAGS_END;
3001 }
3002
3003 rxbd->rx_bd_haddr_hi = (u64) bp->rx_desc_mapping >> 32;
3004 rxbd->rx_bd_haddr_lo = (u64) bp->rx_desc_mapping & 0xffffffff;
3005
3006 val = BNX2_L2CTX_CTX_TYPE_CTX_BD_CHN_TYPE_VALUE;
3007 val |= BNX2_L2CTX_CTX_TYPE_SIZE_L2;
3008 val |= 0x02 << 8;
3009 CTX_WR(bp, GET_CID_ADDR(RX_CID), BNX2_L2CTX_CTX_TYPE, val);
3010
3011 val = (u64) bp->rx_desc_mapping >> 32;
3012 CTX_WR(bp, GET_CID_ADDR(RX_CID), BNX2_L2CTX_NX_BDHADDR_HI, val);
3013
3014 val = (u64) bp->rx_desc_mapping & 0xffffffff;
3015 CTX_WR(bp, GET_CID_ADDR(RX_CID), BNX2_L2CTX_NX_BDHADDR_LO, val);
3016
3017 for ( ;ring_prod < bp->rx_ring_size; ) {
3018 if (bnx2_alloc_rx_skb(bp, ring_prod) < 0) {
3019 break;
3020 }
3021 prod = NEXT_RX_BD(prod);
3022 ring_prod = RX_RING_IDX(prod);
3023 }
3024 bp->rx_prod = prod;
3025
3026 REG_WR16(bp, MB_RX_CID_ADDR + BNX2_L2CTX_HOST_BDIDX, prod);
3027
3028 REG_WR(bp, MB_RX_CID_ADDR + BNX2_L2CTX_HOST_BSEQ, bp->rx_prod_bseq);
3029}
3030
3031static void
3032bnx2_free_tx_skbs(struct bnx2 *bp)
3033{
3034 int i;
3035
3036 if (bp->tx_buf_ring == NULL)
3037 return;
3038
3039 for (i = 0; i < TX_DESC_CNT; ) {
3040 struct sw_bd *tx_buf = &bp->tx_buf_ring[i];
3041 struct sk_buff *skb = tx_buf->skb;
3042 int j, last;
3043
3044 if (skb == NULL) {
3045 i++;
3046 continue;
3047 }
3048
3049 pci_unmap_single(bp->pdev, pci_unmap_addr(tx_buf, mapping),
3050 skb_headlen(skb), PCI_DMA_TODEVICE);
3051
3052 tx_buf->skb = NULL;
3053
3054 last = skb_shinfo(skb)->nr_frags;
3055 for (j = 0; j < last; j++) {
3056 tx_buf = &bp->tx_buf_ring[i + j + 1];
3057 pci_unmap_page(bp->pdev,
3058 pci_unmap_addr(tx_buf, mapping),
3059 skb_shinfo(skb)->frags[j].size,
3060 PCI_DMA_TODEVICE);
3061 }
3062 dev_kfree_skb_any(skb);
3063 i += j + 1;
3064 }
3065
3066}
3067
3068static void
3069bnx2_free_rx_skbs(struct bnx2 *bp)
3070{
3071 int i;
3072
3073 if (bp->rx_buf_ring == NULL)
3074 return;
3075
3076 for (i = 0; i < RX_DESC_CNT; i++) {
3077 struct sw_bd *rx_buf = &bp->rx_buf_ring[i];
3078 struct sk_buff *skb = rx_buf->skb;
3079
3080 if (skb == 0)
3081 continue;
3082
3083 pci_unmap_single(bp->pdev, pci_unmap_addr(rx_buf, mapping),
3084 bp->rx_buf_use_size, PCI_DMA_FROMDEVICE);
3085
3086 rx_buf->skb = NULL;
3087
3088 dev_kfree_skb_any(skb);
3089 }
3090}
3091
3092static void
3093bnx2_free_skbs(struct bnx2 *bp)
3094{
3095 bnx2_free_tx_skbs(bp);
3096 bnx2_free_rx_skbs(bp);
3097}
3098
3099static int
3100bnx2_reset_nic(struct bnx2 *bp, u32 reset_code)
3101{
3102 int rc;
3103
3104 rc = bnx2_reset_chip(bp, reset_code);
3105 bnx2_free_skbs(bp);
3106 if (rc)
3107 return rc;
3108
3109 bnx2_init_chip(bp);
3110 bnx2_init_tx_ring(bp);
3111 bnx2_init_rx_ring(bp);
3112 return 0;
3113}
3114
3115static int
3116bnx2_init_nic(struct bnx2 *bp)
3117{
3118 int rc;
3119
3120 if ((rc = bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET)) != 0)
3121 return rc;
3122
3123 bnx2_init_phy(bp);
3124 bnx2_set_link(bp);
3125 return 0;
3126}
3127
3128static int
3129bnx2_test_registers(struct bnx2 *bp)
3130{
3131 int ret;
3132 int i;
3133 static struct {
3134 u16 offset;
3135 u16 flags;
3136 u32 rw_mask;
3137 u32 ro_mask;
3138 } reg_tbl[] = {
3139 { 0x006c, 0, 0x00000000, 0x0000003f },
3140 { 0x0090, 0, 0xffffffff, 0x00000000 },
3141 { 0x0094, 0, 0x00000000, 0x00000000 },
3142
3143 { 0x0404, 0, 0x00003f00, 0x00000000 },
3144 { 0x0418, 0, 0x00000000, 0xffffffff },
3145 { 0x041c, 0, 0x00000000, 0xffffffff },
3146 { 0x0420, 0, 0x00000000, 0x80ffffff },
3147 { 0x0424, 0, 0x00000000, 0x00000000 },
3148 { 0x0428, 0, 0x00000000, 0x00000001 },
3149 { 0x0450, 0, 0x00000000, 0x0000ffff },
3150 { 0x0454, 0, 0x00000000, 0xffffffff },
3151 { 0x0458, 0, 0x00000000, 0xffffffff },
3152
3153 { 0x0808, 0, 0x00000000, 0xffffffff },
3154 { 0x0854, 0, 0x00000000, 0xffffffff },
3155 { 0x0868, 0, 0x00000000, 0x77777777 },
3156 { 0x086c, 0, 0x00000000, 0x77777777 },
3157 { 0x0870, 0, 0x00000000, 0x77777777 },
3158 { 0x0874, 0, 0x00000000, 0x77777777 },
3159
3160 { 0x0c00, 0, 0x00000000, 0x00000001 },
3161 { 0x0c04, 0, 0x00000000, 0x03ff0001 },
3162 { 0x0c08, 0, 0x0f0ff073, 0x00000000 },
3163 { 0x0c0c, 0, 0x00ffffff, 0x00000000 },
3164 { 0x0c30, 0, 0x00000000, 0xffffffff },
3165 { 0x0c34, 0, 0x00000000, 0xffffffff },
3166 { 0x0c38, 0, 0x00000000, 0xffffffff },
3167 { 0x0c3c, 0, 0x00000000, 0xffffffff },
3168 { 0x0c40, 0, 0x00000000, 0xffffffff },
3169 { 0x0c44, 0, 0x00000000, 0xffffffff },
3170 { 0x0c48, 0, 0x00000000, 0x0007ffff },
3171 { 0x0c4c, 0, 0x00000000, 0xffffffff },
3172 { 0x0c50, 0, 0x00000000, 0xffffffff },
3173 { 0x0c54, 0, 0x00000000, 0xffffffff },
3174 { 0x0c58, 0, 0x00000000, 0xffffffff },
3175 { 0x0c5c, 0, 0x00000000, 0xffffffff },
3176 { 0x0c60, 0, 0x00000000, 0xffffffff },
3177 { 0x0c64, 0, 0x00000000, 0xffffffff },
3178 { 0x0c68, 0, 0x00000000, 0xffffffff },
3179 { 0x0c6c, 0, 0x00000000, 0xffffffff },
3180 { 0x0c70, 0, 0x00000000, 0xffffffff },
3181 { 0x0c74, 0, 0x00000000, 0xffffffff },
3182 { 0x0c78, 0, 0x00000000, 0xffffffff },
3183 { 0x0c7c, 0, 0x00000000, 0xffffffff },
3184 { 0x0c80, 0, 0x00000000, 0xffffffff },
3185 { 0x0c84, 0, 0x00000000, 0xffffffff },
3186 { 0x0c88, 0, 0x00000000, 0xffffffff },
3187 { 0x0c8c, 0, 0x00000000, 0xffffffff },
3188 { 0x0c90, 0, 0x00000000, 0xffffffff },
3189 { 0x0c94, 0, 0x00000000, 0xffffffff },
3190 { 0x0c98, 0, 0x00000000, 0xffffffff },
3191 { 0x0c9c, 0, 0x00000000, 0xffffffff },
3192 { 0x0ca0, 0, 0x00000000, 0xffffffff },
3193 { 0x0ca4, 0, 0x00000000, 0xffffffff },
3194 { 0x0ca8, 0, 0x00000000, 0x0007ffff },
3195 { 0x0cac, 0, 0x00000000, 0xffffffff },
3196 { 0x0cb0, 0, 0x00000000, 0xffffffff },
3197 { 0x0cb4, 0, 0x00000000, 0xffffffff },
3198 { 0x0cb8, 0, 0x00000000, 0xffffffff },
3199 { 0x0cbc, 0, 0x00000000, 0xffffffff },
3200 { 0x0cc0, 0, 0x00000000, 0xffffffff },
3201 { 0x0cc4, 0, 0x00000000, 0xffffffff },
3202 { 0x0cc8, 0, 0x00000000, 0xffffffff },
3203 { 0x0ccc, 0, 0x00000000, 0xffffffff },
3204 { 0x0cd0, 0, 0x00000000, 0xffffffff },
3205 { 0x0cd4, 0, 0x00000000, 0xffffffff },
3206 { 0x0cd8, 0, 0x00000000, 0xffffffff },
3207 { 0x0cdc, 0, 0x00000000, 0xffffffff },
3208 { 0x0ce0, 0, 0x00000000, 0xffffffff },
3209 { 0x0ce4, 0, 0x00000000, 0xffffffff },
3210 { 0x0ce8, 0, 0x00000000, 0xffffffff },
3211 { 0x0cec, 0, 0x00000000, 0xffffffff },
3212 { 0x0cf0, 0, 0x00000000, 0xffffffff },
3213 { 0x0cf4, 0, 0x00000000, 0xffffffff },
3214 { 0x0cf8, 0, 0x00000000, 0xffffffff },
3215 { 0x0cfc, 0, 0x00000000, 0xffffffff },
3216 { 0x0d00, 0, 0x00000000, 0xffffffff },
3217 { 0x0d04, 0, 0x00000000, 0xffffffff },
3218
3219 { 0x1000, 0, 0x00000000, 0x00000001 },
3220 { 0x1004, 0, 0x00000000, 0x000f0001 },
3221 { 0x1044, 0, 0x00000000, 0xffc003ff },
3222 { 0x1080, 0, 0x00000000, 0x0001ffff },
3223 { 0x1084, 0, 0x00000000, 0xffffffff },
3224 { 0x1088, 0, 0x00000000, 0xffffffff },
3225 { 0x108c, 0, 0x00000000, 0xffffffff },
3226 { 0x1090, 0, 0x00000000, 0xffffffff },
3227 { 0x1094, 0, 0x00000000, 0xffffffff },
3228 { 0x1098, 0, 0x00000000, 0xffffffff },
3229 { 0x109c, 0, 0x00000000, 0xffffffff },
3230 { 0x10a0, 0, 0x00000000, 0xffffffff },
3231
3232 { 0x1408, 0, 0x01c00800, 0x00000000 },
3233 { 0x149c, 0, 0x8000ffff, 0x00000000 },
3234 { 0x14a8, 0, 0x00000000, 0x000001ff },
3235 { 0x14ac, 0, 0x4fffffff, 0x10000000 },
3236 { 0x14b0, 0, 0x00000002, 0x00000001 },
3237 { 0x14b8, 0, 0x00000000, 0x00000000 },
3238 { 0x14c0, 0, 0x00000000, 0x00000009 },
3239 { 0x14c4, 0, 0x00003fff, 0x00000000 },
3240 { 0x14cc, 0, 0x00000000, 0x00000001 },
3241 { 0x14d0, 0, 0xffffffff, 0x00000000 },
3242 { 0x1500, 0, 0x00000000, 0xffffffff },
3243 { 0x1504, 0, 0x00000000, 0xffffffff },
3244 { 0x1508, 0, 0x00000000, 0xffffffff },
3245 { 0x150c, 0, 0x00000000, 0xffffffff },
3246 { 0x1510, 0, 0x00000000, 0xffffffff },
3247 { 0x1514, 0, 0x00000000, 0xffffffff },
3248 { 0x1518, 0, 0x00000000, 0xffffffff },
3249 { 0x151c, 0, 0x00000000, 0xffffffff },
3250 { 0x1520, 0, 0x00000000, 0xffffffff },
3251 { 0x1524, 0, 0x00000000, 0xffffffff },
3252 { 0x1528, 0, 0x00000000, 0xffffffff },
3253 { 0x152c, 0, 0x00000000, 0xffffffff },
3254 { 0x1530, 0, 0x00000000, 0xffffffff },
3255 { 0x1534, 0, 0x00000000, 0xffffffff },
3256 { 0x1538, 0, 0x00000000, 0xffffffff },
3257 { 0x153c, 0, 0x00000000, 0xffffffff },
3258 { 0x1540, 0, 0x00000000, 0xffffffff },
3259 { 0x1544, 0, 0x00000000, 0xffffffff },
3260 { 0x1548, 0, 0x00000000, 0xffffffff },
3261 { 0x154c, 0, 0x00000000, 0xffffffff },
3262 { 0x1550, 0, 0x00000000, 0xffffffff },
3263 { 0x1554, 0, 0x00000000, 0xffffffff },
3264 { 0x1558, 0, 0x00000000, 0xffffffff },
3265 { 0x1600, 0, 0x00000000, 0xffffffff },
3266 { 0x1604, 0, 0x00000000, 0xffffffff },
3267 { 0x1608, 0, 0x00000000, 0xffffffff },
3268 { 0x160c, 0, 0x00000000, 0xffffffff },
3269 { 0x1610, 0, 0x00000000, 0xffffffff },
3270 { 0x1614, 0, 0x00000000, 0xffffffff },
3271 { 0x1618, 0, 0x00000000, 0xffffffff },
3272 { 0x161c, 0, 0x00000000, 0xffffffff },
3273 { 0x1620, 0, 0x00000000, 0xffffffff },
3274 { 0x1624, 0, 0x00000000, 0xffffffff },
3275 { 0x1628, 0, 0x00000000, 0xffffffff },
3276 { 0x162c, 0, 0x00000000, 0xffffffff },
3277 { 0x1630, 0, 0x00000000, 0xffffffff },
3278 { 0x1634, 0, 0x00000000, 0xffffffff },
3279 { 0x1638, 0, 0x00000000, 0xffffffff },
3280 { 0x163c, 0, 0x00000000, 0xffffffff },
3281 { 0x1640, 0, 0x00000000, 0xffffffff },
3282 { 0x1644, 0, 0x00000000, 0xffffffff },
3283 { 0x1648, 0, 0x00000000, 0xffffffff },
3284 { 0x164c, 0, 0x00000000, 0xffffffff },
3285 { 0x1650, 0, 0x00000000, 0xffffffff },
3286 { 0x1654, 0, 0x00000000, 0xffffffff },
3287
3288 { 0x1800, 0, 0x00000000, 0x00000001 },
3289 { 0x1804, 0, 0x00000000, 0x00000003 },
3290 { 0x1840, 0, 0x00000000, 0xffffffff },
3291 { 0x1844, 0, 0x00000000, 0xffffffff },
3292 { 0x1848, 0, 0x00000000, 0xffffffff },
3293 { 0x184c, 0, 0x00000000, 0xffffffff },
3294 { 0x1850, 0, 0x00000000, 0xffffffff },
3295 { 0x1900, 0, 0x7ffbffff, 0x00000000 },
3296 { 0x1904, 0, 0xffffffff, 0x00000000 },
3297 { 0x190c, 0, 0xffffffff, 0x00000000 },
3298 { 0x1914, 0, 0xffffffff, 0x00000000 },
3299 { 0x191c, 0, 0xffffffff, 0x00000000 },
3300 { 0x1924, 0, 0xffffffff, 0x00000000 },
3301 { 0x192c, 0, 0xffffffff, 0x00000000 },
3302 { 0x1934, 0, 0xffffffff, 0x00000000 },
3303 { 0x193c, 0, 0xffffffff, 0x00000000 },
3304 { 0x1944, 0, 0xffffffff, 0x00000000 },
3305 { 0x194c, 0, 0xffffffff, 0x00000000 },
3306 { 0x1954, 0, 0xffffffff, 0x00000000 },
3307 { 0x195c, 0, 0xffffffff, 0x00000000 },
3308 { 0x1964, 0, 0xffffffff, 0x00000000 },
3309 { 0x196c, 0, 0xffffffff, 0x00000000 },
3310 { 0x1974, 0, 0xffffffff, 0x00000000 },
3311 { 0x197c, 0, 0xffffffff, 0x00000000 },
3312 { 0x1980, 0, 0x0700ffff, 0x00000000 },
3313
3314 { 0x1c00, 0, 0x00000000, 0x00000001 },
3315 { 0x1c04, 0, 0x00000000, 0x00000003 },
3316 { 0x1c08, 0, 0x0000000f, 0x00000000 },
3317 { 0x1c40, 0, 0x00000000, 0xffffffff },
3318 { 0x1c44, 0, 0x00000000, 0xffffffff },
3319 { 0x1c48, 0, 0x00000000, 0xffffffff },
3320 { 0x1c4c, 0, 0x00000000, 0xffffffff },
3321 { 0x1c50, 0, 0x00000000, 0xffffffff },
3322 { 0x1d00, 0, 0x7ffbffff, 0x00000000 },
3323 { 0x1d04, 0, 0xffffffff, 0x00000000 },
3324 { 0x1d0c, 0, 0xffffffff, 0x00000000 },
3325 { 0x1d14, 0, 0xffffffff, 0x00000000 },
3326 { 0x1d1c, 0, 0xffffffff, 0x00000000 },
3327 { 0x1d24, 0, 0xffffffff, 0x00000000 },
3328 { 0x1d2c, 0, 0xffffffff, 0x00000000 },
3329 { 0x1d34, 0, 0xffffffff, 0x00000000 },
3330 { 0x1d3c, 0, 0xffffffff, 0x00000000 },
3331 { 0x1d44, 0, 0xffffffff, 0x00000000 },
3332 { 0x1d4c, 0, 0xffffffff, 0x00000000 },
3333 { 0x1d54, 0, 0xffffffff, 0x00000000 },
3334 { 0x1d5c, 0, 0xffffffff, 0x00000000 },
3335 { 0x1d64, 0, 0xffffffff, 0x00000000 },
3336 { 0x1d6c, 0, 0xffffffff, 0x00000000 },
3337 { 0x1d74, 0, 0xffffffff, 0x00000000 },
3338 { 0x1d7c, 0, 0xffffffff, 0x00000000 },
3339 { 0x1d80, 0, 0x0700ffff, 0x00000000 },
3340
3341 { 0x2004, 0, 0x00000000, 0x0337000f },
3342 { 0x2008, 0, 0xffffffff, 0x00000000 },
3343 { 0x200c, 0, 0xffffffff, 0x00000000 },
3344 { 0x2010, 0, 0xffffffff, 0x00000000 },
3345 { 0x2014, 0, 0x801fff80, 0x00000000 },
3346 { 0x2018, 0, 0x000003ff, 0x00000000 },
3347
3348 { 0x2800, 0, 0x00000000, 0x00000001 },
3349 { 0x2804, 0, 0x00000000, 0x00003f01 },
3350 { 0x2808, 0, 0x0f3f3f03, 0x00000000 },
3351 { 0x2810, 0, 0xffff0000, 0x00000000 },
3352 { 0x2814, 0, 0xffff0000, 0x00000000 },
3353 { 0x2818, 0, 0xffff0000, 0x00000000 },
3354 { 0x281c, 0, 0xffff0000, 0x00000000 },
3355 { 0x2834, 0, 0xffffffff, 0x00000000 },
3356 { 0x2840, 0, 0x00000000, 0xffffffff },
3357 { 0x2844, 0, 0x00000000, 0xffffffff },
3358 { 0x2848, 0, 0xffffffff, 0x00000000 },
3359 { 0x284c, 0, 0xf800f800, 0x07ff07ff },
3360
3361 { 0x2c00, 0, 0x00000000, 0x00000011 },
3362 { 0x2c04, 0, 0x00000000, 0x00030007 },
3363
3364 { 0x3000, 0, 0x00000000, 0x00000001 },
3365 { 0x3004, 0, 0x00000000, 0x007007ff },
3366 { 0x3008, 0, 0x00000003, 0x00000000 },
3367 { 0x300c, 0, 0xffffffff, 0x00000000 },
3368 { 0x3010, 0, 0xffffffff, 0x00000000 },
3369 { 0x3014, 0, 0xffffffff, 0x00000000 },
3370 { 0x3034, 0, 0xffffffff, 0x00000000 },
3371 { 0x3038, 0, 0xffffffff, 0x00000000 },
3372 { 0x3050, 0, 0x00000001, 0x00000000 },
3373
3374 { 0x3c00, 0, 0x00000000, 0x00000001 },
3375 { 0x3c04, 0, 0x00000000, 0x00070000 },
3376 { 0x3c08, 0, 0x00007f71, 0x07f00000 },
3377 { 0x3c0c, 0, 0x1f3ffffc, 0x00000000 },
3378 { 0x3c10, 0, 0xffffffff, 0x00000000 },
3379 { 0x3c14, 0, 0x00000000, 0xffffffff },
3380 { 0x3c18, 0, 0x00000000, 0xffffffff },
3381 { 0x3c1c, 0, 0xfffff000, 0x00000000 },
3382 { 0x3c20, 0, 0xffffff00, 0x00000000 },
3383 { 0x3c24, 0, 0xffffffff, 0x00000000 },
3384 { 0x3c28, 0, 0xffffffff, 0x00000000 },
3385 { 0x3c2c, 0, 0xffffffff, 0x00000000 },
3386 { 0x3c30, 0, 0xffffffff, 0x00000000 },
3387 { 0x3c34, 0, 0xffffffff, 0x00000000 },
3388 { 0x3c38, 0, 0xffffffff, 0x00000000 },
3389 { 0x3c3c, 0, 0xffffffff, 0x00000000 },
3390 { 0x3c40, 0, 0xffffffff, 0x00000000 },
3391 { 0x3c44, 0, 0xffffffff, 0x00000000 },
3392 { 0x3c48, 0, 0xffffffff, 0x00000000 },
3393 { 0x3c4c, 0, 0xffffffff, 0x00000000 },
3394 { 0x3c50, 0, 0xffffffff, 0x00000000 },
3395 { 0x3c54, 0, 0xffffffff, 0x00000000 },
3396 { 0x3c58, 0, 0xffffffff, 0x00000000 },
3397 { 0x3c5c, 0, 0xffffffff, 0x00000000 },
3398 { 0x3c60, 0, 0xffffffff, 0x00000000 },
3399 { 0x3c64, 0, 0xffffffff, 0x00000000 },
3400 { 0x3c68, 0, 0xffffffff, 0x00000000 },
3401 { 0x3c6c, 0, 0xffffffff, 0x00000000 },
3402 { 0x3c70, 0, 0xffffffff, 0x00000000 },
3403 { 0x3c74, 0, 0x0000003f, 0x00000000 },
3404 { 0x3c78, 0, 0x00000000, 0x00000000 },
3405 { 0x3c7c, 0, 0x00000000, 0x00000000 },
3406 { 0x3c80, 0, 0x3fffffff, 0x00000000 },
3407 { 0x3c84, 0, 0x0000003f, 0x00000000 },
3408 { 0x3c88, 0, 0x00000000, 0xffffffff },
3409 { 0x3c8c, 0, 0x00000000, 0xffffffff },
3410
3411 { 0x4000, 0, 0x00000000, 0x00000001 },
3412 { 0x4004, 0, 0x00000000, 0x00030000 },
3413 { 0x4008, 0, 0x00000ff0, 0x00000000 },
3414 { 0x400c, 0, 0xffffffff, 0x00000000 },
3415 { 0x4088, 0, 0x00000000, 0x00070303 },
3416
3417 { 0x4400, 0, 0x00000000, 0x00000001 },
3418 { 0x4404, 0, 0x00000000, 0x00003f01 },
3419 { 0x4408, 0, 0x7fff00ff, 0x00000000 },
3420 { 0x440c, 0, 0xffffffff, 0x00000000 },
3421 { 0x4410, 0, 0xffff, 0x0000 },
3422 { 0x4414, 0, 0xffff, 0x0000 },
3423 { 0x4418, 0, 0xffff, 0x0000 },
3424 { 0x441c, 0, 0xffff, 0x0000 },
3425 { 0x4428, 0, 0xffffffff, 0x00000000 },
3426 { 0x442c, 0, 0xffffffff, 0x00000000 },
3427 { 0x4430, 0, 0xffffffff, 0x00000000 },
3428 { 0x4434, 0, 0xffffffff, 0x00000000 },
3429 { 0x4438, 0, 0xffffffff, 0x00000000 },
3430 { 0x443c, 0, 0xffffffff, 0x00000000 },
3431 { 0x4440, 0, 0xffffffff, 0x00000000 },
3432 { 0x4444, 0, 0xffffffff, 0x00000000 },
3433
3434 { 0x4c00, 0, 0x00000000, 0x00000001 },
3435 { 0x4c04, 0, 0x00000000, 0x0000003f },
3436 { 0x4c08, 0, 0xffffffff, 0x00000000 },
3437 { 0x4c0c, 0, 0x0007fc00, 0x00000000 },
3438 { 0x4c10, 0, 0x80003fe0, 0x00000000 },
3439 { 0x4c14, 0, 0xffffffff, 0x00000000 },
3440 { 0x4c44, 0, 0x00000000, 0x9fff9fff },
3441 { 0x4c48, 0, 0x00000000, 0xb3009fff },
3442 { 0x4c4c, 0, 0x00000000, 0x77f33b30 },
3443 { 0x4c50, 0, 0x00000000, 0xffffffff },
3444
3445 { 0x5004, 0, 0x00000000, 0x0000007f },
3446 { 0x5008, 0, 0x0f0007ff, 0x00000000 },
3447 { 0x500c, 0, 0xf800f800, 0x07ff07ff },
3448
3449 { 0x5400, 0, 0x00000008, 0x00000001 },
3450 { 0x5404, 0, 0x00000000, 0x0000003f },
3451 { 0x5408, 0, 0x0000001f, 0x00000000 },
3452 { 0x540c, 0, 0xffffffff, 0x00000000 },
3453 { 0x5410, 0, 0xffffffff, 0x00000000 },
3454 { 0x5414, 0, 0x0000ffff, 0x00000000 },
3455 { 0x5418, 0, 0x0000ffff, 0x00000000 },
3456 { 0x541c, 0, 0x0000ffff, 0x00000000 },
3457 { 0x5420, 0, 0x0000ffff, 0x00000000 },
3458 { 0x5428, 0, 0x000000ff, 0x00000000 },
3459 { 0x542c, 0, 0xff00ffff, 0x00000000 },
3460 { 0x5430, 0, 0x001fff80, 0x00000000 },
3461 { 0x5438, 0, 0xffffffff, 0x00000000 },
3462 { 0x543c, 0, 0xffffffff, 0x00000000 },
3463 { 0x5440, 0, 0xf800f800, 0x07ff07ff },
3464
3465 { 0x5c00, 0, 0x00000000, 0x00000001 },
3466 { 0x5c04, 0, 0x00000000, 0x0003000f },
3467 { 0x5c08, 0, 0x00000003, 0x00000000 },
3468 { 0x5c0c, 0, 0x0000fff8, 0x00000000 },
3469 { 0x5c10, 0, 0x00000000, 0xffffffff },
3470 { 0x5c80, 0, 0x00000000, 0x0f7113f1 },
3471 { 0x5c84, 0, 0x00000000, 0x0000f333 },
3472 { 0x5c88, 0, 0x00000000, 0x00077373 },
3473 { 0x5c8c, 0, 0x00000000, 0x0007f737 },
3474
3475 { 0x6808, 0, 0x0000ff7f, 0x00000000 },
3476 { 0x680c, 0, 0xffffffff, 0x00000000 },
3477 { 0x6810, 0, 0xffffffff, 0x00000000 },
3478 { 0x6814, 0, 0xffffffff, 0x00000000 },
3479 { 0x6818, 0, 0xffffffff, 0x00000000 },
3480 { 0x681c, 0, 0xffffffff, 0x00000000 },
3481 { 0x6820, 0, 0x00ff00ff, 0x00000000 },
3482 { 0x6824, 0, 0x00ff00ff, 0x00000000 },
3483 { 0x6828, 0, 0x00ff00ff, 0x00000000 },
3484 { 0x682c, 0, 0x03ff03ff, 0x00000000 },
3485 { 0x6830, 0, 0x03ff03ff, 0x00000000 },
3486 { 0x6834, 0, 0x03ff03ff, 0x00000000 },
3487 { 0x6838, 0, 0x03ff03ff, 0x00000000 },
3488 { 0x683c, 0, 0x0000ffff, 0x00000000 },
3489 { 0x6840, 0, 0x00000ff0, 0x00000000 },
3490 { 0x6844, 0, 0x00ffff00, 0x00000000 },
3491 { 0x684c, 0, 0xffffffff, 0x00000000 },
3492 { 0x6850, 0, 0x7f7f7f7f, 0x00000000 },
3493 { 0x6854, 0, 0x7f7f7f7f, 0x00000000 },
3494 { 0x6858, 0, 0x7f7f7f7f, 0x00000000 },
3495 { 0x685c, 0, 0x7f7f7f7f, 0x00000000 },
3496 { 0x6908, 0, 0x00000000, 0x0001ff0f },
3497 { 0x690c, 0, 0x00000000, 0x0ffe00f0 },
3498
3499 { 0xffff, 0, 0x00000000, 0x00000000 },
3500 };
3501
3502 ret = 0;
3503 for (i = 0; reg_tbl[i].offset != 0xffff; i++) {
3504 u32 offset, rw_mask, ro_mask, save_val, val;
3505
3506 offset = (u32) reg_tbl[i].offset;
3507 rw_mask = reg_tbl[i].rw_mask;
3508 ro_mask = reg_tbl[i].ro_mask;
3509
3510 save_val = readl((u8 *) bp->regview + offset);
3511
3512 writel(0, (u8 *) bp->regview + offset);
3513
3514 val = readl((u8 *) bp->regview + offset);
3515 if ((val & rw_mask) != 0) {
3516 goto reg_test_err;
3517 }
3518
3519 if ((val & ro_mask) != (save_val & ro_mask)) {
3520 goto reg_test_err;
3521 }
3522
3523 writel(0xffffffff, (u8 *) bp->regview + offset);
3524
3525 val = readl((u8 *) bp->regview + offset);
3526 if ((val & rw_mask) != rw_mask) {
3527 goto reg_test_err;
3528 }
3529
3530 if ((val & ro_mask) != (save_val & ro_mask)) {
3531 goto reg_test_err;
3532 }
3533
3534 writel(save_val, (u8 *) bp->regview + offset);
3535 continue;
3536
3537reg_test_err:
3538 writel(save_val, (u8 *) bp->regview + offset);
3539 ret = -ENODEV;
3540 break;
3541 }
3542 return ret;
3543}
3544
3545static int
3546bnx2_do_mem_test(struct bnx2 *bp, u32 start, u32 size)
3547{
3548 static u32 test_pattern[] = { 0x00000000, 0xffffffff, 0x55555555,
3549 0xaaaaaaaa , 0xaa55aa55, 0x55aa55aa };
3550 int i;
3551
3552 for (i = 0; i < sizeof(test_pattern) / 4; i++) {
3553 u32 offset;
3554
3555 for (offset = 0; offset < size; offset += 4) {
3556
3557 REG_WR_IND(bp, start + offset, test_pattern[i]);
3558
3559 if (REG_RD_IND(bp, start + offset) !=
3560 test_pattern[i]) {
3561 return -ENODEV;
3562 }
3563 }
3564 }
3565 return 0;
3566}
3567
3568static int
3569bnx2_test_memory(struct bnx2 *bp)
3570{
3571 int ret = 0;
3572 int i;
3573 static struct {
3574 u32 offset;
3575 u32 len;
3576 } mem_tbl[] = {
3577 { 0x60000, 0x4000 },
3578 { 0xa0000, 0x4000 },
3579 { 0xe0000, 0x4000 },
3580 { 0x120000, 0x4000 },
3581 { 0x1a0000, 0x4000 },
3582 { 0x160000, 0x4000 },
3583 { 0xffffffff, 0 },
3584 };
3585
3586 for (i = 0; mem_tbl[i].offset != 0xffffffff; i++) {
3587 if ((ret = bnx2_do_mem_test(bp, mem_tbl[i].offset,
3588 mem_tbl[i].len)) != 0) {
3589 return ret;
3590 }
3591 }
3592
3593 return ret;
3594}
3595
3596static int
3597bnx2_test_loopback(struct bnx2 *bp)
3598{
3599 unsigned int pkt_size, num_pkts, i;
3600 struct sk_buff *skb, *rx_skb;
3601 unsigned char *packet;
3602 u16 rx_start_idx, rx_idx, send_idx;
3603 u32 send_bseq, val;
3604 dma_addr_t map;
3605 struct tx_bd *txbd;
3606 struct sw_bd *rx_buf;
3607 struct l2_fhdr *rx_hdr;
3608 int ret = -ENODEV;
3609
3610 if (!netif_running(bp->dev))
3611 return -ENODEV;
3612
3613 bp->loopback = MAC_LOOPBACK;
3614 bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_DIAG);
3615 bnx2_set_mac_loopback(bp);
3616
3617 pkt_size = 1514;
3618 skb = dev_alloc_skb(pkt_size);
3619 packet = skb_put(skb, pkt_size);
3620 memcpy(packet, bp->mac_addr, 6);
3621 memset(packet + 6, 0x0, 8);
3622 for (i = 14; i < pkt_size; i++)
3623 packet[i] = (unsigned char) (i & 0xff);
3624
3625 map = pci_map_single(bp->pdev, skb->data, pkt_size,
3626 PCI_DMA_TODEVICE);
3627
3628 val = REG_RD(bp, BNX2_HC_COMMAND);
3629 REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
3630 REG_RD(bp, BNX2_HC_COMMAND);
3631
3632 udelay(5);
3633 rx_start_idx = bp->status_blk->status_rx_quick_consumer_index0;
3634
3635 send_idx = 0;
3636 send_bseq = 0;
3637 num_pkts = 0;
3638
3639 txbd = &bp->tx_desc_ring[send_idx];
3640
3641 txbd->tx_bd_haddr_hi = (u64) map >> 32;
3642 txbd->tx_bd_haddr_lo = (u64) map & 0xffffffff;
3643 txbd->tx_bd_mss_nbytes = pkt_size;
3644 txbd->tx_bd_vlan_tag_flags = TX_BD_FLAGS_START | TX_BD_FLAGS_END;
3645
3646 num_pkts++;
3647 send_idx = NEXT_TX_BD(send_idx);
3648
3649 send_bseq += pkt_size;
3650
3651 REG_WR16(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BIDX, send_idx);
3652 REG_WR(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BSEQ, send_bseq);
3653
3654
3655 udelay(100);
3656
3657 val = REG_RD(bp, BNX2_HC_COMMAND);
3658 REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
3659 REG_RD(bp, BNX2_HC_COMMAND);
3660
3661 udelay(5);
3662
3663 pci_unmap_single(bp->pdev, map, pkt_size, PCI_DMA_TODEVICE);
3664 dev_kfree_skb_irq(skb);
3665
3666 if (bp->status_blk->status_tx_quick_consumer_index0 != send_idx) {
3667 goto loopback_test_done;
3668 }
3669
3670 rx_idx = bp->status_blk->status_rx_quick_consumer_index0;
3671 if (rx_idx != rx_start_idx + num_pkts) {
3672 goto loopback_test_done;
3673 }
3674
3675 rx_buf = &bp->rx_buf_ring[rx_start_idx];
3676 rx_skb = rx_buf->skb;
3677
3678 rx_hdr = (struct l2_fhdr *) rx_skb->data;
3679 skb_reserve(rx_skb, bp->rx_offset);
3680
3681 pci_dma_sync_single_for_cpu(bp->pdev,
3682 pci_unmap_addr(rx_buf, mapping),
3683 bp->rx_buf_size, PCI_DMA_FROMDEVICE);
3684
3685 if (rx_hdr->l2_fhdr_errors &
3686 (L2_FHDR_ERRORS_BAD_CRC |
3687 L2_FHDR_ERRORS_PHY_DECODE |
3688 L2_FHDR_ERRORS_ALIGNMENT |
3689 L2_FHDR_ERRORS_TOO_SHORT |
3690 L2_FHDR_ERRORS_GIANT_FRAME)) {
3691
3692 goto loopback_test_done;
3693 }
3694
3695 if ((rx_hdr->l2_fhdr_pkt_len - 4) != pkt_size) {
3696 goto loopback_test_done;
3697 }
3698
3699 for (i = 14; i < pkt_size; i++) {
3700 if (*(rx_skb->data + i) != (unsigned char) (i & 0xff)) {
3701 goto loopback_test_done;
3702 }
3703 }
3704
3705 ret = 0;
3706
3707loopback_test_done:
3708 bp->loopback = 0;
3709 return ret;
3710}
3711
3712#define NVRAM_SIZE 0x200
3713#define CRC32_RESIDUAL 0xdebb20e3
3714
3715static int
3716bnx2_test_nvram(struct bnx2 *bp)
3717{
3718 u32 buf[NVRAM_SIZE / 4];
3719 u8 *data = (u8 *) buf;
3720 int rc = 0;
3721 u32 magic, csum;
3722
3723 if ((rc = bnx2_nvram_read(bp, 0, data, 4)) != 0)
3724 goto test_nvram_done;
3725
3726 magic = be32_to_cpu(buf[0]);
3727 if (magic != 0x669955aa) {
3728 rc = -ENODEV;
3729 goto test_nvram_done;
3730 }
3731
3732 if ((rc = bnx2_nvram_read(bp, 0x100, data, NVRAM_SIZE)) != 0)
3733 goto test_nvram_done;
3734
3735 csum = ether_crc_le(0x100, data);
3736 if (csum != CRC32_RESIDUAL) {
3737 rc = -ENODEV;
3738 goto test_nvram_done;
3739 }
3740
3741 csum = ether_crc_le(0x100, data + 0x100);
3742 if (csum != CRC32_RESIDUAL) {
3743 rc = -ENODEV;
3744 }
3745
3746test_nvram_done:
3747 return rc;
3748}
3749
3750static int
3751bnx2_test_link(struct bnx2 *bp)
3752{
3753 u32 bmsr;
3754
3755 spin_lock_irq(&bp->phy_lock);
3756 bnx2_read_phy(bp, MII_BMSR, &bmsr);
3757 bnx2_read_phy(bp, MII_BMSR, &bmsr);
3758 spin_unlock_irq(&bp->phy_lock);
3759
3760 if (bmsr & BMSR_LSTATUS) {
3761 return 0;
3762 }
3763 return -ENODEV;
3764}
3765
3766static int
3767bnx2_test_intr(struct bnx2 *bp)
3768{
3769 int i;
3770 u32 val;
3771 u16 status_idx;
3772
3773 if (!netif_running(bp->dev))
3774 return -ENODEV;
3775
3776 status_idx = REG_RD(bp, BNX2_PCICFG_INT_ACK_CMD) & 0xffff;
3777
3778 /* This register is not touched during run-time. */
3779 val = REG_RD(bp, BNX2_HC_COMMAND);
3780 REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW);
3781 REG_RD(bp, BNX2_HC_COMMAND);
3782
3783 for (i = 0; i < 10; i++) {
3784 if ((REG_RD(bp, BNX2_PCICFG_INT_ACK_CMD) & 0xffff) !=
3785 status_idx) {
3786
3787 break;
3788 }
3789
3790 msleep_interruptible(10);
3791 }
3792 if (i < 10)
3793 return 0;
3794
3795 return -ENODEV;
3796}
3797
3798static void
3799bnx2_timer(unsigned long data)
3800{
3801 struct bnx2 *bp = (struct bnx2 *) data;
3802 u32 msg;
3803
3804 if (atomic_read(&bp->intr_sem) != 0)
3805 goto bnx2_restart_timer;
3806
3807 msg = (u32) ++bp->fw_drv_pulse_wr_seq;
3808 REG_WR_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_DRV_PULSE_MB, msg);
3809
3810 if ((bp->phy_flags & PHY_SERDES_FLAG) &&
3811 (CHIP_NUM(bp) == CHIP_NUM_5706)) {
3812 unsigned long flags;
3813
3814 spin_lock_irqsave(&bp->phy_lock, flags);
3815 if (bp->serdes_an_pending) {
3816 bp->serdes_an_pending--;
3817 }
3818 else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) {
3819 u32 bmcr;
3820
3821 bnx2_read_phy(bp, MII_BMCR, &bmcr);
3822
3823 if (bmcr & BMCR_ANENABLE) {
3824 u32 phy1, phy2;
3825
3826 bnx2_write_phy(bp, 0x1c, 0x7c00);
3827 bnx2_read_phy(bp, 0x1c, &phy1);
3828
3829 bnx2_write_phy(bp, 0x17, 0x0f01);
3830 bnx2_read_phy(bp, 0x15, &phy2);
3831 bnx2_write_phy(bp, 0x17, 0x0f01);
3832 bnx2_read_phy(bp, 0x15, &phy2);
3833
3834 if ((phy1 & 0x10) && /* SIGNAL DETECT */
3835 !(phy2 & 0x20)) { /* no CONFIG */
3836
3837 bmcr &= ~BMCR_ANENABLE;
3838 bmcr |= BMCR_SPEED1000 |
3839 BMCR_FULLDPLX;
3840 bnx2_write_phy(bp, MII_BMCR, bmcr);
3841 bp->phy_flags |=
3842 PHY_PARALLEL_DETECT_FLAG;
3843 }
3844 }
3845 }
3846 else if ((bp->link_up) && (bp->autoneg & AUTONEG_SPEED) &&
3847 (bp->phy_flags & PHY_PARALLEL_DETECT_FLAG)) {
3848 u32 phy2;
3849
3850 bnx2_write_phy(bp, 0x17, 0x0f01);
3851 bnx2_read_phy(bp, 0x15, &phy2);
3852 if (phy2 & 0x20) {
3853 u32 bmcr;
3854
3855 bnx2_read_phy(bp, MII_BMCR, &bmcr);
3856 bmcr |= BMCR_ANENABLE;
3857 bnx2_write_phy(bp, MII_BMCR, bmcr);
3858
3859 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
3860
3861 }
3862 }
3863
3864 spin_unlock_irqrestore(&bp->phy_lock, flags);
3865 }
3866
3867bnx2_restart_timer:
3868 bp->timer.expires = RUN_AT(bp->timer_interval);
3869
3870 add_timer(&bp->timer);
3871}
3872
3873/* Called with rtnl_lock */
3874static int
3875bnx2_open(struct net_device *dev)
3876{
3877 struct bnx2 *bp = dev->priv;
3878 int rc;
3879
3880 bnx2_set_power_state(bp, 0);
3881 bnx2_disable_int(bp);
3882
3883 rc = bnx2_alloc_mem(bp);
3884 if (rc)
3885 return rc;
3886
3887 if ((CHIP_ID(bp) != CHIP_ID_5706_A0) &&
3888 (CHIP_ID(bp) != CHIP_ID_5706_A1) &&
3889 !disable_msi) {
3890
3891 if (pci_enable_msi(bp->pdev) == 0) {
3892 bp->flags |= USING_MSI_FLAG;
3893 rc = request_irq(bp->pdev->irq, bnx2_msi, 0, dev->name,
3894 dev);
3895 }
3896 else {
3897 rc = request_irq(bp->pdev->irq, bnx2_interrupt,
3898 SA_SHIRQ, dev->name, dev);
3899 }
3900 }
3901 else {
3902 rc = request_irq(bp->pdev->irq, bnx2_interrupt, SA_SHIRQ,
3903 dev->name, dev);
3904 }
3905 if (rc) {
3906 bnx2_free_mem(bp);
3907 return rc;
3908 }
3909
3910 rc = bnx2_init_nic(bp);
3911
3912 if (rc) {
3913 free_irq(bp->pdev->irq, dev);
3914 if (bp->flags & USING_MSI_FLAG) {
3915 pci_disable_msi(bp->pdev);
3916 bp->flags &= ~USING_MSI_FLAG;
3917 }
3918 bnx2_free_skbs(bp);
3919 bnx2_free_mem(bp);
3920 return rc;
3921 }
3922
3923 init_timer(&bp->timer);
3924
3925 bp->timer.expires = RUN_AT(bp->timer_interval);
3926 bp->timer.data = (unsigned long) bp;
3927 bp->timer.function = bnx2_timer;
3928 add_timer(&bp->timer);
3929
3930 atomic_set(&bp->intr_sem, 0);
3931
3932 bnx2_enable_int(bp);
3933
3934 if (bp->flags & USING_MSI_FLAG) {
3935 /* Test MSI to make sure it is working
3936 * If MSI test fails, go back to INTx mode
3937 */
3938 if (bnx2_test_intr(bp) != 0) {
3939 printk(KERN_WARNING PFX "%s: No interrupt was generated"
3940 " using MSI, switching to INTx mode. Please"
3941 " report this failure to the PCI maintainer"
3942 " and include system chipset information.\n",
3943 bp->dev->name);
3944
3945 bnx2_disable_int(bp);
3946 free_irq(bp->pdev->irq, dev);
3947 pci_disable_msi(bp->pdev);
3948 bp->flags &= ~USING_MSI_FLAG;
3949
3950 rc = bnx2_init_nic(bp);
3951
3952 if (!rc) {
3953 rc = request_irq(bp->pdev->irq, bnx2_interrupt,
3954 SA_SHIRQ, dev->name, dev);
3955 }
3956 if (rc) {
3957 bnx2_free_skbs(bp);
3958 bnx2_free_mem(bp);
3959 del_timer_sync(&bp->timer);
3960 return rc;
3961 }
3962 bnx2_enable_int(bp);
3963 }
3964 }
3965 if (bp->flags & USING_MSI_FLAG) {
3966 printk(KERN_INFO PFX "%s: using MSI\n", dev->name);
3967 }
3968
3969 netif_start_queue(dev);
3970
3971 return 0;
3972}
3973
3974static void
3975bnx2_reset_task(void *data)
3976{
3977 struct bnx2 *bp = data;
3978
3979 bnx2_netif_stop(bp);
3980
3981 bnx2_init_nic(bp);
3982
3983 atomic_set(&bp->intr_sem, 1);
3984 bnx2_netif_start(bp);
3985}
3986
3987static void
3988bnx2_tx_timeout(struct net_device *dev)
3989{
3990 struct bnx2 *bp = dev->priv;
3991
3992 /* This allows the netif to be shutdown gracefully before resetting */
3993 schedule_work(&bp->reset_task);
3994}
3995
3996#ifdef BCM_VLAN
3997/* Called with rtnl_lock */
3998static void
3999bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp)
4000{
4001 struct bnx2 *bp = dev->priv;
4002
4003 bnx2_netif_stop(bp);
4004
4005 bp->vlgrp = vlgrp;
4006 bnx2_set_rx_mode(dev);
4007
4008 bnx2_netif_start(bp);
4009}
4010
4011/* Called with rtnl_lock */
4012static void
4013bnx2_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid)
4014{
4015 struct bnx2 *bp = dev->priv;
4016
4017 bnx2_netif_stop(bp);
4018
4019 if (bp->vlgrp)
4020 bp->vlgrp->vlan_devices[vid] = NULL;
4021 bnx2_set_rx_mode(dev);
4022
4023 bnx2_netif_start(bp);
4024}
4025#endif
4026
4027/* Called with dev->xmit_lock.
4028 * hard_start_xmit is pseudo-lockless - a lock is only required when
4029 * the tx queue is full. This way, we get the benefit of lockless
4030 * operations most of the time without the complexities to handle
4031 * netif_stop_queue/wake_queue race conditions.
4032 */
4033static int
4034bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
4035{
4036 struct bnx2 *bp = dev->priv;
4037 dma_addr_t mapping;
4038 struct tx_bd *txbd;
4039 struct sw_bd *tx_buf;
4040 u32 len, vlan_tag_flags, last_frag, mss;
4041 u16 prod, ring_prod;
4042 int i;
4043
4044 if (unlikely(atomic_read(&bp->tx_avail_bd) <
4045 (skb_shinfo(skb)->nr_frags + 1))) {
4046
4047 netif_stop_queue(dev);
4048 printk(KERN_ERR PFX "%s: BUG! Tx ring full when queue awake!\n",
4049 dev->name);
4050
4051 return NETDEV_TX_BUSY;
4052 }
4053 len = skb_headlen(skb);
4054 prod = bp->tx_prod;
4055 ring_prod = TX_RING_IDX(prod);
4056
4057 vlan_tag_flags = 0;
4058 if (skb->ip_summed == CHECKSUM_HW) {
4059 vlan_tag_flags |= TX_BD_FLAGS_TCP_UDP_CKSUM;
4060 }
4061
4062 if (bp->vlgrp != 0 && vlan_tx_tag_present(skb)) {
4063 vlan_tag_flags |=
4064 (TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16));
4065 }
4066#ifdef BCM_TSO
4067 if ((mss = skb_shinfo(skb)->tso_size) &&
4068 (skb->len > (bp->dev->mtu + ETH_HLEN))) {
4069 u32 tcp_opt_len, ip_tcp_len;
4070
4071 if (skb_header_cloned(skb) &&
4072 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
4073 dev_kfree_skb(skb);
4074 return NETDEV_TX_OK;
4075 }
4076
4077 tcp_opt_len = ((skb->h.th->doff - 5) * 4);
4078 vlan_tag_flags |= TX_BD_FLAGS_SW_LSO;
4079
4080 tcp_opt_len = 0;
4081 if (skb->h.th->doff > 5) {
4082 tcp_opt_len = (skb->h.th->doff - 5) << 2;
4083 }
4084 ip_tcp_len = (skb->nh.iph->ihl << 2) + sizeof(struct tcphdr);
4085
4086 skb->nh.iph->check = 0;
4087 skb->nh.iph->tot_len = ntohs(mss + ip_tcp_len + tcp_opt_len);
4088 skb->h.th->check =
4089 ~csum_tcpudp_magic(skb->nh.iph->saddr,
4090 skb->nh.iph->daddr,
4091 0, IPPROTO_TCP, 0);
4092
4093 if (tcp_opt_len || (skb->nh.iph->ihl > 5)) {
4094 vlan_tag_flags |= ((skb->nh.iph->ihl - 5) +
4095 (tcp_opt_len >> 2)) << 8;
4096 }
4097 }
4098 else
4099#endif
4100 {
4101 mss = 0;
4102 }
4103
4104 mapping = pci_map_single(bp->pdev, skb->data, len, PCI_DMA_TODEVICE);
4105
4106 tx_buf = &bp->tx_buf_ring[ring_prod];
4107 tx_buf->skb = skb;
4108 pci_unmap_addr_set(tx_buf, mapping, mapping);
4109
4110 txbd = &bp->tx_desc_ring[ring_prod];
4111
4112 txbd->tx_bd_haddr_hi = (u64) mapping >> 32;
4113 txbd->tx_bd_haddr_lo = (u64) mapping & 0xffffffff;
4114 txbd->tx_bd_mss_nbytes = len | (mss << 16);
4115 txbd->tx_bd_vlan_tag_flags = vlan_tag_flags | TX_BD_FLAGS_START;
4116
4117 last_frag = skb_shinfo(skb)->nr_frags;
4118
4119 for (i = 0; i < last_frag; i++) {
4120 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
4121
4122 prod = NEXT_TX_BD(prod);
4123 ring_prod = TX_RING_IDX(prod);
4124 txbd = &bp->tx_desc_ring[ring_prod];
4125
4126 len = frag->size;
4127 mapping = pci_map_page(bp->pdev, frag->page, frag->page_offset,
4128 len, PCI_DMA_TODEVICE);
4129 pci_unmap_addr_set(&bp->tx_buf_ring[ring_prod],
4130 mapping, mapping);
4131
4132 txbd->tx_bd_haddr_hi = (u64) mapping >> 32;
4133 txbd->tx_bd_haddr_lo = (u64) mapping & 0xffffffff;
4134 txbd->tx_bd_mss_nbytes = len | (mss << 16);
4135 txbd->tx_bd_vlan_tag_flags = vlan_tag_flags;
4136
4137 }
4138 txbd->tx_bd_vlan_tag_flags |= TX_BD_FLAGS_END;
4139
4140 prod = NEXT_TX_BD(prod);
4141 bp->tx_prod_bseq += skb->len;
4142
4143 atomic_sub(last_frag + 1, &bp->tx_avail_bd);
4144
4145 REG_WR16(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BIDX, prod);
4146 REG_WR(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BSEQ, bp->tx_prod_bseq);
4147
4148 mmiowb();
4149
4150 bp->tx_prod = prod;
4151 dev->trans_start = jiffies;
4152
4153 if (unlikely(atomic_read(&bp->tx_avail_bd) <= MAX_SKB_FRAGS)) {
4154 unsigned long flags;
4155
4156 spin_lock_irqsave(&bp->tx_lock, flags);
4157 if (atomic_read(&bp->tx_avail_bd) <= MAX_SKB_FRAGS) {
4158 netif_stop_queue(dev);
4159
4160 if (atomic_read(&bp->tx_avail_bd) > MAX_SKB_FRAGS)
4161 netif_wake_queue(dev);
4162 }
4163 spin_unlock_irqrestore(&bp->tx_lock, flags);
4164 }
4165
4166 return NETDEV_TX_OK;
4167}
4168
4169/* Called with rtnl_lock */
4170static int
4171bnx2_close(struct net_device *dev)
4172{
4173 struct bnx2 *bp = dev->priv;
4174 u32 reset_code;
4175
4176 flush_scheduled_work();
4177 bnx2_netif_stop(bp);
4178 del_timer_sync(&bp->timer);
4179 if (bp->wol)
4180 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
4181 else
4182 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
4183 bnx2_reset_chip(bp, reset_code);
4184 free_irq(bp->pdev->irq, dev);
4185 if (bp->flags & USING_MSI_FLAG) {
4186 pci_disable_msi(bp->pdev);
4187 bp->flags &= ~USING_MSI_FLAG;
4188 }
4189 bnx2_free_skbs(bp);
4190 bnx2_free_mem(bp);
4191 bp->link_up = 0;
4192 netif_carrier_off(bp->dev);
4193 bnx2_set_power_state(bp, 3);
4194 return 0;
4195}
4196
4197#define GET_NET_STATS64(ctr) \
4198 (unsigned long) ((unsigned long) (ctr##_hi) << 32) + \
4199 (unsigned long) (ctr##_lo)
4200
4201#define GET_NET_STATS32(ctr) \
4202 (ctr##_lo)
4203
4204#if (BITS_PER_LONG == 64)
4205#define GET_NET_STATS GET_NET_STATS64
4206#else
4207#define GET_NET_STATS GET_NET_STATS32
4208#endif
4209
4210static struct net_device_stats *
4211bnx2_get_stats(struct net_device *dev)
4212{
4213 struct bnx2 *bp = dev->priv;
4214 struct statistics_block *stats_blk = bp->stats_blk;
4215 struct net_device_stats *net_stats = &bp->net_stats;
4216
4217 if (bp->stats_blk == NULL) {
4218 return net_stats;
4219 }
4220 net_stats->rx_packets =
4221 GET_NET_STATS(stats_blk->stat_IfHCInUcastPkts) +
4222 GET_NET_STATS(stats_blk->stat_IfHCInMulticastPkts) +
4223 GET_NET_STATS(stats_blk->stat_IfHCInBroadcastPkts);
4224
4225 net_stats->tx_packets =
4226 GET_NET_STATS(stats_blk->stat_IfHCOutUcastPkts) +
4227 GET_NET_STATS(stats_blk->stat_IfHCOutMulticastPkts) +
4228 GET_NET_STATS(stats_blk->stat_IfHCOutBroadcastPkts);
4229
4230 net_stats->rx_bytes =
4231 GET_NET_STATS(stats_blk->stat_IfHCInOctets);
4232
4233 net_stats->tx_bytes =
4234 GET_NET_STATS(stats_blk->stat_IfHCOutOctets);
4235
4236 net_stats->multicast =
4237 GET_NET_STATS(stats_blk->stat_IfHCOutMulticastPkts);
4238
4239 net_stats->collisions =
4240 (unsigned long) stats_blk->stat_EtherStatsCollisions;
4241
4242 net_stats->rx_length_errors =
4243 (unsigned long) (stats_blk->stat_EtherStatsUndersizePkts +
4244 stats_blk->stat_EtherStatsOverrsizePkts);
4245
4246 net_stats->rx_over_errors =
4247 (unsigned long) stats_blk->stat_IfInMBUFDiscards;
4248
4249 net_stats->rx_frame_errors =
4250 (unsigned long) stats_blk->stat_Dot3StatsAlignmentErrors;
4251
4252 net_stats->rx_crc_errors =
4253 (unsigned long) stats_blk->stat_Dot3StatsFCSErrors;
4254
4255 net_stats->rx_errors = net_stats->rx_length_errors +
4256 net_stats->rx_over_errors + net_stats->rx_frame_errors +
4257 net_stats->rx_crc_errors;
4258
4259 net_stats->tx_aborted_errors =
4260 (unsigned long) (stats_blk->stat_Dot3StatsExcessiveCollisions +
4261 stats_blk->stat_Dot3StatsLateCollisions);
4262
4263 if (CHIP_NUM(bp) == CHIP_NUM_5706)
4264 net_stats->tx_carrier_errors = 0;
4265 else {
4266 net_stats->tx_carrier_errors =
4267 (unsigned long)
4268 stats_blk->stat_Dot3StatsCarrierSenseErrors;
4269 }
4270
4271 net_stats->tx_errors =
4272 (unsigned long)
4273 stats_blk->stat_emac_tx_stat_dot3statsinternalmactransmiterrors
4274 +
4275 net_stats->tx_aborted_errors +
4276 net_stats->tx_carrier_errors;
4277
4278 return net_stats;
4279}
4280
4281/* All ethtool functions called with rtnl_lock */
4282
4283static int
4284bnx2_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4285{
4286 struct bnx2 *bp = dev->priv;
4287
4288 cmd->supported = SUPPORTED_Autoneg;
4289 if (bp->phy_flags & PHY_SERDES_FLAG) {
4290 cmd->supported |= SUPPORTED_1000baseT_Full |
4291 SUPPORTED_FIBRE;
4292
4293 cmd->port = PORT_FIBRE;
4294 }
4295 else {
4296 cmd->supported |= SUPPORTED_10baseT_Half |
4297 SUPPORTED_10baseT_Full |
4298 SUPPORTED_100baseT_Half |
4299 SUPPORTED_100baseT_Full |
4300 SUPPORTED_1000baseT_Full |
4301 SUPPORTED_TP;
4302
4303 cmd->port = PORT_TP;
4304 }
4305
4306 cmd->advertising = bp->advertising;
4307
4308 if (bp->autoneg & AUTONEG_SPEED) {
4309 cmd->autoneg = AUTONEG_ENABLE;
4310 }
4311 else {
4312 cmd->autoneg = AUTONEG_DISABLE;
4313 }
4314
4315 if (netif_carrier_ok(dev)) {
4316 cmd->speed = bp->line_speed;
4317 cmd->duplex = bp->duplex;
4318 }
4319 else {
4320 cmd->speed = -1;
4321 cmd->duplex = -1;
4322 }
4323
4324 cmd->transceiver = XCVR_INTERNAL;
4325 cmd->phy_address = bp->phy_addr;
4326
4327 return 0;
4328}
4329
4330static int
4331bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4332{
4333 struct bnx2 *bp = dev->priv;
4334 u8 autoneg = bp->autoneg;
4335 u8 req_duplex = bp->req_duplex;
4336 u16 req_line_speed = bp->req_line_speed;
4337 u32 advertising = bp->advertising;
4338
4339 if (cmd->autoneg == AUTONEG_ENABLE) {
4340 autoneg |= AUTONEG_SPEED;
4341
4342 cmd->advertising &= ETHTOOL_ALL_COPPER_SPEED;
4343
4344 /* allow advertising 1 speed */
4345 if ((cmd->advertising == ADVERTISED_10baseT_Half) ||
4346 (cmd->advertising == ADVERTISED_10baseT_Full) ||
4347 (cmd->advertising == ADVERTISED_100baseT_Half) ||
4348 (cmd->advertising == ADVERTISED_100baseT_Full)) {
4349
4350 if (bp->phy_flags & PHY_SERDES_FLAG)
4351 return -EINVAL;
4352
4353 advertising = cmd->advertising;
4354
4355 }
4356 else if (cmd->advertising == ADVERTISED_1000baseT_Full) {
4357 advertising = cmd->advertising;
4358 }
4359 else if (cmd->advertising == ADVERTISED_1000baseT_Half) {
4360 return -EINVAL;
4361 }
4362 else {
4363 if (bp->phy_flags & PHY_SERDES_FLAG) {
4364 advertising = ETHTOOL_ALL_FIBRE_SPEED;
4365 }
4366 else {
4367 advertising = ETHTOOL_ALL_COPPER_SPEED;
4368 }
4369 }
4370 advertising |= ADVERTISED_Autoneg;
4371 }
4372 else {
4373 if (bp->phy_flags & PHY_SERDES_FLAG) {
4374 if ((cmd->speed != SPEED_1000) ||
4375 (cmd->duplex != DUPLEX_FULL)) {
4376 return -EINVAL;
4377 }
4378 }
4379 else if (cmd->speed == SPEED_1000) {
4380 return -EINVAL;
4381 }
4382 autoneg &= ~AUTONEG_SPEED;
4383 req_line_speed = cmd->speed;
4384 req_duplex = cmd->duplex;
4385 advertising = 0;
4386 }
4387
4388 bp->autoneg = autoneg;
4389 bp->advertising = advertising;
4390 bp->req_line_speed = req_line_speed;
4391 bp->req_duplex = req_duplex;
4392
4393 spin_lock_irq(&bp->phy_lock);
4394
4395 bnx2_setup_phy(bp);
4396
4397 spin_unlock_irq(&bp->phy_lock);
4398
4399 return 0;
4400}
4401
4402static void
4403bnx2_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
4404{
4405 struct bnx2 *bp = dev->priv;
4406
4407 strcpy(info->driver, DRV_MODULE_NAME);
4408 strcpy(info->version, DRV_MODULE_VERSION);
4409 strcpy(info->bus_info, pci_name(bp->pdev));
4410 info->fw_version[0] = ((bp->fw_ver & 0xff000000) >> 24) + '0';
4411 info->fw_version[2] = ((bp->fw_ver & 0xff0000) >> 16) + '0';
4412 info->fw_version[4] = ((bp->fw_ver & 0xff00) >> 8) + '0';
4413 info->fw_version[6] = (bp->fw_ver & 0xff) + '0';
4414 info->fw_version[1] = info->fw_version[3] = info->fw_version[5] = '.';
4415 info->fw_version[7] = 0;
4416}
4417
4418static void
4419bnx2_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
4420{
4421 struct bnx2 *bp = dev->priv;
4422
4423 if (bp->flags & NO_WOL_FLAG) {
4424 wol->supported = 0;
4425 wol->wolopts = 0;
4426 }
4427 else {
4428 wol->supported = WAKE_MAGIC;
4429 if (bp->wol)
4430 wol->wolopts = WAKE_MAGIC;
4431 else
4432 wol->wolopts = 0;
4433 }
4434 memset(&wol->sopass, 0, sizeof(wol->sopass));
4435}
4436
4437static int
4438bnx2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
4439{
4440 struct bnx2 *bp = dev->priv;
4441
4442 if (wol->wolopts & ~WAKE_MAGIC)
4443 return -EINVAL;
4444
4445 if (wol->wolopts & WAKE_MAGIC) {
4446 if (bp->flags & NO_WOL_FLAG)
4447 return -EINVAL;
4448
4449 bp->wol = 1;
4450 }
4451 else {
4452 bp->wol = 0;
4453 }
4454 return 0;
4455}
4456
4457static int
4458bnx2_nway_reset(struct net_device *dev)
4459{
4460 struct bnx2 *bp = dev->priv;
4461 u32 bmcr;
4462
4463 if (!(bp->autoneg & AUTONEG_SPEED)) {
4464 return -EINVAL;
4465 }
4466
4467 spin_lock_irq(&bp->phy_lock);
4468
4469 /* Force a link down visible on the other side */
4470 if (bp->phy_flags & PHY_SERDES_FLAG) {
4471 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK);
4472 spin_unlock_irq(&bp->phy_lock);
4473
4474 msleep(20);
4475
4476 spin_lock_irq(&bp->phy_lock);
4477 if (CHIP_NUM(bp) == CHIP_NUM_5706) {
4478 bp->serdes_an_pending = SERDES_AN_TIMEOUT /
4479 bp->timer_interval;
4480 }
4481 }
4482
4483 bnx2_read_phy(bp, MII_BMCR, &bmcr);
4484 bmcr &= ~BMCR_LOOPBACK;
4485 bnx2_write_phy(bp, MII_BMCR, bmcr | BMCR_ANRESTART | BMCR_ANENABLE);
4486
4487 spin_unlock_irq(&bp->phy_lock);
4488
4489 return 0;
4490}
4491
4492static int
4493bnx2_get_eeprom_len(struct net_device *dev)
4494{
4495 struct bnx2 *bp = dev->priv;
4496
4497 if (bp->flash_info == 0)
4498 return 0;
4499
4500 return (int) bp->flash_info->total_size;
4501}
4502
4503static int
4504bnx2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
4505 u8 *eebuf)
4506{
4507 struct bnx2 *bp = dev->priv;
4508 int rc;
4509
4510 if (eeprom->offset > bp->flash_info->total_size)
4511 return -EINVAL;
4512
4513 if ((eeprom->offset + eeprom->len) > bp->flash_info->total_size)
4514 eeprom->len = bp->flash_info->total_size - eeprom->offset;
4515
4516 rc = bnx2_nvram_read(bp, eeprom->offset, eebuf, eeprom->len);
4517
4518 return rc;
4519}
4520
4521static int
4522bnx2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
4523 u8 *eebuf)
4524{
4525 struct bnx2 *bp = dev->priv;
4526 int rc;
4527
4528 if (eeprom->offset > bp->flash_info->total_size)
4529 return -EINVAL;
4530
4531 if ((eeprom->offset + eeprom->len) > bp->flash_info->total_size)
4532 eeprom->len = bp->flash_info->total_size - eeprom->offset;
4533
4534 rc = bnx2_nvram_write(bp, eeprom->offset, eebuf, eeprom->len);
4535
4536 return rc;
4537}
4538
4539static int
4540bnx2_get_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
4541{
4542 struct bnx2 *bp = dev->priv;
4543
4544 memset(coal, 0, sizeof(struct ethtool_coalesce));
4545
4546 coal->rx_coalesce_usecs = bp->rx_ticks;
4547 coal->rx_max_coalesced_frames = bp->rx_quick_cons_trip;
4548 coal->rx_coalesce_usecs_irq = bp->rx_ticks_int;
4549 coal->rx_max_coalesced_frames_irq = bp->rx_quick_cons_trip_int;
4550
4551 coal->tx_coalesce_usecs = bp->tx_ticks;
4552 coal->tx_max_coalesced_frames = bp->tx_quick_cons_trip;
4553 coal->tx_coalesce_usecs_irq = bp->tx_ticks_int;
4554 coal->tx_max_coalesced_frames_irq = bp->tx_quick_cons_trip_int;
4555
4556 coal->stats_block_coalesce_usecs = bp->stats_ticks;
4557
4558 return 0;
4559}
4560
4561static int
4562bnx2_set_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
4563{
4564 struct bnx2 *bp = dev->priv;
4565
4566 bp->rx_ticks = (u16) coal->rx_coalesce_usecs;
4567 if (bp->rx_ticks > 0x3ff) bp->rx_ticks = 0x3ff;
4568
4569 bp->rx_quick_cons_trip = (u16) coal->rx_max_coalesced_frames;
4570 if (bp->rx_quick_cons_trip > 0xff) bp->rx_quick_cons_trip = 0xff;
4571
4572 bp->rx_ticks_int = (u16) coal->rx_coalesce_usecs_irq;
4573 if (bp->rx_ticks_int > 0x3ff) bp->rx_ticks_int = 0x3ff;
4574
4575 bp->rx_quick_cons_trip_int = (u16) coal->rx_max_coalesced_frames_irq;
4576 if (bp->rx_quick_cons_trip_int > 0xff)
4577 bp->rx_quick_cons_trip_int = 0xff;
4578
4579 bp->tx_ticks = (u16) coal->tx_coalesce_usecs;
4580 if (bp->tx_ticks > 0x3ff) bp->tx_ticks = 0x3ff;
4581
4582 bp->tx_quick_cons_trip = (u16) coal->tx_max_coalesced_frames;
4583 if (bp->tx_quick_cons_trip > 0xff) bp->tx_quick_cons_trip = 0xff;
4584
4585 bp->tx_ticks_int = (u16) coal->tx_coalesce_usecs_irq;
4586 if (bp->tx_ticks_int > 0x3ff) bp->tx_ticks_int = 0x3ff;
4587
4588 bp->tx_quick_cons_trip_int = (u16) coal->tx_max_coalesced_frames_irq;
4589 if (bp->tx_quick_cons_trip_int > 0xff) bp->tx_quick_cons_trip_int =
4590 0xff;
4591
4592 bp->stats_ticks = coal->stats_block_coalesce_usecs;
4593 if (bp->stats_ticks > 0xffff00) bp->stats_ticks = 0xffff00;
4594 bp->stats_ticks &= 0xffff00;
4595
4596 if (netif_running(bp->dev)) {
4597 bnx2_netif_stop(bp);
4598 bnx2_init_nic(bp);
4599 bnx2_netif_start(bp);
4600 }
4601
4602 return 0;
4603}
4604
4605static void
4606bnx2_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
4607{
4608 struct bnx2 *bp = dev->priv;
4609
4610 ering->rx_max_pending = MAX_RX_DESC_CNT;
4611 ering->rx_mini_max_pending = 0;
4612 ering->rx_jumbo_max_pending = 0;
4613
4614 ering->rx_pending = bp->rx_ring_size;
4615 ering->rx_mini_pending = 0;
4616 ering->rx_jumbo_pending = 0;
4617
4618 ering->tx_max_pending = MAX_TX_DESC_CNT;
4619 ering->tx_pending = bp->tx_ring_size;
4620}
4621
4622static int
4623bnx2_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
4624{
4625 struct bnx2 *bp = dev->priv;
4626
4627 if ((ering->rx_pending > MAX_RX_DESC_CNT) ||
4628 (ering->tx_pending > MAX_TX_DESC_CNT) ||
4629 (ering->tx_pending <= MAX_SKB_FRAGS)) {
4630
4631 return -EINVAL;
4632 }
4633 bp->rx_ring_size = ering->rx_pending;
4634 bp->tx_ring_size = ering->tx_pending;
4635
4636 if (netif_running(bp->dev)) {
4637 bnx2_netif_stop(bp);
4638 bnx2_init_nic(bp);
4639 bnx2_netif_start(bp);
4640 }
4641
4642 return 0;
4643}
4644
4645static void
4646bnx2_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
4647{
4648 struct bnx2 *bp = dev->priv;
4649
4650 epause->autoneg = ((bp->autoneg & AUTONEG_FLOW_CTRL) != 0);
4651 epause->rx_pause = ((bp->flow_ctrl & FLOW_CTRL_RX) != 0);
4652 epause->tx_pause = ((bp->flow_ctrl & FLOW_CTRL_TX) != 0);
4653}
4654
4655static int
4656bnx2_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
4657{
4658 struct bnx2 *bp = dev->priv;
4659
4660 bp->req_flow_ctrl = 0;
4661 if (epause->rx_pause)
4662 bp->req_flow_ctrl |= FLOW_CTRL_RX;
4663 if (epause->tx_pause)
4664 bp->req_flow_ctrl |= FLOW_CTRL_TX;
4665
4666 if (epause->autoneg) {
4667 bp->autoneg |= AUTONEG_FLOW_CTRL;
4668 }
4669 else {
4670 bp->autoneg &= ~AUTONEG_FLOW_CTRL;
4671 }
4672
4673 spin_lock_irq(&bp->phy_lock);
4674
4675 bnx2_setup_phy(bp);
4676
4677 spin_unlock_irq(&bp->phy_lock);
4678
4679 return 0;
4680}
4681
4682static u32
4683bnx2_get_rx_csum(struct net_device *dev)
4684{
4685 struct bnx2 *bp = dev->priv;
4686
4687 return bp->rx_csum;
4688}
4689
4690static int
4691bnx2_set_rx_csum(struct net_device *dev, u32 data)
4692{
4693 struct bnx2 *bp = dev->priv;
4694
4695 bp->rx_csum = data;
4696 return 0;
4697}
4698
4699#define BNX2_NUM_STATS 45
4700
4701struct {
4702 char string[ETH_GSTRING_LEN];
4703} bnx2_stats_str_arr[BNX2_NUM_STATS] = {
4704 { "rx_bytes" },
4705 { "rx_error_bytes" },
4706 { "tx_bytes" },
4707 { "tx_error_bytes" },
4708 { "rx_ucast_packets" },
4709 { "rx_mcast_packets" },
4710 { "rx_bcast_packets" },
4711 { "tx_ucast_packets" },
4712 { "tx_mcast_packets" },
4713 { "tx_bcast_packets" },
4714 { "tx_mac_errors" },
4715 { "tx_carrier_errors" },
4716 { "rx_crc_errors" },
4717 { "rx_align_errors" },
4718 { "tx_single_collisions" },
4719 { "tx_multi_collisions" },
4720 { "tx_deferred" },
4721 { "tx_excess_collisions" },
4722 { "tx_late_collisions" },
4723 { "tx_total_collisions" },
4724 { "rx_fragments" },
4725 { "rx_jabbers" },
4726 { "rx_undersize_packets" },
4727 { "rx_oversize_packets" },
4728 { "rx_64_byte_packets" },
4729 { "rx_65_to_127_byte_packets" },
4730 { "rx_128_to_255_byte_packets" },
4731 { "rx_256_to_511_byte_packets" },
4732 { "rx_512_to_1023_byte_packets" },
4733 { "rx_1024_to_1522_byte_packets" },
4734 { "rx_1523_to_9022_byte_packets" },
4735 { "tx_64_byte_packets" },
4736 { "tx_65_to_127_byte_packets" },
4737 { "tx_128_to_255_byte_packets" },
4738 { "tx_256_to_511_byte_packets" },
4739 { "tx_512_to_1023_byte_packets" },
4740 { "tx_1024_to_1522_byte_packets" },
4741 { "tx_1523_to_9022_byte_packets" },
4742 { "rx_xon_frames" },
4743 { "rx_xoff_frames" },
4744 { "tx_xon_frames" },
4745 { "tx_xoff_frames" },
4746 { "rx_mac_ctrl_frames" },
4747 { "rx_filtered_packets" },
4748 { "rx_discards" },
4749};
4750
4751#define STATS_OFFSET32(offset_name) (offsetof(struct statistics_block, offset_name) / 4)
4752
4753unsigned long bnx2_stats_offset_arr[BNX2_NUM_STATS] = {
4754 STATS_OFFSET32(stat_IfHCInOctets_hi),
4755 STATS_OFFSET32(stat_IfHCInBadOctets_hi),
4756 STATS_OFFSET32(stat_IfHCOutOctets_hi),
4757 STATS_OFFSET32(stat_IfHCOutBadOctets_hi),
4758 STATS_OFFSET32(stat_IfHCInUcastPkts_hi),
4759 STATS_OFFSET32(stat_IfHCInMulticastPkts_hi),
4760 STATS_OFFSET32(stat_IfHCInBroadcastPkts_hi),
4761 STATS_OFFSET32(stat_IfHCOutUcastPkts_hi),
4762 STATS_OFFSET32(stat_IfHCOutMulticastPkts_hi),
4763 STATS_OFFSET32(stat_IfHCOutBroadcastPkts_hi),
4764 STATS_OFFSET32(stat_emac_tx_stat_dot3statsinternalmactransmiterrors),
4765 STATS_OFFSET32(stat_Dot3StatsCarrierSenseErrors),
4766 STATS_OFFSET32(stat_Dot3StatsFCSErrors),
4767 STATS_OFFSET32(stat_Dot3StatsAlignmentErrors),
4768 STATS_OFFSET32(stat_Dot3StatsSingleCollisionFrames),
4769 STATS_OFFSET32(stat_Dot3StatsMultipleCollisionFrames),
4770 STATS_OFFSET32(stat_Dot3StatsDeferredTransmissions),
4771 STATS_OFFSET32(stat_Dot3StatsExcessiveCollisions),
4772 STATS_OFFSET32(stat_Dot3StatsLateCollisions),
4773 STATS_OFFSET32(stat_EtherStatsCollisions),
4774 STATS_OFFSET32(stat_EtherStatsFragments),
4775 STATS_OFFSET32(stat_EtherStatsJabbers),
4776 STATS_OFFSET32(stat_EtherStatsUndersizePkts),
4777 STATS_OFFSET32(stat_EtherStatsOverrsizePkts),
4778 STATS_OFFSET32(stat_EtherStatsPktsRx64Octets),
4779 STATS_OFFSET32(stat_EtherStatsPktsRx65Octetsto127Octets),
4780 STATS_OFFSET32(stat_EtherStatsPktsRx128Octetsto255Octets),
4781 STATS_OFFSET32(stat_EtherStatsPktsRx256Octetsto511Octets),
4782 STATS_OFFSET32(stat_EtherStatsPktsRx512Octetsto1023Octets),
4783 STATS_OFFSET32(stat_EtherStatsPktsRx1024Octetsto1522Octets),
4784 STATS_OFFSET32(stat_EtherStatsPktsRx1523Octetsto9022Octets),
4785 STATS_OFFSET32(stat_EtherStatsPktsTx64Octets),
4786 STATS_OFFSET32(stat_EtherStatsPktsTx65Octetsto127Octets),
4787 STATS_OFFSET32(stat_EtherStatsPktsTx128Octetsto255Octets),
4788 STATS_OFFSET32(stat_EtherStatsPktsTx256Octetsto511Octets),
4789 STATS_OFFSET32(stat_EtherStatsPktsTx512Octetsto1023Octets),
4790 STATS_OFFSET32(stat_EtherStatsPktsTx1024Octetsto1522Octets),
4791 STATS_OFFSET32(stat_EtherStatsPktsTx1523Octetsto9022Octets),
4792 STATS_OFFSET32(stat_XonPauseFramesReceived),
4793 STATS_OFFSET32(stat_XoffPauseFramesReceived),
4794 STATS_OFFSET32(stat_OutXonSent),
4795 STATS_OFFSET32(stat_OutXoffSent),
4796 STATS_OFFSET32(stat_MacControlFramesReceived),
4797 STATS_OFFSET32(stat_IfInFramesL2FilterDiscards),
4798 STATS_OFFSET32(stat_IfInMBUFDiscards),
4799};
4800
4801/* stat_IfHCInBadOctets and stat_Dot3StatsCarrierSenseErrors are
4802 * skipped because of errata.
4803 */
4804u8 bnx2_5706_stats_len_arr[BNX2_NUM_STATS] = {
4805 8,0,8,8,8,8,8,8,8,8,
4806 4,0,4,4,4,4,4,4,4,4,
4807 4,4,4,4,4,4,4,4,4,4,
4808 4,4,4,4,4,4,4,4,4,4,
4809 4,4,4,4,4,
4810};
4811
4812#define BNX2_NUM_TESTS 6
4813
4814struct {
4815 char string[ETH_GSTRING_LEN];
4816} bnx2_tests_str_arr[BNX2_NUM_TESTS] = {
4817 { "register_test (offline)" },
4818 { "memory_test (offline)" },
4819 { "loopback_test (offline)" },
4820 { "nvram_test (online)" },
4821 { "interrupt_test (online)" },
4822 { "link_test (online)" },
4823};
4824
4825static int
4826bnx2_self_test_count(struct net_device *dev)
4827{
4828 return BNX2_NUM_TESTS;
4829}
4830
4831static void
4832bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
4833{
4834 struct bnx2 *bp = dev->priv;
4835
4836 memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS);
4837 if (etest->flags & ETH_TEST_FL_OFFLINE) {
4838 bnx2_netif_stop(bp);
4839 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG);
4840 bnx2_free_skbs(bp);
4841
4842 if (bnx2_test_registers(bp) != 0) {
4843 buf[0] = 1;
4844 etest->flags |= ETH_TEST_FL_FAILED;
4845 }
4846 if (bnx2_test_memory(bp) != 0) {
4847 buf[1] = 1;
4848 etest->flags |= ETH_TEST_FL_FAILED;
4849 }
4850 if (bnx2_test_loopback(bp) != 0) {
4851 buf[2] = 1;
4852 etest->flags |= ETH_TEST_FL_FAILED;
4853 }
4854
4855 if (!netif_running(bp->dev)) {
4856 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET);
4857 }
4858 else {
4859 bnx2_init_nic(bp);
4860 bnx2_netif_start(bp);
4861 }
4862
4863 /* wait for link up */
4864 msleep_interruptible(3000);
4865 if ((!bp->link_up) && !(bp->phy_flags & PHY_SERDES_FLAG))
4866 msleep_interruptible(4000);
4867 }
4868
4869 if (bnx2_test_nvram(bp) != 0) {
4870 buf[3] = 1;
4871 etest->flags |= ETH_TEST_FL_FAILED;
4872 }
4873 if (bnx2_test_intr(bp) != 0) {
4874 buf[4] = 1;
4875 etest->flags |= ETH_TEST_FL_FAILED;
4876 }
4877
4878 if (bnx2_test_link(bp) != 0) {
4879 buf[5] = 1;
4880 etest->flags |= ETH_TEST_FL_FAILED;
4881
4882 }
4883}
4884
4885static void
4886bnx2_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
4887{
4888 switch (stringset) {
4889 case ETH_SS_STATS:
4890 memcpy(buf, bnx2_stats_str_arr,
4891 sizeof(bnx2_stats_str_arr));
4892 break;
4893 case ETH_SS_TEST:
4894 memcpy(buf, bnx2_tests_str_arr,
4895 sizeof(bnx2_tests_str_arr));
4896 break;
4897 }
4898}
4899
4900static int
4901bnx2_get_stats_count(struct net_device *dev)
4902{
4903 return BNX2_NUM_STATS;
4904}
4905
4906static void
4907bnx2_get_ethtool_stats(struct net_device *dev,
4908 struct ethtool_stats *stats, u64 *buf)
4909{
4910 struct bnx2 *bp = dev->priv;
4911 int i;
4912 u32 *hw_stats = (u32 *) bp->stats_blk;
4913 u8 *stats_len_arr = 0;
4914
4915 if (hw_stats == NULL) {
4916 memset(buf, 0, sizeof(u64) * BNX2_NUM_STATS);
4917 return;
4918 }
4919
4920 if (CHIP_NUM(bp) == CHIP_NUM_5706)
4921 stats_len_arr = bnx2_5706_stats_len_arr;
4922
4923 for (i = 0; i < BNX2_NUM_STATS; i++) {
4924 if (stats_len_arr[i] == 0) {
4925 /* skip this counter */
4926 buf[i] = 0;
4927 continue;
4928 }
4929 if (stats_len_arr[i] == 4) {
4930 /* 4-byte counter */
4931 buf[i] = (u64)
4932 *(hw_stats + bnx2_stats_offset_arr[i]);
4933 continue;
4934 }
4935 /* 8-byte counter */
4936 buf[i] = (((u64) *(hw_stats +
4937 bnx2_stats_offset_arr[i])) << 32) +
4938 *(hw_stats + bnx2_stats_offset_arr[i] + 1);
4939 }
4940}
4941
4942static int
4943bnx2_phys_id(struct net_device *dev, u32 data)
4944{
4945 struct bnx2 *bp = dev->priv;
4946 int i;
4947 u32 save;
4948
4949 if (data == 0)
4950 data = 2;
4951
4952 save = REG_RD(bp, BNX2_MISC_CFG);
4953 REG_WR(bp, BNX2_MISC_CFG, BNX2_MISC_CFG_LEDMODE_MAC);
4954
4955 for (i = 0; i < (data * 2); i++) {
4956 if ((i % 2) == 0) {
4957 REG_WR(bp, BNX2_EMAC_LED, BNX2_EMAC_LED_OVERRIDE);
4958 }
4959 else {
4960 REG_WR(bp, BNX2_EMAC_LED, BNX2_EMAC_LED_OVERRIDE |
4961 BNX2_EMAC_LED_1000MB_OVERRIDE |
4962 BNX2_EMAC_LED_100MB_OVERRIDE |
4963 BNX2_EMAC_LED_10MB_OVERRIDE |
4964 BNX2_EMAC_LED_TRAFFIC_OVERRIDE |
4965 BNX2_EMAC_LED_TRAFFIC);
4966 }
4967 msleep_interruptible(500);
4968 if (signal_pending(current))
4969 break;
4970 }
4971 REG_WR(bp, BNX2_EMAC_LED, 0);
4972 REG_WR(bp, BNX2_MISC_CFG, save);
4973 return 0;
4974}
4975
4976static struct ethtool_ops bnx2_ethtool_ops = {
4977 .get_settings = bnx2_get_settings,
4978 .set_settings = bnx2_set_settings,
4979 .get_drvinfo = bnx2_get_drvinfo,
4980 .get_wol = bnx2_get_wol,
4981 .set_wol = bnx2_set_wol,
4982 .nway_reset = bnx2_nway_reset,
4983 .get_link = ethtool_op_get_link,
4984 .get_eeprom_len = bnx2_get_eeprom_len,
4985 .get_eeprom = bnx2_get_eeprom,
4986 .set_eeprom = bnx2_set_eeprom,
4987 .get_coalesce = bnx2_get_coalesce,
4988 .set_coalesce = bnx2_set_coalesce,
4989 .get_ringparam = bnx2_get_ringparam,
4990 .set_ringparam = bnx2_set_ringparam,
4991 .get_pauseparam = bnx2_get_pauseparam,
4992 .set_pauseparam = bnx2_set_pauseparam,
4993 .get_rx_csum = bnx2_get_rx_csum,
4994 .set_rx_csum = bnx2_set_rx_csum,
4995 .get_tx_csum = ethtool_op_get_tx_csum,
4996 .set_tx_csum = ethtool_op_set_tx_csum,
4997 .get_sg = ethtool_op_get_sg,
4998 .set_sg = ethtool_op_set_sg,
4999#ifdef BCM_TSO
5000 .get_tso = ethtool_op_get_tso,
5001 .set_tso = ethtool_op_set_tso,
5002#endif
5003 .self_test_count = bnx2_self_test_count,
5004 .self_test = bnx2_self_test,
5005 .get_strings = bnx2_get_strings,
5006 .phys_id = bnx2_phys_id,
5007 .get_stats_count = bnx2_get_stats_count,
5008 .get_ethtool_stats = bnx2_get_ethtool_stats,
5009};
5010
5011/* Called with rtnl_lock */
5012static int
5013bnx2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
5014{
5015 struct mii_ioctl_data *data = (struct mii_ioctl_data *)&ifr->ifr_data;
5016 struct bnx2 *bp = dev->priv;
5017 int err;
5018
5019 switch(cmd) {
5020 case SIOCGMIIPHY:
5021 data->phy_id = bp->phy_addr;
5022
5023 /* fallthru */
5024 case SIOCGMIIREG: {
5025 u32 mii_regval;
5026
5027 spin_lock_irq(&bp->phy_lock);
5028 err = bnx2_read_phy(bp, data->reg_num & 0x1f, &mii_regval);
5029 spin_unlock_irq(&bp->phy_lock);
5030
5031 data->val_out = mii_regval;
5032
5033 return err;
5034 }
5035
5036 case SIOCSMIIREG:
5037 if (!capable(CAP_NET_ADMIN))
5038 return -EPERM;
5039
5040 spin_lock_irq(&bp->phy_lock);
5041 err = bnx2_write_phy(bp, data->reg_num & 0x1f, data->val_in);
5042 spin_unlock_irq(&bp->phy_lock);
5043
5044 return err;
5045
5046 default:
5047 /* do nothing */
5048 break;
5049 }
5050 return -EOPNOTSUPP;
5051}
5052
5053/* Called with rtnl_lock */
5054static int
5055bnx2_change_mac_addr(struct net_device *dev, void *p)
5056{
5057 struct sockaddr *addr = p;
5058 struct bnx2 *bp = dev->priv;
5059
5060 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
5061 if (netif_running(dev))
5062 bnx2_set_mac_addr(bp);
5063
5064 return 0;
5065}
5066
5067/* Called with rtnl_lock */
5068static int
5069bnx2_change_mtu(struct net_device *dev, int new_mtu)
5070{
5071 struct bnx2 *bp = dev->priv;
5072
5073 if (((new_mtu + ETH_HLEN) > MAX_ETHERNET_JUMBO_PACKET_SIZE) ||
5074 ((new_mtu + ETH_HLEN) < MIN_ETHERNET_PACKET_SIZE))
5075 return -EINVAL;
5076
5077 dev->mtu = new_mtu;
5078 if (netif_running(dev)) {
5079 bnx2_netif_stop(bp);
5080
5081 bnx2_init_nic(bp);
5082
5083 bnx2_netif_start(bp);
5084 }
5085 return 0;
5086}
5087
5088#if defined(HAVE_POLL_CONTROLLER) || defined(CONFIG_NET_POLL_CONTROLLER)
5089static void
5090poll_bnx2(struct net_device *dev)
5091{
5092 struct bnx2 *bp = dev->priv;
5093
5094 disable_irq(bp->pdev->irq);
5095 bnx2_interrupt(bp->pdev->irq, dev, NULL);
5096 enable_irq(bp->pdev->irq);
5097}
5098#endif
5099
5100static int __devinit
5101bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5102{
5103 struct bnx2 *bp;
5104 unsigned long mem_len;
5105 int rc;
5106 u32 reg;
5107
5108 SET_MODULE_OWNER(dev);
5109 SET_NETDEV_DEV(dev, &pdev->dev);
5110 bp = dev->priv;
5111
5112 bp->flags = 0;
5113 bp->phy_flags = 0;
5114
5115 /* enable device (incl. PCI PM wakeup), and bus-mastering */
5116 rc = pci_enable_device(pdev);
5117 if (rc) {
5118 printk(KERN_ERR PFX "Cannot enable PCI device, aborting.");
5119 goto err_out;
5120 }
5121
5122 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
5123 printk(KERN_ERR PFX "Cannot find PCI device base address, "
5124 "aborting.\n");
5125 rc = -ENODEV;
5126 goto err_out_disable;
5127 }
5128
5129 rc = pci_request_regions(pdev, DRV_MODULE_NAME);
5130 if (rc) {
5131 printk(KERN_ERR PFX "Cannot obtain PCI resources, aborting.\n");
5132 goto err_out_disable;
5133 }
5134
5135 pci_set_master(pdev);
5136
5137 bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
5138 if (bp->pm_cap == 0) {
5139 printk(KERN_ERR PFX "Cannot find power management capability, "
5140 "aborting.\n");
5141 rc = -EIO;
5142 goto err_out_release;
5143 }
5144
5145 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
5146 if (bp->pcix_cap == 0) {
5147 printk(KERN_ERR PFX "Cannot find PCIX capability, aborting.\n");
5148 rc = -EIO;
5149 goto err_out_release;
5150 }
5151
5152 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) {
5153 bp->flags |= USING_DAC_FLAG;
5154 if (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) != 0) {
5155 printk(KERN_ERR PFX "pci_set_consistent_dma_mask "
5156 "failed, aborting.\n");
5157 rc = -EIO;
5158 goto err_out_release;
5159 }
5160 }
5161 else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0) {
5162 printk(KERN_ERR PFX "System does not support DMA, aborting.\n");
5163 rc = -EIO;
5164 goto err_out_release;
5165 }
5166
5167 bp->dev = dev;
5168 bp->pdev = pdev;
5169
5170 spin_lock_init(&bp->phy_lock);
5171 spin_lock_init(&bp->tx_lock);
5172 INIT_WORK(&bp->reset_task, bnx2_reset_task, bp);
5173
5174 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0);
5175 mem_len = MB_GET_CID_ADDR(17);
5176 dev->mem_end = dev->mem_start + mem_len;
5177 dev->irq = pdev->irq;
5178
5179 bp->regview = ioremap_nocache(dev->base_addr, mem_len);
5180
5181 if (!bp->regview) {
5182 printk(KERN_ERR PFX "Cannot map register space, aborting.\n");
5183 rc = -ENOMEM;
5184 goto err_out_release;
5185 }
5186
5187 /* Configure byte swap and enable write to the reg_window registers.
5188 * Rely on CPU to do target byte swapping on big endian systems
5189 * The chip's target access swapping will not swap all accesses
5190 */
5191 pci_write_config_dword(bp->pdev, BNX2_PCICFG_MISC_CONFIG,
5192 BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA |
5193 BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP);
5194
5195 bnx2_set_power_state(bp, 0);
5196
5197 bp->chip_id = REG_RD(bp, BNX2_MISC_ID);
5198
5199 bp->phy_addr = 1;
5200
5201 /* Get bus information. */
5202 reg = REG_RD(bp, BNX2_PCICFG_MISC_STATUS);
5203 if (reg & BNX2_PCICFG_MISC_STATUS_PCIX_DET) {
5204 u32 clkreg;
5205
5206 bp->flags |= PCIX_FLAG;
5207
5208 clkreg = REG_RD(bp, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS);
5209
5210 clkreg &= BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET;
5211 switch (clkreg) {
5212 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_133MHZ:
5213 bp->bus_speed_mhz = 133;
5214 break;
5215
5216 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_95MHZ:
5217 bp->bus_speed_mhz = 100;
5218 break;
5219
5220 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_66MHZ:
5221 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_80MHZ:
5222 bp->bus_speed_mhz = 66;
5223 break;
5224
5225 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_48MHZ:
5226 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_55MHZ:
5227 bp->bus_speed_mhz = 50;
5228 break;
5229
5230 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_LOW:
5231 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_32MHZ:
5232 case BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_38MHZ:
5233 bp->bus_speed_mhz = 33;
5234 break;
5235 }
5236 }
5237 else {
5238 if (reg & BNX2_PCICFG_MISC_STATUS_M66EN)
5239 bp->bus_speed_mhz = 66;
5240 else
5241 bp->bus_speed_mhz = 33;
5242 }
5243
5244 if (reg & BNX2_PCICFG_MISC_STATUS_32BIT_DET)
5245 bp->flags |= PCI_32BIT_FLAG;
5246
5247 /* 5706A0 may falsely detect SERR and PERR. */
5248 if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
5249 reg = REG_RD(bp, PCI_COMMAND);
5250 reg &= ~(PCI_COMMAND_SERR | PCI_COMMAND_PARITY);
5251 REG_WR(bp, PCI_COMMAND, reg);
5252 }
5253 else if ((CHIP_ID(bp) == CHIP_ID_5706_A1) &&
5254 !(bp->flags & PCIX_FLAG)) {
5255
5256 printk(KERN_ERR PFX "5706 A1 can only be used in a PCIX bus, "
5257 "aborting.\n");
5258 goto err_out_unmap;
5259 }
5260
5261 bnx2_init_nvram(bp);
5262
5263 /* Get the permanent MAC address. First we need to make sure the
5264 * firmware is actually running.
5265 */
5266 reg = REG_RD_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_DEV_INFO_SIGNATURE);
5267
5268 if ((reg & BNX2_DEV_INFO_SIGNATURE_MAGIC_MASK) !=
5269 BNX2_DEV_INFO_SIGNATURE_MAGIC) {
5270 printk(KERN_ERR PFX "Firmware not running, aborting.\n");
5271 rc = -ENODEV;
5272 goto err_out_unmap;
5273 }
5274
5275 bp->fw_ver = REG_RD_IND(bp, HOST_VIEW_SHMEM_BASE +
5276 BNX2_DEV_INFO_BC_REV);
5277
5278 reg = REG_RD_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_PORT_HW_CFG_MAC_UPPER);
5279 bp->mac_addr[0] = (u8) (reg >> 8);
5280 bp->mac_addr[1] = (u8) reg;
5281
5282 reg = REG_RD_IND(bp, HOST_VIEW_SHMEM_BASE + BNX2_PORT_HW_CFG_MAC_LOWER);
5283 bp->mac_addr[2] = (u8) (reg >> 24);
5284 bp->mac_addr[3] = (u8) (reg >> 16);
5285 bp->mac_addr[4] = (u8) (reg >> 8);
5286 bp->mac_addr[5] = (u8) reg;
5287
5288 bp->tx_ring_size = MAX_TX_DESC_CNT;
5289 bp->rx_ring_size = 100;
5290
5291 bp->rx_csum = 1;
5292
5293 bp->rx_offset = sizeof(struct l2_fhdr) + 2;
5294
5295 bp->tx_quick_cons_trip_int = 20;
5296 bp->tx_quick_cons_trip = 20;
5297 bp->tx_ticks_int = 80;
5298 bp->tx_ticks = 80;
5299
5300 bp->rx_quick_cons_trip_int = 6;
5301 bp->rx_quick_cons_trip = 6;
5302 bp->rx_ticks_int = 18;
5303 bp->rx_ticks = 18;
5304
5305 bp->stats_ticks = 1000000 & 0xffff00;
5306
5307 bp->timer_interval = HZ;
5308
5309 /* Disable WOL support if we are running on a SERDES chip. */
5310 if (CHIP_BOND_ID(bp) & CHIP_BOND_ID_SERDES_BIT) {
5311 bp->phy_flags |= PHY_SERDES_FLAG;
5312 bp->flags |= NO_WOL_FLAG;
5313 }
5314
5315 if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
5316 bp->tx_quick_cons_trip_int =
5317 bp->tx_quick_cons_trip;
5318 bp->tx_ticks_int = bp->tx_ticks;
5319 bp->rx_quick_cons_trip_int =
5320 bp->rx_quick_cons_trip;
5321 bp->rx_ticks_int = bp->rx_ticks;
5322 bp->comp_prod_trip_int = bp->comp_prod_trip;
5323 bp->com_ticks_int = bp->com_ticks;
5324 bp->cmd_ticks_int = bp->cmd_ticks;
5325 }
5326
5327 bp->autoneg = AUTONEG_SPEED | AUTONEG_FLOW_CTRL;
5328 bp->req_line_speed = 0;
5329 if (bp->phy_flags & PHY_SERDES_FLAG) {
5330 bp->advertising = ETHTOOL_ALL_FIBRE_SPEED | ADVERTISED_Autoneg;
5331 }
5332 else {
5333 bp->advertising = ETHTOOL_ALL_COPPER_SPEED | ADVERTISED_Autoneg;
5334 }
5335
5336 bp->req_flow_ctrl = FLOW_CTRL_RX | FLOW_CTRL_TX;
5337
5338 return 0;
5339
5340err_out_unmap:
5341 if (bp->regview) {
5342 iounmap(bp->regview);
5343 }
5344
5345err_out_release:
5346 pci_release_regions(pdev);
5347
5348err_out_disable:
5349 pci_disable_device(pdev);
5350 pci_set_drvdata(pdev, NULL);
5351
5352err_out:
5353 return rc;
5354}
5355
5356static int __devinit
5357bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
5358{
5359 static int version_printed = 0;
5360 struct net_device *dev = NULL;
5361 struct bnx2 *bp;
5362 int rc, i;
5363
5364 if (version_printed++ == 0)
5365 printk(KERN_INFO "%s", version);
5366
5367 /* dev zeroed in init_etherdev */
5368 dev = alloc_etherdev(sizeof(*bp));
5369
5370 if (!dev)
5371 return -ENOMEM;
5372
5373 rc = bnx2_init_board(pdev, dev);
5374 if (rc < 0) {
5375 free_netdev(dev);
5376 return rc;
5377 }
5378
5379 dev->open = bnx2_open;
5380 dev->hard_start_xmit = bnx2_start_xmit;
5381 dev->stop = bnx2_close;
5382 dev->get_stats = bnx2_get_stats;
5383 dev->set_multicast_list = bnx2_set_rx_mode;
5384 dev->do_ioctl = bnx2_ioctl;
5385 dev->set_mac_address = bnx2_change_mac_addr;
5386 dev->change_mtu = bnx2_change_mtu;
5387 dev->tx_timeout = bnx2_tx_timeout;
5388 dev->watchdog_timeo = TX_TIMEOUT;
5389#ifdef BCM_VLAN
5390 dev->vlan_rx_register = bnx2_vlan_rx_register;
5391 dev->vlan_rx_kill_vid = bnx2_vlan_rx_kill_vid;
5392#endif
5393 dev->poll = bnx2_poll;
5394 dev->ethtool_ops = &bnx2_ethtool_ops;
5395 dev->weight = 64;
5396
5397 bp = dev->priv;
5398
5399#if defined(HAVE_POLL_CONTROLLER) || defined(CONFIG_NET_POLL_CONTROLLER)
5400 dev->poll_controller = poll_bnx2;
5401#endif
5402
5403 if ((rc = register_netdev(dev))) {
5404 printk(KERN_ERR PFX "Cannot register net device\n");
5405 if (bp->regview)
5406 iounmap(bp->regview);
5407 pci_release_regions(pdev);
5408 pci_disable_device(pdev);
5409 pci_set_drvdata(pdev, NULL);
5410 free_netdev(dev);
5411 return rc;
5412 }
5413
5414 pci_set_drvdata(pdev, dev);
5415
5416 memcpy(dev->dev_addr, bp->mac_addr, 6);
5417 bp->name = board_info[ent->driver_data].name,
5418 printk(KERN_INFO "%s: %s (%c%d) PCI%s %s %dMHz found at mem %lx, "
5419 "IRQ %d, ",
5420 dev->name,
5421 bp->name,
5422 ((CHIP_ID(bp) & 0xf000) >> 12) + 'A',
5423 ((CHIP_ID(bp) & 0x0ff0) >> 4),
5424 ((bp->flags & PCIX_FLAG) ? "-X" : ""),
5425 ((bp->flags & PCI_32BIT_FLAG) ? "32-bit" : "64-bit"),
5426 bp->bus_speed_mhz,
5427 dev->base_addr,
5428 bp->pdev->irq);
5429
5430 printk("node addr ");
5431 for (i = 0; i < 6; i++)
5432 printk("%2.2x", dev->dev_addr[i]);
5433 printk("\n");
5434
5435 dev->features |= NETIF_F_SG;
5436 if (bp->flags & USING_DAC_FLAG)
5437 dev->features |= NETIF_F_HIGHDMA;
5438 dev->features |= NETIF_F_IP_CSUM;
5439#ifdef BCM_VLAN
5440 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
5441#endif
5442#ifdef BCM_TSO
5443 dev->features |= NETIF_F_TSO;
5444#endif
5445
5446 netif_carrier_off(bp->dev);
5447
5448 return 0;
5449}
5450
5451static void __devexit
5452bnx2_remove_one(struct pci_dev *pdev)
5453{
5454 struct net_device *dev = pci_get_drvdata(pdev);
5455 struct bnx2 *bp = dev->priv;
5456
5457 unregister_netdev(dev);
5458
5459 if (bp->regview)
5460 iounmap(bp->regview);
5461
5462 free_netdev(dev);
5463 pci_release_regions(pdev);
5464 pci_disable_device(pdev);
5465 pci_set_drvdata(pdev, NULL);
5466}
5467
5468static int
5469bnx2_suspend(struct pci_dev *pdev, u32 state)
5470{
5471 struct net_device *dev = pci_get_drvdata(pdev);
5472 struct bnx2 *bp = dev->priv;
5473 u32 reset_code;
5474
5475 if (!netif_running(dev))
5476 return 0;
5477
5478 bnx2_netif_stop(bp);
5479 netif_device_detach(dev);
5480 del_timer_sync(&bp->timer);
5481 if (bp->wol)
5482 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
5483 else
5484 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
5485 bnx2_reset_chip(bp, reset_code);
5486 bnx2_free_skbs(bp);
5487 bnx2_set_power_state(bp, state);
5488 return 0;
5489}
5490
5491static int
5492bnx2_resume(struct pci_dev *pdev)
5493{
5494 struct net_device *dev = pci_get_drvdata(pdev);
5495 struct bnx2 *bp = dev->priv;
5496
5497 if (!netif_running(dev))
5498 return 0;
5499
5500 bnx2_set_power_state(bp, 0);
5501 netif_device_attach(dev);
5502 bnx2_init_nic(bp);
5503 bnx2_netif_start(bp);
5504 return 0;
5505}
5506
5507static struct pci_driver bnx2_pci_driver = {
5508 name: DRV_MODULE_NAME,
5509 id_table: bnx2_pci_tbl,
5510 probe: bnx2_init_one,
5511 remove: __devexit_p(bnx2_remove_one),
5512 suspend: bnx2_suspend,
5513 resume: bnx2_resume,
5514};
5515
5516static int __init bnx2_init(void)
5517{
5518 return pci_module_init(&bnx2_pci_driver);
5519}
5520
5521static void __exit bnx2_cleanup(void)
5522{
5523 pci_unregister_driver(&bnx2_pci_driver);
5524}
5525
5526module_init(bnx2_init);
5527module_exit(bnx2_cleanup);
5528
5529
5530
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
new file mode 100644
index 000000000000..8214a2853d0d
--- /dev/null
+++ b/drivers/net/bnx2.h
@@ -0,0 +1,4352 @@
1/* bnx2.h: Broadcom NX2 network driver.
2 *
3 * Copyright (c) 2004, 2005 Broadcom 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.
8 *
9 * Written by: Michael Chan (mchan@broadcom.com)
10 */
11
12
13#ifndef BNX2_H
14#define BNX2_H
15
16#include <linux/config.h>
17
18#include <linux/module.h>
19#include <linux/moduleparam.h>
20
21#include <linux/kernel.h>
22#include <linux/timer.h>
23#include <linux/errno.h>
24#include <linux/ioport.h>
25#include <linux/slab.h>
26#include <linux/interrupt.h>
27#include <linux/pci.h>
28#include <linux/init.h>
29#include <linux/netdevice.h>
30#include <linux/etherdevice.h>
31#include <linux/skbuff.h>
32#include <linux/dma-mapping.h>
33#include <asm/bitops.h>
34#include <asm/io.h>
35#include <asm/irq.h>
36#include <linux/delay.h>
37#include <asm/byteorder.h>
38#include <linux/time.h>
39#include <linux/ethtool.h>
40#include <linux/mii.h>
41#ifdef NETIF_F_HW_VLAN_TX
42#include <linux/if_vlan.h>
43#define BCM_VLAN 1
44#endif
45#ifdef NETIF_F_TSO
46#include <net/ip.h>
47#include <net/tcp.h>
48#include <net/checksum.h>
49#define BCM_TSO 1
50#endif
51#include <linux/workqueue.h>
52#include <linux/crc32.h>
53
54/* Hardware data structures and register definitions automatically
55 * generated from RTL code. Do not modify.
56 */
57
58/*
59 * tx_bd definition
60 */
61struct tx_bd {
62 u32 tx_bd_haddr_hi;
63 u32 tx_bd_haddr_lo;
64 u32 tx_bd_mss_nbytes;
65 u32 tx_bd_vlan_tag_flags;
66 #define TX_BD_FLAGS_CONN_FAULT (1<<0)
67 #define TX_BD_FLAGS_TCP_UDP_CKSUM (1<<1)
68 #define TX_BD_FLAGS_IP_CKSUM (1<<2)
69 #define TX_BD_FLAGS_VLAN_TAG (1<<3)
70 #define TX_BD_FLAGS_COAL_NOW (1<<4)
71 #define TX_BD_FLAGS_DONT_GEN_CRC (1<<5)
72 #define TX_BD_FLAGS_END (1<<6)
73 #define TX_BD_FLAGS_START (1<<7)
74 #define TX_BD_FLAGS_SW_OPTION_WORD (0x1f<<8)
75 #define TX_BD_FLAGS_SW_FLAGS (1<<13)
76 #define TX_BD_FLAGS_SW_SNAP (1<<14)
77 #define TX_BD_FLAGS_SW_LSO (1<<15)
78
79};
80
81
82/*
83 * rx_bd definition
84 */
85struct rx_bd {
86 u32 rx_bd_haddr_hi;
87 u32 rx_bd_haddr_lo;
88 u32 rx_bd_len;
89 u32 rx_bd_flags;
90 #define RX_BD_FLAGS_NOPUSH (1<<0)
91 #define RX_BD_FLAGS_DUMMY (1<<1)
92 #define RX_BD_FLAGS_END (1<<2)
93 #define RX_BD_FLAGS_START (1<<3)
94
95};
96
97
98/*
99 * status_block definition
100 */
101struct status_block {
102 u32 status_attn_bits;
103 #define STATUS_ATTN_BITS_LINK_STATE (1L<<0)
104 #define STATUS_ATTN_BITS_TX_SCHEDULER_ABORT (1L<<1)
105 #define STATUS_ATTN_BITS_TX_BD_READ_ABORT (1L<<2)
106 #define STATUS_ATTN_BITS_TX_BD_CACHE_ABORT (1L<<3)
107 #define STATUS_ATTN_BITS_TX_PROCESSOR_ABORT (1L<<4)
108 #define STATUS_ATTN_BITS_TX_DMA_ABORT (1L<<5)
109 #define STATUS_ATTN_BITS_TX_PATCHUP_ABORT (1L<<6)
110 #define STATUS_ATTN_BITS_TX_ASSEMBLER_ABORT (1L<<7)
111 #define STATUS_ATTN_BITS_RX_PARSER_MAC_ABORT (1L<<8)
112 #define STATUS_ATTN_BITS_RX_PARSER_CATCHUP_ABORT (1L<<9)
113 #define STATUS_ATTN_BITS_RX_MBUF_ABORT (1L<<10)
114 #define STATUS_ATTN_BITS_RX_LOOKUP_ABORT (1L<<11)
115 #define STATUS_ATTN_BITS_RX_PROCESSOR_ABORT (1L<<12)
116 #define STATUS_ATTN_BITS_RX_V2P_ABORT (1L<<13)
117 #define STATUS_ATTN_BITS_RX_BD_CACHE_ABORT (1L<<14)
118 #define STATUS_ATTN_BITS_RX_DMA_ABORT (1L<<15)
119 #define STATUS_ATTN_BITS_COMPLETION_ABORT (1L<<16)
120 #define STATUS_ATTN_BITS_HOST_COALESCE_ABORT (1L<<17)
121 #define STATUS_ATTN_BITS_MAILBOX_QUEUE_ABORT (1L<<18)
122 #define STATUS_ATTN_BITS_CONTEXT_ABORT (1L<<19)
123 #define STATUS_ATTN_BITS_CMD_SCHEDULER_ABORT (1L<<20)
124 #define STATUS_ATTN_BITS_CMD_PROCESSOR_ABORT (1L<<21)
125 #define STATUS_ATTN_BITS_MGMT_PROCESSOR_ABORT (1L<<22)
126 #define STATUS_ATTN_BITS_MAC_ABORT (1L<<23)
127 #define STATUS_ATTN_BITS_TIMER_ABORT (1L<<24)
128 #define STATUS_ATTN_BITS_DMAE_ABORT (1L<<25)
129 #define STATUS_ATTN_BITS_FLSH_ABORT (1L<<26)
130 #define STATUS_ATTN_BITS_GRC_ABORT (1L<<27)
131 #define STATUS_ATTN_BITS_PARITY_ERROR (1L<<31)
132
133 u32 status_attn_bits_ack;
134#if defined(__BIG_ENDIAN)
135 u16 status_tx_quick_consumer_index0;
136 u16 status_tx_quick_consumer_index1;
137 u16 status_tx_quick_consumer_index2;
138 u16 status_tx_quick_consumer_index3;
139 u16 status_rx_quick_consumer_index0;
140 u16 status_rx_quick_consumer_index1;
141 u16 status_rx_quick_consumer_index2;
142 u16 status_rx_quick_consumer_index3;
143 u16 status_rx_quick_consumer_index4;
144 u16 status_rx_quick_consumer_index5;
145 u16 status_rx_quick_consumer_index6;
146 u16 status_rx_quick_consumer_index7;
147 u16 status_rx_quick_consumer_index8;
148 u16 status_rx_quick_consumer_index9;
149 u16 status_rx_quick_consumer_index10;
150 u16 status_rx_quick_consumer_index11;
151 u16 status_rx_quick_consumer_index12;
152 u16 status_rx_quick_consumer_index13;
153 u16 status_rx_quick_consumer_index14;
154 u16 status_rx_quick_consumer_index15;
155 u16 status_completion_producer_index;
156 u16 status_cmd_consumer_index;
157 u16 status_idx;
158 u16 status_unused;
159#elif defined(__LITTLE_ENDIAN)
160 u16 status_tx_quick_consumer_index1;
161 u16 status_tx_quick_consumer_index0;
162 u16 status_tx_quick_consumer_index3;
163 u16 status_tx_quick_consumer_index2;
164 u16 status_rx_quick_consumer_index1;
165 u16 status_rx_quick_consumer_index0;
166 u16 status_rx_quick_consumer_index3;
167 u16 status_rx_quick_consumer_index2;
168 u16 status_rx_quick_consumer_index5;
169 u16 status_rx_quick_consumer_index4;
170 u16 status_rx_quick_consumer_index7;
171 u16 status_rx_quick_consumer_index6;
172 u16 status_rx_quick_consumer_index9;
173 u16 status_rx_quick_consumer_index8;
174 u16 status_rx_quick_consumer_index11;
175 u16 status_rx_quick_consumer_index10;
176 u16 status_rx_quick_consumer_index13;
177 u16 status_rx_quick_consumer_index12;
178 u16 status_rx_quick_consumer_index15;
179 u16 status_rx_quick_consumer_index14;
180 u16 status_cmd_consumer_index;
181 u16 status_completion_producer_index;
182 u16 status_unused;
183 u16 status_idx;
184#endif
185};
186
187
188/*
189 * statistics_block definition
190 */
191struct statistics_block {
192 u32 stat_IfHCInOctets_hi;
193 u32 stat_IfHCInOctets_lo;
194 u32 stat_IfHCInBadOctets_hi;
195 u32 stat_IfHCInBadOctets_lo;
196 u32 stat_IfHCOutOctets_hi;
197 u32 stat_IfHCOutOctets_lo;
198 u32 stat_IfHCOutBadOctets_hi;
199 u32 stat_IfHCOutBadOctets_lo;
200 u32 stat_IfHCInUcastPkts_hi;
201 u32 stat_IfHCInUcastPkts_lo;
202 u32 stat_IfHCInMulticastPkts_hi;
203 u32 stat_IfHCInMulticastPkts_lo;
204 u32 stat_IfHCInBroadcastPkts_hi;
205 u32 stat_IfHCInBroadcastPkts_lo;
206 u32 stat_IfHCOutUcastPkts_hi;
207 u32 stat_IfHCOutUcastPkts_lo;
208 u32 stat_IfHCOutMulticastPkts_hi;
209 u32 stat_IfHCOutMulticastPkts_lo;
210 u32 stat_IfHCOutBroadcastPkts_hi;
211 u32 stat_IfHCOutBroadcastPkts_lo;
212 u32 stat_emac_tx_stat_dot3statsinternalmactransmiterrors;
213 u32 stat_Dot3StatsCarrierSenseErrors;
214 u32 stat_Dot3StatsFCSErrors;
215 u32 stat_Dot3StatsAlignmentErrors;
216 u32 stat_Dot3StatsSingleCollisionFrames;
217 u32 stat_Dot3StatsMultipleCollisionFrames;
218 u32 stat_Dot3StatsDeferredTransmissions;
219 u32 stat_Dot3StatsExcessiveCollisions;
220 u32 stat_Dot3StatsLateCollisions;
221 u32 stat_EtherStatsCollisions;
222 u32 stat_EtherStatsFragments;
223 u32 stat_EtherStatsJabbers;
224 u32 stat_EtherStatsUndersizePkts;
225 u32 stat_EtherStatsOverrsizePkts;
226 u32 stat_EtherStatsPktsRx64Octets;
227 u32 stat_EtherStatsPktsRx65Octetsto127Octets;
228 u32 stat_EtherStatsPktsRx128Octetsto255Octets;
229 u32 stat_EtherStatsPktsRx256Octetsto511Octets;
230 u32 stat_EtherStatsPktsRx512Octetsto1023Octets;
231 u32 stat_EtherStatsPktsRx1024Octetsto1522Octets;
232 u32 stat_EtherStatsPktsRx1523Octetsto9022Octets;
233 u32 stat_EtherStatsPktsTx64Octets;
234 u32 stat_EtherStatsPktsTx65Octetsto127Octets;
235 u32 stat_EtherStatsPktsTx128Octetsto255Octets;
236 u32 stat_EtherStatsPktsTx256Octetsto511Octets;
237 u32 stat_EtherStatsPktsTx512Octetsto1023Octets;
238 u32 stat_EtherStatsPktsTx1024Octetsto1522Octets;
239 u32 stat_EtherStatsPktsTx1523Octetsto9022Octets;
240 u32 stat_XonPauseFramesReceived;
241 u32 stat_XoffPauseFramesReceived;
242 u32 stat_OutXonSent;
243 u32 stat_OutXoffSent;
244 u32 stat_FlowControlDone;
245 u32 stat_MacControlFramesReceived;
246 u32 stat_XoffStateEntered;
247 u32 stat_IfInFramesL2FilterDiscards;
248 u32 stat_IfInRuleCheckerDiscards;
249 u32 stat_IfInFTQDiscards;
250 u32 stat_IfInMBUFDiscards;
251 u32 stat_IfInRuleCheckerP4Hit;
252 u32 stat_CatchupInRuleCheckerDiscards;
253 u32 stat_CatchupInFTQDiscards;
254 u32 stat_CatchupInMBUFDiscards;
255 u32 stat_CatchupInRuleCheckerP4Hit;
256 u32 stat_GenStat00;
257 u32 stat_GenStat01;
258 u32 stat_GenStat02;
259 u32 stat_GenStat03;
260 u32 stat_GenStat04;
261 u32 stat_GenStat05;
262 u32 stat_GenStat06;
263 u32 stat_GenStat07;
264 u32 stat_GenStat08;
265 u32 stat_GenStat09;
266 u32 stat_GenStat10;
267 u32 stat_GenStat11;
268 u32 stat_GenStat12;
269 u32 stat_GenStat13;
270 u32 stat_GenStat14;
271 u32 stat_GenStat15;
272};
273
274
275/*
276 * l2_fhdr definition
277 */
278struct l2_fhdr {
279#if defined(__BIG_ENDIAN)
280 u16 l2_fhdr_errors;
281 u16 l2_fhdr_status;
282#elif defined(__LITTLE_ENDIAN)
283 u16 l2_fhdr_status;
284 u16 l2_fhdr_errors;
285#endif
286 #define L2_FHDR_ERRORS_BAD_CRC (1<<1)
287 #define L2_FHDR_ERRORS_PHY_DECODE (1<<2)
288 #define L2_FHDR_ERRORS_ALIGNMENT (1<<3)
289 #define L2_FHDR_ERRORS_TOO_SHORT (1<<4)
290 #define L2_FHDR_ERRORS_GIANT_FRAME (1<<5)
291
292 #define L2_FHDR_STATUS_RULE_CLASS (0x7<<0)
293 #define L2_FHDR_STATUS_RULE_P2 (1<<3)
294 #define L2_FHDR_STATUS_RULE_P3 (1<<4)
295 #define L2_FHDR_STATUS_RULE_P4 (1<<5)
296 #define L2_FHDR_STATUS_L2_VLAN_TAG (1<<6)
297 #define L2_FHDR_STATUS_L2_LLC_SNAP (1<<7)
298 #define L2_FHDR_STATUS_RSS_HASH (1<<8)
299 #define L2_FHDR_STATUS_IP_DATAGRAM (1<<13)
300 #define L2_FHDR_STATUS_TCP_SEGMENT (1<<14)
301 #define L2_FHDR_STATUS_UDP_DATAGRAM (1<<15)
302
303 u32 l2_fhdr_hash;
304#if defined(__BIG_ENDIAN)
305 u16 l2_fhdr_pkt_len;
306 u16 l2_fhdr_vlan_tag;
307 u16 l2_fhdr_ip_xsum;
308 u16 l2_fhdr_tcp_udp_xsum;
309#elif defined(__LITTLE_ENDIAN)
310 u16 l2_fhdr_vlan_tag;
311 u16 l2_fhdr_pkt_len;
312 u16 l2_fhdr_tcp_udp_xsum;
313 u16 l2_fhdr_ip_xsum;
314#endif
315};
316
317
318/*
319 * l2_context definition
320 */
321#define BNX2_L2CTX_TYPE 0x00000000
322#define BNX2_L2CTX_TYPE_SIZE_L2 ((0xc0/0x20)<<16)
323#define BNX2_L2CTX_TYPE_TYPE (0xf<<28)
324#define BNX2_L2CTX_TYPE_TYPE_EMPTY (0<<28)
325#define BNX2_L2CTX_TYPE_TYPE_L2 (1<<28)
326
327#define BNX2_L2CTX_TX_HOST_BIDX 0x00000088
328#define BNX2_L2CTX_EST_NBD 0x00000088
329#define BNX2_L2CTX_CMD_TYPE 0x00000088
330#define BNX2_L2CTX_CMD_TYPE_TYPE (0xf<<24)
331#define BNX2_L2CTX_CMD_TYPE_TYPE_L2 (0<<24)
332#define BNX2_L2CTX_CMD_TYPE_TYPE_TCP (1<<24)
333
334#define BNX2_L2CTX_TX_HOST_BSEQ 0x00000090
335#define BNX2_L2CTX_TSCH_BSEQ 0x00000094
336#define BNX2_L2CTX_TBDR_BSEQ 0x00000098
337#define BNX2_L2CTX_TBDR_BOFF 0x0000009c
338#define BNX2_L2CTX_TBDR_BIDX 0x0000009c
339#define BNX2_L2CTX_TBDR_BHADDR_HI 0x000000a0
340#define BNX2_L2CTX_TBDR_BHADDR_LO 0x000000a4
341#define BNX2_L2CTX_TXP_BOFF 0x000000a8
342#define BNX2_L2CTX_TXP_BIDX 0x000000a8
343#define BNX2_L2CTX_TXP_BSEQ 0x000000ac
344
345
346/*
347 * l2_bd_chain_context definition
348 */
349#define BNX2_L2CTX_BD_PRE_READ 0x00000000
350#define BNX2_L2CTX_CTX_SIZE 0x00000000
351#define BNX2_L2CTX_CTX_TYPE 0x00000000
352#define BNX2_L2CTX_CTX_TYPE_SIZE_L2 ((0x20/20)<<16)
353#define BNX2_L2CTX_CTX_TYPE_CTX_BD_CHN_TYPE (0xf<<28)
354#define BNX2_L2CTX_CTX_TYPE_CTX_BD_CHN_TYPE_UNDEFINED (0<<28)
355#define BNX2_L2CTX_CTX_TYPE_CTX_BD_CHN_TYPE_VALUE (1<<28)
356
357#define BNX2_L2CTX_HOST_BDIDX 0x00000004
358#define BNX2_L2CTX_HOST_BSEQ 0x00000008
359#define BNX2_L2CTX_NX_BSEQ 0x0000000c
360#define BNX2_L2CTX_NX_BDHADDR_HI 0x00000010
361#define BNX2_L2CTX_NX_BDHADDR_LO 0x00000014
362#define BNX2_L2CTX_NX_BDIDX 0x00000018
363
364
365/*
366 * pci_config_l definition
367 * offset: 0000
368 */
369#define BNX2_PCICFG_MISC_CONFIG 0x00000068
370#define BNX2_PCICFG_MISC_CONFIG_TARGET_BYTE_SWAP (1L<<2)
371#define BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP (1L<<3)
372#define BNX2_PCICFG_MISC_CONFIG_CLOCK_CTL_ENA (1L<<5)
373#define BNX2_PCICFG_MISC_CONFIG_TARGET_GRC_WORD_SWAP (1L<<6)
374#define BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA (1L<<7)
375#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ (1L<<8)
376#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY (1L<<9)
377#define BNX2_PCICFG_MISC_CONFIG_ASIC_METAL_REV (0xffL<<16)
378#define BNX2_PCICFG_MISC_CONFIG_ASIC_BASE_REV (0xfL<<24)
379#define BNX2_PCICFG_MISC_CONFIG_ASIC_ID (0xfL<<28)
380
381#define BNX2_PCICFG_MISC_STATUS 0x0000006c
382#define BNX2_PCICFG_MISC_STATUS_INTA_VALUE (1L<<0)
383#define BNX2_PCICFG_MISC_STATUS_32BIT_DET (1L<<1)
384#define BNX2_PCICFG_MISC_STATUS_M66EN (1L<<2)
385#define BNX2_PCICFG_MISC_STATUS_PCIX_DET (1L<<3)
386#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED (0x3L<<4)
387#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_66 (0L<<4)
388#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_100 (1L<<4)
389#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_133 (2L<<4)
390#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_PCI_MODE (3L<<4)
391
392#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS 0x00000070
393#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET (0xfL<<0)
394#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_32MHZ (0L<<0)
395#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_38MHZ (1L<<0)
396#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_48MHZ (2L<<0)
397#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_55MHZ (3L<<0)
398#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_66MHZ (4L<<0)
399#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_80MHZ (5L<<0)
400#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_95MHZ (6L<<0)
401#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_133MHZ (7L<<0)
402#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_LOW (0xfL<<0)
403#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_DISABLE (1L<<6)
404#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT (1L<<7)
405#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC (0x7L<<8)
406#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_UNDEF (0L<<8)
407#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_12 (1L<<8)
408#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_6 (2L<<8)
409#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_62 (4L<<8)
410#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PLAY_DEAD (1L<<11)
411#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED (0xfL<<12)
412#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_100 (0L<<12)
413#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_80 (1L<<12)
414#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_50 (2L<<12)
415#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_40 (4L<<12)
416#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_25 (8L<<12)
417#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_STOP (1L<<16)
418#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_PLL_STOP (1L<<17)
419#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED_18 (1L<<18)
420#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_USE_SPD_DET (1L<<19)
421#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED (0xfffL<<20)
422
423#define BNX2_PCICFG_REG_WINDOW_ADDRESS 0x00000078
424#define BNX2_PCICFG_REG_WINDOW 0x00000080
425#define BNX2_PCICFG_INT_ACK_CMD 0x00000084
426#define BNX2_PCICFG_INT_ACK_CMD_INDEX (0xffffL<<0)
427#define BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID (1L<<16)
428#define BNX2_PCICFG_INT_ACK_CMD_USE_INT_HC_PARAM (1L<<17)
429#define BNX2_PCICFG_INT_ACK_CMD_MASK_INT (1L<<18)
430
431#define BNX2_PCICFG_STATUS_BIT_SET_CMD 0x00000088
432#define BNX2_PCICFG_STATUS_BIT_CLEAR_CMD 0x0000008c
433#define BNX2_PCICFG_MAILBOX_QUEUE_ADDR 0x00000090
434#define BNX2_PCICFG_MAILBOX_QUEUE_DATA 0x00000094
435
436
437/*
438 * pci_reg definition
439 * offset: 0x400
440 */
441#define BNX2_PCI_GRC_WINDOW_ADDR 0x00000400
442#define BNX2_PCI_GRC_WINDOW_ADDR_PCI_GRC_WINDOW_ADDR_VALUE (0x3ffffL<<8)
443
444#define BNX2_PCI_CONFIG_1 0x00000404
445#define BNX2_PCI_CONFIG_1_READ_BOUNDARY (0x7L<<8)
446#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_OFF (0L<<8)
447#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_16 (1L<<8)
448#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_32 (2L<<8)
449#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_64 (3L<<8)
450#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_128 (4L<<8)
451#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_256 (5L<<8)
452#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_512 (6L<<8)
453#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_1024 (7L<<8)
454#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY (0x7L<<11)
455#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_OFF (0L<<11)
456#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_16 (1L<<11)
457#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_32 (2L<<11)
458#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_64 (3L<<11)
459#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_128 (4L<<11)
460#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_256 (5L<<11)
461#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_512 (6L<<11)
462#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_1024 (7L<<11)
463
464#define BNX2_PCI_CONFIG_2 0x00000408
465#define BNX2_PCI_CONFIG_2_BAR1_SIZE (0xfL<<0)
466#define BNX2_PCI_CONFIG_2_BAR1_SIZE_DISABLED (0L<<0)
467#define BNX2_PCI_CONFIG_2_BAR1_SIZE_64K (1L<<0)
468#define BNX2_PCI_CONFIG_2_BAR1_SIZE_128K (2L<<0)
469#define BNX2_PCI_CONFIG_2_BAR1_SIZE_256K (3L<<0)
470#define BNX2_PCI_CONFIG_2_BAR1_SIZE_512K (4L<<0)
471#define BNX2_PCI_CONFIG_2_BAR1_SIZE_1M (5L<<0)
472#define BNX2_PCI_CONFIG_2_BAR1_SIZE_2M (6L<<0)
473#define BNX2_PCI_CONFIG_2_BAR1_SIZE_4M (7L<<0)
474#define BNX2_PCI_CONFIG_2_BAR1_SIZE_8M (8L<<0)
475#define BNX2_PCI_CONFIG_2_BAR1_SIZE_16M (9L<<0)
476#define BNX2_PCI_CONFIG_2_BAR1_SIZE_32M (10L<<0)
477#define BNX2_PCI_CONFIG_2_BAR1_SIZE_64M (11L<<0)
478#define BNX2_PCI_CONFIG_2_BAR1_SIZE_128M (12L<<0)
479#define BNX2_PCI_CONFIG_2_BAR1_SIZE_256M (13L<<0)
480#define BNX2_PCI_CONFIG_2_BAR1_SIZE_512M (14L<<0)
481#define BNX2_PCI_CONFIG_2_BAR1_SIZE_1G (15L<<0)
482#define BNX2_PCI_CONFIG_2_BAR1_64ENA (1L<<4)
483#define BNX2_PCI_CONFIG_2_EXP_ROM_RETRY (1L<<5)
484#define BNX2_PCI_CONFIG_2_CFG_CYCLE_RETRY (1L<<6)
485#define BNX2_PCI_CONFIG_2_FIRST_CFG_DONE (1L<<7)
486#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE (0xffL<<8)
487#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_DISABLED (0L<<8)
488#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_1K (1L<<8)
489#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_2K (2L<<8)
490#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_4K (3L<<8)
491#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_8K (4L<<8)
492#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_16K (5L<<8)
493#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_32K (6L<<8)
494#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_64K (7L<<8)
495#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_128K (8L<<8)
496#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_256K (9L<<8)
497#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_512K (10L<<8)
498#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_1M (11L<<8)
499#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_2M (12L<<8)
500#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_4M (13L<<8)
501#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_8M (14L<<8)
502#define BNX2_PCI_CONFIG_2_EXP_ROM_SIZE_16M (15L<<8)
503#define BNX2_PCI_CONFIG_2_MAX_SPLIT_LIMIT (0x1fL<<16)
504#define BNX2_PCI_CONFIG_2_MAX_READ_LIMIT (0x3L<<21)
505#define BNX2_PCI_CONFIG_2_MAX_READ_LIMIT_512 (0L<<21)
506#define BNX2_PCI_CONFIG_2_MAX_READ_LIMIT_1K (1L<<21)
507#define BNX2_PCI_CONFIG_2_MAX_READ_LIMIT_2K (2L<<21)
508#define BNX2_PCI_CONFIG_2_MAX_READ_LIMIT_4K (3L<<21)
509#define BNX2_PCI_CONFIG_2_FORCE_32_BIT_MSTR (1L<<23)
510#define BNX2_PCI_CONFIG_2_FORCE_32_BIT_TGT (1L<<24)
511#define BNX2_PCI_CONFIG_2_KEEP_REQ_ASSERT (1L<<25)
512
513#define BNX2_PCI_CONFIG_3 0x0000040c
514#define BNX2_PCI_CONFIG_3_STICKY_BYTE (0xffL<<0)
515#define BNX2_PCI_CONFIG_3_FORCE_PME (1L<<24)
516#define BNX2_PCI_CONFIG_3_PME_STATUS (1L<<25)
517#define BNX2_PCI_CONFIG_3_PME_ENABLE (1L<<26)
518#define BNX2_PCI_CONFIG_3_PM_STATE (0x3L<<27)
519#define BNX2_PCI_CONFIG_3_VAUX_PRESET (1L<<30)
520#define BNX2_PCI_CONFIG_3_PCI_POWER (1L<<31)
521
522#define BNX2_PCI_PM_DATA_A 0x00000410
523#define BNX2_PCI_PM_DATA_A_PM_DATA_0_PRG (0xffL<<0)
524#define BNX2_PCI_PM_DATA_A_PM_DATA_1_PRG (0xffL<<8)
525#define BNX2_PCI_PM_DATA_A_PM_DATA_2_PRG (0xffL<<16)
526#define BNX2_PCI_PM_DATA_A_PM_DATA_3_PRG (0xffL<<24)
527
528#define BNX2_PCI_PM_DATA_B 0x00000414
529#define BNX2_PCI_PM_DATA_B_PM_DATA_4_PRG (0xffL<<0)
530#define BNX2_PCI_PM_DATA_B_PM_DATA_5_PRG (0xffL<<8)
531#define BNX2_PCI_PM_DATA_B_PM_DATA_6_PRG (0xffL<<16)
532#define BNX2_PCI_PM_DATA_B_PM_DATA_7_PRG (0xffL<<24)
533
534#define BNX2_PCI_SWAP_DIAG0 0x00000418
535#define BNX2_PCI_SWAP_DIAG1 0x0000041c
536#define BNX2_PCI_EXP_ROM_ADDR 0x00000420
537#define BNX2_PCI_EXP_ROM_ADDR_ADDRESS (0x3fffffL<<2)
538#define BNX2_PCI_EXP_ROM_ADDR_REQ (1L<<31)
539
540#define BNX2_PCI_EXP_ROM_DATA 0x00000424
541#define BNX2_PCI_VPD_INTF 0x00000428
542#define BNX2_PCI_VPD_INTF_INTF_REQ (1L<<0)
543
544#define BNX2_PCI_VPD_ADDR_FLAG 0x0000042c
545#define BNX2_PCI_VPD_ADDR_FLAG_ADDRESS (0x1fff<<2)
546#define BNX2_PCI_VPD_ADDR_FLAG_WR (1<<15)
547
548#define BNX2_PCI_VPD_DATA 0x00000430
549#define BNX2_PCI_ID_VAL1 0x00000434
550#define BNX2_PCI_ID_VAL1_DEVICE_ID (0xffffL<<0)
551#define BNX2_PCI_ID_VAL1_VENDOR_ID (0xffffL<<16)
552
553#define BNX2_PCI_ID_VAL2 0x00000438
554#define BNX2_PCI_ID_VAL2_SUBSYSTEM_VENDOR_ID (0xffffL<<0)
555#define BNX2_PCI_ID_VAL2_SUBSYSTEM_ID (0xffffL<<16)
556
557#define BNX2_PCI_ID_VAL3 0x0000043c
558#define BNX2_PCI_ID_VAL3_CLASS_CODE (0xffffffL<<0)
559#define BNX2_PCI_ID_VAL3_REVISION_ID (0xffL<<24)
560
561#define BNX2_PCI_ID_VAL4 0x00000440
562#define BNX2_PCI_ID_VAL4_CAP_ENA (0xfL<<0)
563#define BNX2_PCI_ID_VAL4_CAP_ENA_0 (0L<<0)
564#define BNX2_PCI_ID_VAL4_CAP_ENA_1 (1L<<0)
565#define BNX2_PCI_ID_VAL4_CAP_ENA_2 (2L<<0)
566#define BNX2_PCI_ID_VAL4_CAP_ENA_3 (3L<<0)
567#define BNX2_PCI_ID_VAL4_CAP_ENA_4 (4L<<0)
568#define BNX2_PCI_ID_VAL4_CAP_ENA_5 (5L<<0)
569#define BNX2_PCI_ID_VAL4_CAP_ENA_6 (6L<<0)
570#define BNX2_PCI_ID_VAL4_CAP_ENA_7 (7L<<0)
571#define BNX2_PCI_ID_VAL4_CAP_ENA_8 (8L<<0)
572#define BNX2_PCI_ID_VAL4_CAP_ENA_9 (9L<<0)
573#define BNX2_PCI_ID_VAL4_CAP_ENA_10 (10L<<0)
574#define BNX2_PCI_ID_VAL4_CAP_ENA_11 (11L<<0)
575#define BNX2_PCI_ID_VAL4_CAP_ENA_12 (12L<<0)
576#define BNX2_PCI_ID_VAL4_CAP_ENA_13 (13L<<0)
577#define BNX2_PCI_ID_VAL4_CAP_ENA_14 (14L<<0)
578#define BNX2_PCI_ID_VAL4_CAP_ENA_15 (15L<<0)
579#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG (0x3L<<6)
580#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_0 (0L<<6)
581#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_1 (1L<<6)
582#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_2 (2L<<6)
583#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_3 (3L<<6)
584#define BNX2_PCI_ID_VAL4_MSI_LIMIT (0x7L<<9)
585#define BNX2_PCI_ID_VAL4_MSI_ADVERTIZE (0x7L<<12)
586#define BNX2_PCI_ID_VAL4_MSI_ENABLE (1L<<15)
587#define BNX2_PCI_ID_VAL4_MAX_64_ADVERTIZE (1L<<16)
588#define BNX2_PCI_ID_VAL4_MAX_133_ADVERTIZE (1L<<17)
589#define BNX2_PCI_ID_VAL4_MAX_MEM_READ_SIZE (0x3L<<21)
590#define BNX2_PCI_ID_VAL4_MAX_SPLIT_SIZE (0x7L<<23)
591#define BNX2_PCI_ID_VAL4_MAX_CUMULATIVE_SIZE (0x7L<<26)
592
593#define BNX2_PCI_ID_VAL5 0x00000444
594#define BNX2_PCI_ID_VAL5_D1_SUPPORT (1L<<0)
595#define BNX2_PCI_ID_VAL5_D2_SUPPORT (1L<<1)
596#define BNX2_PCI_ID_VAL5_PME_IN_D0 (1L<<2)
597#define BNX2_PCI_ID_VAL5_PME_IN_D1 (1L<<3)
598#define BNX2_PCI_ID_VAL5_PME_IN_D2 (1L<<4)
599#define BNX2_PCI_ID_VAL5_PME_IN_D3_HOT (1L<<5)
600
601#define BNX2_PCI_PCIX_EXTENDED_STATUS 0x00000448
602#define BNX2_PCI_PCIX_EXTENDED_STATUS_NO_SNOOP (1L<<8)
603#define BNX2_PCI_PCIX_EXTENDED_STATUS_LONG_BURST (1L<<9)
604#define BNX2_PCI_PCIX_EXTENDED_STATUS_SPLIT_COMP_MSG_CLASS (0xfL<<16)
605#define BNX2_PCI_PCIX_EXTENDED_STATUS_SPLIT_COMP_MSG_IDX (0xffL<<24)
606
607#define BNX2_PCI_ID_VAL6 0x0000044c
608#define BNX2_PCI_ID_VAL6_MAX_LAT (0xffL<<0)
609#define BNX2_PCI_ID_VAL6_MIN_GNT (0xffL<<8)
610#define BNX2_PCI_ID_VAL6_BIST (0xffL<<16)
611
612#define BNX2_PCI_MSI_DATA 0x00000450
613#define BNX2_PCI_MSI_DATA_PCI_MSI_DATA (0xffffL<<0)
614
615#define BNX2_PCI_MSI_ADDR_H 0x00000454
616#define BNX2_PCI_MSI_ADDR_L 0x00000458
617
618
619/*
620 * misc_reg definition
621 * offset: 0x800
622 */
623#define BNX2_MISC_COMMAND 0x00000800
624#define BNX2_MISC_COMMAND_ENABLE_ALL (1L<<0)
625#define BNX2_MISC_COMMAND_DISABLE_ALL (1L<<1)
626#define BNX2_MISC_COMMAND_CORE_RESET (1L<<4)
627#define BNX2_MISC_COMMAND_HARD_RESET (1L<<5)
628#define BNX2_MISC_COMMAND_PAR_ERROR (1L<<8)
629#define BNX2_MISC_COMMAND_PAR_ERR_RAM (0x7fL<<16)
630
631#define BNX2_MISC_CFG 0x00000804
632#define BNX2_MISC_CFG_PCI_GRC_TMOUT (1L<<0)
633#define BNX2_MISC_CFG_NVM_WR_EN (0x3L<<1)
634#define BNX2_MISC_CFG_NVM_WR_EN_PROTECT (0L<<1)
635#define BNX2_MISC_CFG_NVM_WR_EN_PCI (1L<<1)
636#define BNX2_MISC_CFG_NVM_WR_EN_ALLOW (2L<<1)
637#define BNX2_MISC_CFG_NVM_WR_EN_ALLOW2 (3L<<1)
638#define BNX2_MISC_CFG_BIST_EN (1L<<3)
639#define BNX2_MISC_CFG_CK25_OUT_ALT_SRC (1L<<4)
640#define BNX2_MISC_CFG_BYPASS_BSCAN (1L<<5)
641#define BNX2_MISC_CFG_BYPASS_EJTAG (1L<<6)
642#define BNX2_MISC_CFG_CLK_CTL_OVERRIDE (1L<<7)
643#define BNX2_MISC_CFG_LEDMODE (0x3L<<8)
644#define BNX2_MISC_CFG_LEDMODE_MAC (0L<<8)
645#define BNX2_MISC_CFG_LEDMODE_GPHY1 (1L<<8)
646#define BNX2_MISC_CFG_LEDMODE_GPHY2 (2L<<8)
647
648#define BNX2_MISC_ID 0x00000808
649#define BNX2_MISC_ID_BOND_ID (0xfL<<0)
650#define BNX2_MISC_ID_CHIP_METAL (0xffL<<4)
651#define BNX2_MISC_ID_CHIP_REV (0xfL<<12)
652#define BNX2_MISC_ID_CHIP_NUM (0xffffL<<16)
653
654#define BNX2_MISC_ENABLE_STATUS_BITS 0x0000080c
655#define BNX2_MISC_ENABLE_STATUS_BITS_TX_SCHEDULER_ENABLE (1L<<0)
656#define BNX2_MISC_ENABLE_STATUS_BITS_TX_BD_READ_ENABLE (1L<<1)
657#define BNX2_MISC_ENABLE_STATUS_BITS_TX_BD_CACHE_ENABLE (1L<<2)
658#define BNX2_MISC_ENABLE_STATUS_BITS_TX_PROCESSOR_ENABLE (1L<<3)
659#define BNX2_MISC_ENABLE_STATUS_BITS_TX_DMA_ENABLE (1L<<4)
660#define BNX2_MISC_ENABLE_STATUS_BITS_TX_PATCHUP_ENABLE (1L<<5)
661#define BNX2_MISC_ENABLE_STATUS_BITS_TX_PAYLOAD_Q_ENABLE (1L<<6)
662#define BNX2_MISC_ENABLE_STATUS_BITS_TX_HEADER_Q_ENABLE (1L<<7)
663#define BNX2_MISC_ENABLE_STATUS_BITS_TX_ASSEMBLER_ENABLE (1L<<8)
664#define BNX2_MISC_ENABLE_STATUS_BITS_EMAC_ENABLE (1L<<9)
665#define BNX2_MISC_ENABLE_STATUS_BITS_RX_PARSER_MAC_ENABLE (1L<<10)
666#define BNX2_MISC_ENABLE_STATUS_BITS_RX_PARSER_CATCHUP_ENABLE (1L<<11)
667#define BNX2_MISC_ENABLE_STATUS_BITS_RX_MBUF_ENABLE (1L<<12)
668#define BNX2_MISC_ENABLE_STATUS_BITS_RX_LOOKUP_ENABLE (1L<<13)
669#define BNX2_MISC_ENABLE_STATUS_BITS_RX_PROCESSOR_ENABLE (1L<<14)
670#define BNX2_MISC_ENABLE_STATUS_BITS_RX_V2P_ENABLE (1L<<15)
671#define BNX2_MISC_ENABLE_STATUS_BITS_RX_BD_CACHE_ENABLE (1L<<16)
672#define BNX2_MISC_ENABLE_STATUS_BITS_RX_DMA_ENABLE (1L<<17)
673#define BNX2_MISC_ENABLE_STATUS_BITS_COMPLETION_ENABLE (1L<<18)
674#define BNX2_MISC_ENABLE_STATUS_BITS_HOST_COALESCE_ENABLE (1L<<19)
675#define BNX2_MISC_ENABLE_STATUS_BITS_MAILBOX_QUEUE_ENABLE (1L<<20)
676#define BNX2_MISC_ENABLE_STATUS_BITS_CONTEXT_ENABLE (1L<<21)
677#define BNX2_MISC_ENABLE_STATUS_BITS_CMD_SCHEDULER_ENABLE (1L<<22)
678#define BNX2_MISC_ENABLE_STATUS_BITS_CMD_PROCESSOR_ENABLE (1L<<23)
679#define BNX2_MISC_ENABLE_STATUS_BITS_MGMT_PROCESSOR_ENABLE (1L<<24)
680#define BNX2_MISC_ENABLE_STATUS_BITS_TIMER_ENABLE (1L<<25)
681#define BNX2_MISC_ENABLE_STATUS_BITS_DMA_ENGINE_ENABLE (1L<<26)
682#define BNX2_MISC_ENABLE_STATUS_BITS_UMP_ENABLE (1L<<27)
683
684#define BNX2_MISC_ENABLE_SET_BITS 0x00000810
685#define BNX2_MISC_ENABLE_SET_BITS_TX_SCHEDULER_ENABLE (1L<<0)
686#define BNX2_MISC_ENABLE_SET_BITS_TX_BD_READ_ENABLE (1L<<1)
687#define BNX2_MISC_ENABLE_SET_BITS_TX_BD_CACHE_ENABLE (1L<<2)
688#define BNX2_MISC_ENABLE_SET_BITS_TX_PROCESSOR_ENABLE (1L<<3)
689#define BNX2_MISC_ENABLE_SET_BITS_TX_DMA_ENABLE (1L<<4)
690#define BNX2_MISC_ENABLE_SET_BITS_TX_PATCHUP_ENABLE (1L<<5)
691#define BNX2_MISC_ENABLE_SET_BITS_TX_PAYLOAD_Q_ENABLE (1L<<6)
692#define BNX2_MISC_ENABLE_SET_BITS_TX_HEADER_Q_ENABLE (1L<<7)
693#define BNX2_MISC_ENABLE_SET_BITS_TX_ASSEMBLER_ENABLE (1L<<8)
694#define BNX2_MISC_ENABLE_SET_BITS_EMAC_ENABLE (1L<<9)
695#define BNX2_MISC_ENABLE_SET_BITS_RX_PARSER_MAC_ENABLE (1L<<10)
696#define BNX2_MISC_ENABLE_SET_BITS_RX_PARSER_CATCHUP_ENABLE (1L<<11)
697#define BNX2_MISC_ENABLE_SET_BITS_RX_MBUF_ENABLE (1L<<12)
698#define BNX2_MISC_ENABLE_SET_BITS_RX_LOOKUP_ENABLE (1L<<13)
699#define BNX2_MISC_ENABLE_SET_BITS_RX_PROCESSOR_ENABLE (1L<<14)
700#define BNX2_MISC_ENABLE_SET_BITS_RX_V2P_ENABLE (1L<<15)
701#define BNX2_MISC_ENABLE_SET_BITS_RX_BD_CACHE_ENABLE (1L<<16)
702#define BNX2_MISC_ENABLE_SET_BITS_RX_DMA_ENABLE (1L<<17)
703#define BNX2_MISC_ENABLE_SET_BITS_COMPLETION_ENABLE (1L<<18)
704#define BNX2_MISC_ENABLE_SET_BITS_HOST_COALESCE_ENABLE (1L<<19)
705#define BNX2_MISC_ENABLE_SET_BITS_MAILBOX_QUEUE_ENABLE (1L<<20)
706#define BNX2_MISC_ENABLE_SET_BITS_CONTEXT_ENABLE (1L<<21)
707#define BNX2_MISC_ENABLE_SET_BITS_CMD_SCHEDULER_ENABLE (1L<<22)
708#define BNX2_MISC_ENABLE_SET_BITS_CMD_PROCESSOR_ENABLE (1L<<23)
709#define BNX2_MISC_ENABLE_SET_BITS_MGMT_PROCESSOR_ENABLE (1L<<24)
710#define BNX2_MISC_ENABLE_SET_BITS_TIMER_ENABLE (1L<<25)
711#define BNX2_MISC_ENABLE_SET_BITS_DMA_ENGINE_ENABLE (1L<<26)
712#define BNX2_MISC_ENABLE_SET_BITS_UMP_ENABLE (1L<<27)
713
714#define BNX2_MISC_ENABLE_CLR_BITS 0x00000814
715#define BNX2_MISC_ENABLE_CLR_BITS_TX_SCHEDULER_ENABLE (1L<<0)
716#define BNX2_MISC_ENABLE_CLR_BITS_TX_BD_READ_ENABLE (1L<<1)
717#define BNX2_MISC_ENABLE_CLR_BITS_TX_BD_CACHE_ENABLE (1L<<2)
718#define BNX2_MISC_ENABLE_CLR_BITS_TX_PROCESSOR_ENABLE (1L<<3)
719#define BNX2_MISC_ENABLE_CLR_BITS_TX_DMA_ENABLE (1L<<4)
720#define BNX2_MISC_ENABLE_CLR_BITS_TX_PATCHUP_ENABLE (1L<<5)
721#define BNX2_MISC_ENABLE_CLR_BITS_TX_PAYLOAD_Q_ENABLE (1L<<6)
722#define BNX2_MISC_ENABLE_CLR_BITS_TX_HEADER_Q_ENABLE (1L<<7)
723#define BNX2_MISC_ENABLE_CLR_BITS_TX_ASSEMBLER_ENABLE (1L<<8)
724#define BNX2_MISC_ENABLE_CLR_BITS_EMAC_ENABLE (1L<<9)
725#define BNX2_MISC_ENABLE_CLR_BITS_RX_PARSER_MAC_ENABLE (1L<<10)
726#define BNX2_MISC_ENABLE_CLR_BITS_RX_PARSER_CATCHUP_ENABLE (1L<<11)
727#define BNX2_MISC_ENABLE_CLR_BITS_RX_MBUF_ENABLE (1L<<12)
728#define BNX2_MISC_ENABLE_CLR_BITS_RX_LOOKUP_ENABLE (1L<<13)
729#define BNX2_MISC_ENABLE_CLR_BITS_RX_PROCESSOR_ENABLE (1L<<14)
730#define BNX2_MISC_ENABLE_CLR_BITS_RX_V2P_ENABLE (1L<<15)
731#define BNX2_MISC_ENABLE_CLR_BITS_RX_BD_CACHE_ENABLE (1L<<16)
732#define BNX2_MISC_ENABLE_CLR_BITS_RX_DMA_ENABLE (1L<<17)
733#define BNX2_MISC_ENABLE_CLR_BITS_COMPLETION_ENABLE (1L<<18)
734#define BNX2_MISC_ENABLE_CLR_BITS_HOST_COALESCE_ENABLE (1L<<19)
735#define BNX2_MISC_ENABLE_CLR_BITS_MAILBOX_QUEUE_ENABLE (1L<<20)
736#define BNX2_MISC_ENABLE_CLR_BITS_CONTEXT_ENABLE (1L<<21)
737#define BNX2_MISC_ENABLE_CLR_BITS_CMD_SCHEDULER_ENABLE (1L<<22)
738#define BNX2_MISC_ENABLE_CLR_BITS_CMD_PROCESSOR_ENABLE (1L<<23)
739#define BNX2_MISC_ENABLE_CLR_BITS_MGMT_PROCESSOR_ENABLE (1L<<24)
740#define BNX2_MISC_ENABLE_CLR_BITS_TIMER_ENABLE (1L<<25)
741#define BNX2_MISC_ENABLE_CLR_BITS_DMA_ENGINE_ENABLE (1L<<26)
742#define BNX2_MISC_ENABLE_CLR_BITS_UMP_ENABLE (1L<<27)
743
744#define BNX2_MISC_CLOCK_CONTROL_BITS 0x00000818
745#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET (0xfL<<0)
746#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_32MHZ (0L<<0)
747#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_38MHZ (1L<<0)
748#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_48MHZ (2L<<0)
749#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_55MHZ (3L<<0)
750#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_66MHZ (4L<<0)
751#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_80MHZ (5L<<0)
752#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_95MHZ (6L<<0)
753#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_133MHZ (7L<<0)
754#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_LOW (0xfL<<0)
755#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_DISABLE (1L<<6)
756#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT (1L<<7)
757#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC (0x7L<<8)
758#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_UNDEF (0L<<8)
759#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_12 (1L<<8)
760#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_6 (2L<<8)
761#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_62 (4L<<8)
762#define BNX2_MISC_CLOCK_CONTROL_BITS_PLAY_DEAD (1L<<11)
763#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED (0xfL<<12)
764#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_100 (0L<<12)
765#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_80 (1L<<12)
766#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_50 (2L<<12)
767#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_40 (4L<<12)
768#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_25 (8L<<12)
769#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_STOP (1L<<16)
770#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_PLL_STOP (1L<<17)
771#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED_18 (1L<<18)
772#define BNX2_MISC_CLOCK_CONTROL_BITS_USE_SPD_DET (1L<<19)
773#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED (0xfffL<<20)
774
775#define BNX2_MISC_GPIO 0x0000081c
776#define BNX2_MISC_GPIO_VALUE (0xffL<<0)
777#define BNX2_MISC_GPIO_SET (0xffL<<8)
778#define BNX2_MISC_GPIO_CLR (0xffL<<16)
779#define BNX2_MISC_GPIO_FLOAT (0xffL<<24)
780
781#define BNX2_MISC_GPIO_INT 0x00000820
782#define BNX2_MISC_GPIO_INT_INT_STATE (0xfL<<0)
783#define BNX2_MISC_GPIO_INT_OLD_VALUE (0xfL<<8)
784#define BNX2_MISC_GPIO_INT_OLD_SET (0xfL<<16)
785#define BNX2_MISC_GPIO_INT_OLD_CLR (0xfL<<24)
786
787#define BNX2_MISC_CONFIG_LFSR 0x00000824
788#define BNX2_MISC_CONFIG_LFSR_DIV (0xffffL<<0)
789
790#define BNX2_MISC_LFSR_MASK_BITS 0x00000828
791#define BNX2_MISC_LFSR_MASK_BITS_TX_SCHEDULER_ENABLE (1L<<0)
792#define BNX2_MISC_LFSR_MASK_BITS_TX_BD_READ_ENABLE (1L<<1)
793#define BNX2_MISC_LFSR_MASK_BITS_TX_BD_CACHE_ENABLE (1L<<2)
794#define BNX2_MISC_LFSR_MASK_BITS_TX_PROCESSOR_ENABLE (1L<<3)
795#define BNX2_MISC_LFSR_MASK_BITS_TX_DMA_ENABLE (1L<<4)
796#define BNX2_MISC_LFSR_MASK_BITS_TX_PATCHUP_ENABLE (1L<<5)
797#define BNX2_MISC_LFSR_MASK_BITS_TX_PAYLOAD_Q_ENABLE (1L<<6)
798#define BNX2_MISC_LFSR_MASK_BITS_TX_HEADER_Q_ENABLE (1L<<7)
799#define BNX2_MISC_LFSR_MASK_BITS_TX_ASSEMBLER_ENABLE (1L<<8)
800#define BNX2_MISC_LFSR_MASK_BITS_EMAC_ENABLE (1L<<9)
801#define BNX2_MISC_LFSR_MASK_BITS_RX_PARSER_MAC_ENABLE (1L<<10)
802#define BNX2_MISC_LFSR_MASK_BITS_RX_PARSER_CATCHUP_ENABLE (1L<<11)
803#define BNX2_MISC_LFSR_MASK_BITS_RX_MBUF_ENABLE (1L<<12)
804#define BNX2_MISC_LFSR_MASK_BITS_RX_LOOKUP_ENABLE (1L<<13)
805#define BNX2_MISC_LFSR_MASK_BITS_RX_PROCESSOR_ENABLE (1L<<14)
806#define BNX2_MISC_LFSR_MASK_BITS_RX_V2P_ENABLE (1L<<15)
807#define BNX2_MISC_LFSR_MASK_BITS_RX_BD_CACHE_ENABLE (1L<<16)
808#define BNX2_MISC_LFSR_MASK_BITS_RX_DMA_ENABLE (1L<<17)
809#define BNX2_MISC_LFSR_MASK_BITS_COMPLETION_ENABLE (1L<<18)
810#define BNX2_MISC_LFSR_MASK_BITS_HOST_COALESCE_ENABLE (1L<<19)
811#define BNX2_MISC_LFSR_MASK_BITS_MAILBOX_QUEUE_ENABLE (1L<<20)
812#define BNX2_MISC_LFSR_MASK_BITS_CONTEXT_ENABLE (1L<<21)
813#define BNX2_MISC_LFSR_MASK_BITS_CMD_SCHEDULER_ENABLE (1L<<22)
814#define BNX2_MISC_LFSR_MASK_BITS_CMD_PROCESSOR_ENABLE (1L<<23)
815#define BNX2_MISC_LFSR_MASK_BITS_MGMT_PROCESSOR_ENABLE (1L<<24)
816#define BNX2_MISC_LFSR_MASK_BITS_TIMER_ENABLE (1L<<25)
817#define BNX2_MISC_LFSR_MASK_BITS_DMA_ENGINE_ENABLE (1L<<26)
818#define BNX2_MISC_LFSR_MASK_BITS_UMP_ENABLE (1L<<27)
819
820#define BNX2_MISC_ARB_REQ0 0x0000082c
821#define BNX2_MISC_ARB_REQ1 0x00000830
822#define BNX2_MISC_ARB_REQ2 0x00000834
823#define BNX2_MISC_ARB_REQ3 0x00000838
824#define BNX2_MISC_ARB_REQ4 0x0000083c
825#define BNX2_MISC_ARB_FREE0 0x00000840
826#define BNX2_MISC_ARB_FREE1 0x00000844
827#define BNX2_MISC_ARB_FREE2 0x00000848
828#define BNX2_MISC_ARB_FREE3 0x0000084c
829#define BNX2_MISC_ARB_FREE4 0x00000850
830#define BNX2_MISC_ARB_REQ_STATUS0 0x00000854
831#define BNX2_MISC_ARB_REQ_STATUS1 0x00000858
832#define BNX2_MISC_ARB_REQ_STATUS2 0x0000085c
833#define BNX2_MISC_ARB_REQ_STATUS3 0x00000860
834#define BNX2_MISC_ARB_REQ_STATUS4 0x00000864
835#define BNX2_MISC_ARB_GNT0 0x00000868
836#define BNX2_MISC_ARB_GNT0_0 (0x7L<<0)
837#define BNX2_MISC_ARB_GNT0_1 (0x7L<<4)
838#define BNX2_MISC_ARB_GNT0_2 (0x7L<<8)
839#define BNX2_MISC_ARB_GNT0_3 (0x7L<<12)
840#define BNX2_MISC_ARB_GNT0_4 (0x7L<<16)
841#define BNX2_MISC_ARB_GNT0_5 (0x7L<<20)
842#define BNX2_MISC_ARB_GNT0_6 (0x7L<<24)
843#define BNX2_MISC_ARB_GNT0_7 (0x7L<<28)
844
845#define BNX2_MISC_ARB_GNT1 0x0000086c
846#define BNX2_MISC_ARB_GNT1_8 (0x7L<<0)
847#define BNX2_MISC_ARB_GNT1_9 (0x7L<<4)
848#define BNX2_MISC_ARB_GNT1_10 (0x7L<<8)
849#define BNX2_MISC_ARB_GNT1_11 (0x7L<<12)
850#define BNX2_MISC_ARB_GNT1_12 (0x7L<<16)
851#define BNX2_MISC_ARB_GNT1_13 (0x7L<<20)
852#define BNX2_MISC_ARB_GNT1_14 (0x7L<<24)
853#define BNX2_MISC_ARB_GNT1_15 (0x7L<<28)
854
855#define BNX2_MISC_ARB_GNT2 0x00000870
856#define BNX2_MISC_ARB_GNT2_16 (0x7L<<0)
857#define BNX2_MISC_ARB_GNT2_17 (0x7L<<4)
858#define BNX2_MISC_ARB_GNT2_18 (0x7L<<8)
859#define BNX2_MISC_ARB_GNT2_19 (0x7L<<12)
860#define BNX2_MISC_ARB_GNT2_20 (0x7L<<16)
861#define BNX2_MISC_ARB_GNT2_21 (0x7L<<20)
862#define BNX2_MISC_ARB_GNT2_22 (0x7L<<24)
863#define BNX2_MISC_ARB_GNT2_23 (0x7L<<28)
864
865#define BNX2_MISC_ARB_GNT3 0x00000874
866#define BNX2_MISC_ARB_GNT3_24 (0x7L<<0)
867#define BNX2_MISC_ARB_GNT3_25 (0x7L<<4)
868#define BNX2_MISC_ARB_GNT3_26 (0x7L<<8)
869#define BNX2_MISC_ARB_GNT3_27 (0x7L<<12)
870#define BNX2_MISC_ARB_GNT3_28 (0x7L<<16)
871#define BNX2_MISC_ARB_GNT3_29 (0x7L<<20)
872#define BNX2_MISC_ARB_GNT3_30 (0x7L<<24)
873#define BNX2_MISC_ARB_GNT3_31 (0x7L<<28)
874
875#define BNX2_MISC_PRBS_CONTROL 0x00000878
876#define BNX2_MISC_PRBS_CONTROL_EN (1L<<0)
877#define BNX2_MISC_PRBS_CONTROL_RSTB (1L<<1)
878#define BNX2_MISC_PRBS_CONTROL_INV (1L<<2)
879#define BNX2_MISC_PRBS_CONTROL_ERR_CLR (1L<<3)
880#define BNX2_MISC_PRBS_CONTROL_ORDER (0x3L<<4)
881#define BNX2_MISC_PRBS_CONTROL_ORDER_7TH (0L<<4)
882#define BNX2_MISC_PRBS_CONTROL_ORDER_15TH (1L<<4)
883#define BNX2_MISC_PRBS_CONTROL_ORDER_23RD (2L<<4)
884#define BNX2_MISC_PRBS_CONTROL_ORDER_31ST (3L<<4)
885
886#define BNX2_MISC_PRBS_STATUS 0x0000087c
887#define BNX2_MISC_PRBS_STATUS_LOCK (1L<<0)
888#define BNX2_MISC_PRBS_STATUS_STKY (1L<<1)
889#define BNX2_MISC_PRBS_STATUS_ERRORS (0x3fffL<<2)
890#define BNX2_MISC_PRBS_STATUS_STATE (0xfL<<16)
891
892#define BNX2_MISC_SM_ASF_CONTROL 0x00000880
893#define BNX2_MISC_SM_ASF_CONTROL_ASF_RST (1L<<0)
894#define BNX2_MISC_SM_ASF_CONTROL_TSC_EN (1L<<1)
895#define BNX2_MISC_SM_ASF_CONTROL_WG_TO (1L<<2)
896#define BNX2_MISC_SM_ASF_CONTROL_HB_TO (1L<<3)
897#define BNX2_MISC_SM_ASF_CONTROL_PA_TO (1L<<4)
898#define BNX2_MISC_SM_ASF_CONTROL_PL_TO (1L<<5)
899#define BNX2_MISC_SM_ASF_CONTROL_RT_TO (1L<<6)
900#define BNX2_MISC_SM_ASF_CONTROL_SMB_EVENT (1L<<7)
901#define BNX2_MISC_SM_ASF_CONTROL_RES (0xfL<<8)
902#define BNX2_MISC_SM_ASF_CONTROL_SMB_EN (1L<<12)
903#define BNX2_MISC_SM_ASF_CONTROL_SMB_BB_EN (1L<<13)
904#define BNX2_MISC_SM_ASF_CONTROL_SMB_NO_ADDR_FILT (1L<<14)
905#define BNX2_MISC_SM_ASF_CONTROL_SMB_AUTOREAD (1L<<15)
906#define BNX2_MISC_SM_ASF_CONTROL_NIC_SMB_ADDR1 (0x3fL<<16)
907#define BNX2_MISC_SM_ASF_CONTROL_NIC_SMB_ADDR2 (0x3fL<<24)
908#define BNX2_MISC_SM_ASF_CONTROL_EN_NIC_SMB_ADDR_0 (1L<<30)
909#define BNX2_MISC_SM_ASF_CONTROL_SMB_EARLY_ATTN (1L<<31)
910
911#define BNX2_MISC_SMB_IN 0x00000884
912#define BNX2_MISC_SMB_IN_DAT_IN (0xffL<<0)
913#define BNX2_MISC_SMB_IN_RDY (1L<<8)
914#define BNX2_MISC_SMB_IN_DONE (1L<<9)
915#define BNX2_MISC_SMB_IN_FIRSTBYTE (1L<<10)
916#define BNX2_MISC_SMB_IN_STATUS (0x7L<<11)
917#define BNX2_MISC_SMB_IN_STATUS_OK (0x0L<<11)
918#define BNX2_MISC_SMB_IN_STATUS_PEC (0x1L<<11)
919#define BNX2_MISC_SMB_IN_STATUS_OFLOW (0x2L<<11)
920#define BNX2_MISC_SMB_IN_STATUS_STOP (0x3L<<11)
921#define BNX2_MISC_SMB_IN_STATUS_TIMEOUT (0x4L<<11)
922
923#define BNX2_MISC_SMB_OUT 0x00000888
924#define BNX2_MISC_SMB_OUT_DAT_OUT (0xffL<<0)
925#define BNX2_MISC_SMB_OUT_RDY (1L<<8)
926#define BNX2_MISC_SMB_OUT_START (1L<<9)
927#define BNX2_MISC_SMB_OUT_LAST (1L<<10)
928#define BNX2_MISC_SMB_OUT_ACC_TYPE (1L<<11)
929#define BNX2_MISC_SMB_OUT_ENB_PEC (1L<<12)
930#define BNX2_MISC_SMB_OUT_GET_RX_LEN (1L<<13)
931#define BNX2_MISC_SMB_OUT_SMB_READ_LEN (0x3fL<<14)
932#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS (0xfL<<20)
933#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_OK (0L<<20)
934#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_FIRST_NACK (1L<<20)
935#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_SUB_NACK (9L<<20)
936#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_UFLOW (2L<<20)
937#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_STOP (3L<<20)
938#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_TIMEOUT (4L<<20)
939#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_FIRST_LOST (5L<<20)
940#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_SUB_LOST (0xdL<<20)
941#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_BADACK (0x6L<<20)
942#define BNX2_MISC_SMB_OUT_SMB_OUT_SLAVEMODE (1L<<24)
943#define BNX2_MISC_SMB_OUT_SMB_OUT_DAT_EN (1L<<25)
944#define BNX2_MISC_SMB_OUT_SMB_OUT_DAT_IN (1L<<26)
945#define BNX2_MISC_SMB_OUT_SMB_OUT_CLK_EN (1L<<27)
946#define BNX2_MISC_SMB_OUT_SMB_OUT_CLK_IN (1L<<28)
947
948#define BNX2_MISC_SMB_WATCHDOG 0x0000088c
949#define BNX2_MISC_SMB_WATCHDOG_WATCHDOG (0xffffL<<0)
950
951#define BNX2_MISC_SMB_HEARTBEAT 0x00000890
952#define BNX2_MISC_SMB_HEARTBEAT_HEARTBEAT (0xffffL<<0)
953
954#define BNX2_MISC_SMB_POLL_ASF 0x00000894
955#define BNX2_MISC_SMB_POLL_ASF_POLL_ASF (0xffffL<<0)
956
957#define BNX2_MISC_SMB_POLL_LEGACY 0x00000898
958#define BNX2_MISC_SMB_POLL_LEGACY_POLL_LEGACY (0xffffL<<0)
959
960#define BNX2_MISC_SMB_RETRAN 0x0000089c
961#define BNX2_MISC_SMB_RETRAN_RETRAN (0xffL<<0)
962
963#define BNX2_MISC_SMB_TIMESTAMP 0x000008a0
964#define BNX2_MISC_SMB_TIMESTAMP_TIMESTAMP (0xffffffffL<<0)
965
966#define BNX2_MISC_PERR_ENA0 0x000008a4
967#define BNX2_MISC_PERR_ENA0_COM_MISC_CTXC (1L<<0)
968#define BNX2_MISC_PERR_ENA0_COM_MISC_REGF (1L<<1)
969#define BNX2_MISC_PERR_ENA0_COM_MISC_SCPAD (1L<<2)
970#define BNX2_MISC_PERR_ENA0_CP_MISC_CTXC (1L<<3)
971#define BNX2_MISC_PERR_ENA0_CP_MISC_REGF (1L<<4)
972#define BNX2_MISC_PERR_ENA0_CP_MISC_SCPAD (1L<<5)
973#define BNX2_MISC_PERR_ENA0_CS_MISC_TMEM (1L<<6)
974#define BNX2_MISC_PERR_ENA0_CTX_MISC_ACCM0 (1L<<7)
975#define BNX2_MISC_PERR_ENA0_CTX_MISC_ACCM1 (1L<<8)
976#define BNX2_MISC_PERR_ENA0_CTX_MISC_ACCM2 (1L<<9)
977#define BNX2_MISC_PERR_ENA0_CTX_MISC_ACCM3 (1L<<10)
978#define BNX2_MISC_PERR_ENA0_CTX_MISC_ACCM4 (1L<<11)
979#define BNX2_MISC_PERR_ENA0_CTX_MISC_ACCM5 (1L<<12)
980#define BNX2_MISC_PERR_ENA0_CTX_MISC_PGTBL (1L<<13)
981#define BNX2_MISC_PERR_ENA0_DMAE_MISC_DR0 (1L<<14)
982#define BNX2_MISC_PERR_ENA0_DMAE_MISC_DR1 (1L<<15)
983#define BNX2_MISC_PERR_ENA0_DMAE_MISC_DR2 (1L<<16)
984#define BNX2_MISC_PERR_ENA0_DMAE_MISC_DR3 (1L<<17)
985#define BNX2_MISC_PERR_ENA0_DMAE_MISC_DR4 (1L<<18)
986#define BNX2_MISC_PERR_ENA0_DMAE_MISC_DW0 (1L<<19)
987#define BNX2_MISC_PERR_ENA0_DMAE_MISC_DW1 (1L<<20)
988#define BNX2_MISC_PERR_ENA0_DMAE_MISC_DW2 (1L<<21)
989#define BNX2_MISC_PERR_ENA0_HC_MISC_DMA (1L<<22)
990#define BNX2_MISC_PERR_ENA0_MCP_MISC_REGF (1L<<23)
991#define BNX2_MISC_PERR_ENA0_MCP_MISC_SCPAD (1L<<24)
992#define BNX2_MISC_PERR_ENA0_MQ_MISC_CTX (1L<<25)
993#define BNX2_MISC_PERR_ENA0_RBDC_MISC (1L<<26)
994#define BNX2_MISC_PERR_ENA0_RBUF_MISC_MB (1L<<27)
995#define BNX2_MISC_PERR_ENA0_RBUF_MISC_PTR (1L<<28)
996#define BNX2_MISC_PERR_ENA0_RDE_MISC_RPC (1L<<29)
997#define BNX2_MISC_PERR_ENA0_RDE_MISC_RPM (1L<<30)
998#define BNX2_MISC_PERR_ENA0_RV2P_MISC_CB0REGS (1L<<31)
999
1000#define BNX2_MISC_PERR_ENA1 0x000008a8
1001#define BNX2_MISC_PERR_ENA1_RV2P_MISC_CB1REGS (1L<<0)
1002#define BNX2_MISC_PERR_ENA1_RV2P_MISC_P1IRAM (1L<<1)
1003#define BNX2_MISC_PERR_ENA1_RV2P_MISC_P2IRAM (1L<<2)
1004#define BNX2_MISC_PERR_ENA1_RXP_MISC_CTXC (1L<<3)
1005#define BNX2_MISC_PERR_ENA1_RXP_MISC_REGF (1L<<4)
1006#define BNX2_MISC_PERR_ENA1_RXP_MISC_SCPAD (1L<<5)
1007#define BNX2_MISC_PERR_ENA1_RXP_MISC_RBUFC (1L<<6)
1008#define BNX2_MISC_PERR_ENA1_TBDC_MISC (1L<<7)
1009#define BNX2_MISC_PERR_ENA1_TDMA_MISC (1L<<8)
1010#define BNX2_MISC_PERR_ENA1_THBUF_MISC_MB0 (1L<<9)
1011#define BNX2_MISC_PERR_ENA1_THBUF_MISC_MB1 (1L<<10)
1012#define BNX2_MISC_PERR_ENA1_TPAT_MISC_REGF (1L<<11)
1013#define BNX2_MISC_PERR_ENA1_TPAT_MISC_SCPAD (1L<<12)
1014#define BNX2_MISC_PERR_ENA1_TPBUF_MISC_MB (1L<<13)
1015#define BNX2_MISC_PERR_ENA1_TSCH_MISC_LR (1L<<14)
1016#define BNX2_MISC_PERR_ENA1_TXP_MISC_CTXC (1L<<15)
1017#define BNX2_MISC_PERR_ENA1_TXP_MISC_REGF (1L<<16)
1018#define BNX2_MISC_PERR_ENA1_TXP_MISC_SCPAD (1L<<17)
1019#define BNX2_MISC_PERR_ENA1_UMP_MISC_FIORX (1L<<18)
1020#define BNX2_MISC_PERR_ENA1_UMP_MISC_FIOTX (1L<<19)
1021#define BNX2_MISC_PERR_ENA1_UMP_MISC_RX (1L<<20)
1022#define BNX2_MISC_PERR_ENA1_UMP_MISC_TX (1L<<21)
1023#define BNX2_MISC_PERR_ENA1_RDMAQ_MISC (1L<<22)
1024#define BNX2_MISC_PERR_ENA1_CSQ_MISC (1L<<23)
1025#define BNX2_MISC_PERR_ENA1_CPQ_MISC (1L<<24)
1026#define BNX2_MISC_PERR_ENA1_MCPQ_MISC (1L<<25)
1027#define BNX2_MISC_PERR_ENA1_RV2PMQ_MISC (1L<<26)
1028#define BNX2_MISC_PERR_ENA1_RV2PPQ_MISC (1L<<27)
1029#define BNX2_MISC_PERR_ENA1_RV2PTQ_MISC (1L<<28)
1030#define BNX2_MISC_PERR_ENA1_RXPQ_MISC (1L<<29)
1031#define BNX2_MISC_PERR_ENA1_RXPCQ_MISC (1L<<30)
1032#define BNX2_MISC_PERR_ENA1_RLUPQ_MISC (1L<<31)
1033
1034#define BNX2_MISC_PERR_ENA2 0x000008ac
1035#define BNX2_MISC_PERR_ENA2_COMQ_MISC (1L<<0)
1036#define BNX2_MISC_PERR_ENA2_COMXQ_MISC (1L<<1)
1037#define BNX2_MISC_PERR_ENA2_COMTQ_MISC (1L<<2)
1038#define BNX2_MISC_PERR_ENA2_TSCHQ_MISC (1L<<3)
1039#define BNX2_MISC_PERR_ENA2_TBDRQ_MISC (1L<<4)
1040#define BNX2_MISC_PERR_ENA2_TXPQ_MISC (1L<<5)
1041#define BNX2_MISC_PERR_ENA2_TDMAQ_MISC (1L<<6)
1042#define BNX2_MISC_PERR_ENA2_TPATQ_MISC (1L<<7)
1043#define BNX2_MISC_PERR_ENA2_TASQ_MISC (1L<<8)
1044
1045#define BNX2_MISC_DEBUG_VECTOR_SEL 0x000008b0
1046#define BNX2_MISC_DEBUG_VECTOR_SEL_0 (0xfffL<<0)
1047#define BNX2_MISC_DEBUG_VECTOR_SEL_1 (0xfffL<<12)
1048
1049#define BNX2_MISC_VREG_CONTROL 0x000008b4
1050#define BNX2_MISC_VREG_CONTROL_1_2 (0xfL<<0)
1051#define BNX2_MISC_VREG_CONTROL_2_5 (0xfL<<4)
1052
1053#define BNX2_MISC_FINAL_CLK_CTL_VAL 0x000008b8
1054#define BNX2_MISC_FINAL_CLK_CTL_VAL_MISC_FINAL_CLK_CTL_VAL (0x3ffffffL<<6)
1055
1056#define BNX2_MISC_UNUSED0 0x000008bc
1057
1058
1059/*
1060 * nvm_reg definition
1061 * offset: 0x6400
1062 */
1063#define BNX2_NVM_COMMAND 0x00006400
1064#define BNX2_NVM_COMMAND_RST (1L<<0)
1065#define BNX2_NVM_COMMAND_DONE (1L<<3)
1066#define BNX2_NVM_COMMAND_DOIT (1L<<4)
1067#define BNX2_NVM_COMMAND_WR (1L<<5)
1068#define BNX2_NVM_COMMAND_ERASE (1L<<6)
1069#define BNX2_NVM_COMMAND_FIRST (1L<<7)
1070#define BNX2_NVM_COMMAND_LAST (1L<<8)
1071#define BNX2_NVM_COMMAND_WREN (1L<<16)
1072#define BNX2_NVM_COMMAND_WRDI (1L<<17)
1073#define BNX2_NVM_COMMAND_EWSR (1L<<18)
1074#define BNX2_NVM_COMMAND_WRSR (1L<<19)
1075
1076#define BNX2_NVM_STATUS 0x00006404
1077#define BNX2_NVM_STATUS_PI_FSM_STATE (0xfL<<0)
1078#define BNX2_NVM_STATUS_EE_FSM_STATE (0xfL<<4)
1079#define BNX2_NVM_STATUS_EQ_FSM_STATE (0xfL<<8)
1080
1081#define BNX2_NVM_WRITE 0x00006408
1082#define BNX2_NVM_WRITE_NVM_WRITE_VALUE (0xffffffffL<<0)
1083#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_BIT_BANG (0L<<0)
1084#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_EECLK (1L<<0)
1085#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_EEDATA (2L<<0)
1086#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SCLK (4L<<0)
1087#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_CS_B (8L<<0)
1088#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SO (16L<<0)
1089#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SI (32L<<0)
1090
1091#define BNX2_NVM_ADDR 0x0000640c
1092#define BNX2_NVM_ADDR_NVM_ADDR_VALUE (0xffffffL<<0)
1093#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_BIT_BANG (0L<<0)
1094#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_EECLK (1L<<0)
1095#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_EEDATA (2L<<0)
1096#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SCLK (4L<<0)
1097#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_CS_B (8L<<0)
1098#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SO (16L<<0)
1099#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SI (32L<<0)
1100
1101#define BNX2_NVM_READ 0x00006410
1102#define BNX2_NVM_READ_NVM_READ_VALUE (0xffffffffL<<0)
1103#define BNX2_NVM_READ_NVM_READ_VALUE_BIT_BANG (0L<<0)
1104#define BNX2_NVM_READ_NVM_READ_VALUE_EECLK (1L<<0)
1105#define BNX2_NVM_READ_NVM_READ_VALUE_EEDATA (2L<<0)
1106#define BNX2_NVM_READ_NVM_READ_VALUE_SCLK (4L<<0)
1107#define BNX2_NVM_READ_NVM_READ_VALUE_CS_B (8L<<0)
1108#define BNX2_NVM_READ_NVM_READ_VALUE_SO (16L<<0)
1109#define BNX2_NVM_READ_NVM_READ_VALUE_SI (32L<<0)
1110
1111#define BNX2_NVM_CFG1 0x00006414
1112#define BNX2_NVM_CFG1_FLASH_MODE (1L<<0)
1113#define BNX2_NVM_CFG1_BUFFER_MODE (1L<<1)
1114#define BNX2_NVM_CFG1_PASS_MODE (1L<<2)
1115#define BNX2_NVM_CFG1_BITBANG_MODE (1L<<3)
1116#define BNX2_NVM_CFG1_STATUS_BIT (0x7L<<4)
1117#define BNX2_NVM_CFG1_STATUS_BIT_FLASH_RDY (0L<<4)
1118#define BNX2_NVM_CFG1_STATUS_BIT_BUFFER_RDY (7L<<4)
1119#define BNX2_NVM_CFG1_SPI_CLK_DIV (0xfL<<7)
1120#define BNX2_NVM_CFG1_SEE_CLK_DIV (0x7ffL<<11)
1121#define BNX2_NVM_CFG1_PROTECT_MODE (1L<<24)
1122#define BNX2_NVM_CFG1_FLASH_SIZE (1L<<25)
1123#define BNX2_NVM_CFG1_COMPAT_BYPASSS (1L<<31)
1124
1125#define BNX2_NVM_CFG2 0x00006418
1126#define BNX2_NVM_CFG2_ERASE_CMD (0xffL<<0)
1127#define BNX2_NVM_CFG2_DUMMY (0xffL<<8)
1128#define BNX2_NVM_CFG2_STATUS_CMD (0xffL<<16)
1129
1130#define BNX2_NVM_CFG3 0x0000641c
1131#define BNX2_NVM_CFG3_BUFFER_RD_CMD (0xffL<<0)
1132#define BNX2_NVM_CFG3_WRITE_CMD (0xffL<<8)
1133#define BNX2_NVM_CFG3_BUFFER_WRITE_CMD (0xffL<<16)
1134#define BNX2_NVM_CFG3_READ_CMD (0xffL<<24)
1135
1136#define BNX2_NVM_SW_ARB 0x00006420
1137#define BNX2_NVM_SW_ARB_ARB_REQ_SET0 (1L<<0)
1138#define BNX2_NVM_SW_ARB_ARB_REQ_SET1 (1L<<1)
1139#define BNX2_NVM_SW_ARB_ARB_REQ_SET2 (1L<<2)
1140#define BNX2_NVM_SW_ARB_ARB_REQ_SET3 (1L<<3)
1141#define BNX2_NVM_SW_ARB_ARB_REQ_CLR0 (1L<<4)
1142#define BNX2_NVM_SW_ARB_ARB_REQ_CLR1 (1L<<5)
1143#define BNX2_NVM_SW_ARB_ARB_REQ_CLR2 (1L<<6)
1144#define BNX2_NVM_SW_ARB_ARB_REQ_CLR3 (1L<<7)
1145#define BNX2_NVM_SW_ARB_ARB_ARB0 (1L<<8)
1146#define BNX2_NVM_SW_ARB_ARB_ARB1 (1L<<9)
1147#define BNX2_NVM_SW_ARB_ARB_ARB2 (1L<<10)
1148#define BNX2_NVM_SW_ARB_ARB_ARB3 (1L<<11)
1149#define BNX2_NVM_SW_ARB_REQ0 (1L<<12)
1150#define BNX2_NVM_SW_ARB_REQ1 (1L<<13)
1151#define BNX2_NVM_SW_ARB_REQ2 (1L<<14)
1152#define BNX2_NVM_SW_ARB_REQ3 (1L<<15)
1153
1154#define BNX2_NVM_ACCESS_ENABLE 0x00006424
1155#define BNX2_NVM_ACCESS_ENABLE_EN (1L<<0)
1156#define BNX2_NVM_ACCESS_ENABLE_WR_EN (1L<<1)
1157
1158#define BNX2_NVM_WRITE1 0x00006428
1159#define BNX2_NVM_WRITE1_WREN_CMD (0xffL<<0)
1160#define BNX2_NVM_WRITE1_WRDI_CMD (0xffL<<8)
1161#define BNX2_NVM_WRITE1_SR_DATA (0xffL<<16)
1162
1163
1164
1165/*
1166 * dma_reg definition
1167 * offset: 0xc00
1168 */
1169#define BNX2_DMA_COMMAND 0x00000c00
1170#define BNX2_DMA_COMMAND_ENABLE (1L<<0)
1171
1172#define BNX2_DMA_STATUS 0x00000c04
1173#define BNX2_DMA_STATUS_PAR_ERROR_STATE (1L<<0)
1174#define BNX2_DMA_STATUS_READ_TRANSFERS_STAT (1L<<16)
1175#define BNX2_DMA_STATUS_READ_DELAY_PCI_CLKS_STAT (1L<<17)
1176#define BNX2_DMA_STATUS_BIG_READ_TRANSFERS_STAT (1L<<18)
1177#define BNX2_DMA_STATUS_BIG_READ_DELAY_PCI_CLKS_STAT (1L<<19)
1178#define BNX2_DMA_STATUS_BIG_READ_RETRY_AFTER_DATA_STAT (1L<<20)
1179#define BNX2_DMA_STATUS_WRITE_TRANSFERS_STAT (1L<<21)
1180#define BNX2_DMA_STATUS_WRITE_DELAY_PCI_CLKS_STAT (1L<<22)
1181#define BNX2_DMA_STATUS_BIG_WRITE_TRANSFERS_STAT (1L<<23)
1182#define BNX2_DMA_STATUS_BIG_WRITE_DELAY_PCI_CLKS_STAT (1L<<24)
1183#define BNX2_DMA_STATUS_BIG_WRITE_RETRY_AFTER_DATA_STAT (1L<<25)
1184
1185#define BNX2_DMA_CONFIG 0x00000c08
1186#define BNX2_DMA_CONFIG_DATA_BYTE_SWAP (1L<<0)
1187#define BNX2_DMA_CONFIG_DATA_WORD_SWAP (1L<<1)
1188#define BNX2_DMA_CONFIG_CNTL_BYTE_SWAP (1L<<4)
1189#define BNX2_DMA_CONFIG_CNTL_WORD_SWAP (1L<<5)
1190#define BNX2_DMA_CONFIG_ONE_DMA (1L<<6)
1191#define BNX2_DMA_CONFIG_CNTL_TWO_DMA (1L<<7)
1192#define BNX2_DMA_CONFIG_CNTL_FPGA_MODE (1L<<8)
1193#define BNX2_DMA_CONFIG_CNTL_PING_PONG_DMA (1L<<10)
1194#define BNX2_DMA_CONFIG_CNTL_PCI_COMP_DLY (1L<<11)
1195#define BNX2_DMA_CONFIG_NO_RCHANS_IN_USE (0xfL<<12)
1196#define BNX2_DMA_CONFIG_NO_WCHANS_IN_USE (0xfL<<16)
1197#define BNX2_DMA_CONFIG_PCI_CLK_CMP_BITS (0x7L<<20)
1198#define BNX2_DMA_CONFIG_PCI_FAST_CLK_CMP (1L<<23)
1199#define BNX2_DMA_CONFIG_BIG_SIZE (0xfL<<24)
1200#define BNX2_DMA_CONFIG_BIG_SIZE_NONE (0x0L<<24)
1201#define BNX2_DMA_CONFIG_BIG_SIZE_64 (0x1L<<24)
1202#define BNX2_DMA_CONFIG_BIG_SIZE_128 (0x2L<<24)
1203#define BNX2_DMA_CONFIG_BIG_SIZE_256 (0x4L<<24)
1204#define BNX2_DMA_CONFIG_BIG_SIZE_512 (0x8L<<24)
1205
1206#define BNX2_DMA_BLACKOUT 0x00000c0c
1207#define BNX2_DMA_BLACKOUT_RD_RETRY_BLACKOUT (0xffL<<0)
1208#define BNX2_DMA_BLACKOUT_2ND_RD_RETRY_BLACKOUT (0xffL<<8)
1209#define BNX2_DMA_BLACKOUT_WR_RETRY_BLACKOUT (0xffL<<16)
1210
1211#define BNX2_DMA_RCHAN_STAT 0x00000c30
1212#define BNX2_DMA_RCHAN_STAT_COMP_CODE_0 (0x7L<<0)
1213#define BNX2_DMA_RCHAN_STAT_PAR_ERR_0 (1L<<3)
1214#define BNX2_DMA_RCHAN_STAT_COMP_CODE_1 (0x7L<<4)
1215#define BNX2_DMA_RCHAN_STAT_PAR_ERR_1 (1L<<7)
1216#define BNX2_DMA_RCHAN_STAT_COMP_CODE_2 (0x7L<<8)
1217#define BNX2_DMA_RCHAN_STAT_PAR_ERR_2 (1L<<11)
1218#define BNX2_DMA_RCHAN_STAT_COMP_CODE_3 (0x7L<<12)
1219#define BNX2_DMA_RCHAN_STAT_PAR_ERR_3 (1L<<15)
1220#define BNX2_DMA_RCHAN_STAT_COMP_CODE_4 (0x7L<<16)
1221#define BNX2_DMA_RCHAN_STAT_PAR_ERR_4 (1L<<19)
1222#define BNX2_DMA_RCHAN_STAT_COMP_CODE_5 (0x7L<<20)
1223#define BNX2_DMA_RCHAN_STAT_PAR_ERR_5 (1L<<23)
1224#define BNX2_DMA_RCHAN_STAT_COMP_CODE_6 (0x7L<<24)
1225#define BNX2_DMA_RCHAN_STAT_PAR_ERR_6 (1L<<27)
1226#define BNX2_DMA_RCHAN_STAT_COMP_CODE_7 (0x7L<<28)
1227#define BNX2_DMA_RCHAN_STAT_PAR_ERR_7 (1L<<31)
1228
1229#define BNX2_DMA_WCHAN_STAT 0x00000c34
1230#define BNX2_DMA_WCHAN_STAT_COMP_CODE_0 (0x7L<<0)
1231#define BNX2_DMA_WCHAN_STAT_PAR_ERR_0 (1L<<3)
1232#define BNX2_DMA_WCHAN_STAT_COMP_CODE_1 (0x7L<<4)
1233#define BNX2_DMA_WCHAN_STAT_PAR_ERR_1 (1L<<7)
1234#define BNX2_DMA_WCHAN_STAT_COMP_CODE_2 (0x7L<<8)
1235#define BNX2_DMA_WCHAN_STAT_PAR_ERR_2 (1L<<11)
1236#define BNX2_DMA_WCHAN_STAT_COMP_CODE_3 (0x7L<<12)
1237#define BNX2_DMA_WCHAN_STAT_PAR_ERR_3 (1L<<15)
1238#define BNX2_DMA_WCHAN_STAT_COMP_CODE_4 (0x7L<<16)
1239#define BNX2_DMA_WCHAN_STAT_PAR_ERR_4 (1L<<19)
1240#define BNX2_DMA_WCHAN_STAT_COMP_CODE_5 (0x7L<<20)
1241#define BNX2_DMA_WCHAN_STAT_PAR_ERR_5 (1L<<23)
1242#define BNX2_DMA_WCHAN_STAT_COMP_CODE_6 (0x7L<<24)
1243#define BNX2_DMA_WCHAN_STAT_PAR_ERR_6 (1L<<27)
1244#define BNX2_DMA_WCHAN_STAT_COMP_CODE_7 (0x7L<<28)
1245#define BNX2_DMA_WCHAN_STAT_PAR_ERR_7 (1L<<31)
1246
1247#define BNX2_DMA_RCHAN_ASSIGNMENT 0x00000c38
1248#define BNX2_DMA_RCHAN_ASSIGNMENT_0 (0xfL<<0)
1249#define BNX2_DMA_RCHAN_ASSIGNMENT_1 (0xfL<<4)
1250#define BNX2_DMA_RCHAN_ASSIGNMENT_2 (0xfL<<8)
1251#define BNX2_DMA_RCHAN_ASSIGNMENT_3 (0xfL<<12)
1252#define BNX2_DMA_RCHAN_ASSIGNMENT_4 (0xfL<<16)
1253#define BNX2_DMA_RCHAN_ASSIGNMENT_5 (0xfL<<20)
1254#define BNX2_DMA_RCHAN_ASSIGNMENT_6 (0xfL<<24)
1255#define BNX2_DMA_RCHAN_ASSIGNMENT_7 (0xfL<<28)
1256
1257#define BNX2_DMA_WCHAN_ASSIGNMENT 0x00000c3c
1258#define BNX2_DMA_WCHAN_ASSIGNMENT_0 (0xfL<<0)
1259#define BNX2_DMA_WCHAN_ASSIGNMENT_1 (0xfL<<4)
1260#define BNX2_DMA_WCHAN_ASSIGNMENT_2 (0xfL<<8)
1261#define BNX2_DMA_WCHAN_ASSIGNMENT_3 (0xfL<<12)
1262#define BNX2_DMA_WCHAN_ASSIGNMENT_4 (0xfL<<16)
1263#define BNX2_DMA_WCHAN_ASSIGNMENT_5 (0xfL<<20)
1264#define BNX2_DMA_WCHAN_ASSIGNMENT_6 (0xfL<<24)
1265#define BNX2_DMA_WCHAN_ASSIGNMENT_7 (0xfL<<28)
1266
1267#define BNX2_DMA_RCHAN_STAT_00 0x00000c40
1268#define BNX2_DMA_RCHAN_STAT_00_RCHAN_STA_HOST_ADDR_LOW (0xffffffffL<<0)
1269
1270#define BNX2_DMA_RCHAN_STAT_01 0x00000c44
1271#define BNX2_DMA_RCHAN_STAT_01_RCHAN_STA_HOST_ADDR_HIGH (0xffffffffL<<0)
1272
1273#define BNX2_DMA_RCHAN_STAT_02 0x00000c48
1274#define BNX2_DMA_RCHAN_STAT_02_LENGTH (0xffffL<<0)
1275#define BNX2_DMA_RCHAN_STAT_02_WORD_SWAP (1L<<16)
1276#define BNX2_DMA_RCHAN_STAT_02_BYTE_SWAP (1L<<17)
1277#define BNX2_DMA_RCHAN_STAT_02_PRIORITY_LVL (1L<<18)
1278
1279#define BNX2_DMA_RCHAN_STAT_10 0x00000c4c
1280#define BNX2_DMA_RCHAN_STAT_11 0x00000c50
1281#define BNX2_DMA_RCHAN_STAT_12 0x00000c54
1282#define BNX2_DMA_RCHAN_STAT_20 0x00000c58
1283#define BNX2_DMA_RCHAN_STAT_21 0x00000c5c
1284#define BNX2_DMA_RCHAN_STAT_22 0x00000c60
1285#define BNX2_DMA_RCHAN_STAT_30 0x00000c64
1286#define BNX2_DMA_RCHAN_STAT_31 0x00000c68
1287#define BNX2_DMA_RCHAN_STAT_32 0x00000c6c
1288#define BNX2_DMA_RCHAN_STAT_40 0x00000c70
1289#define BNX2_DMA_RCHAN_STAT_41 0x00000c74
1290#define BNX2_DMA_RCHAN_STAT_42 0x00000c78
1291#define BNX2_DMA_RCHAN_STAT_50 0x00000c7c
1292#define BNX2_DMA_RCHAN_STAT_51 0x00000c80
1293#define BNX2_DMA_RCHAN_STAT_52 0x00000c84
1294#define BNX2_DMA_RCHAN_STAT_60 0x00000c88
1295#define BNX2_DMA_RCHAN_STAT_61 0x00000c8c
1296#define BNX2_DMA_RCHAN_STAT_62 0x00000c90
1297#define BNX2_DMA_RCHAN_STAT_70 0x00000c94
1298#define BNX2_DMA_RCHAN_STAT_71 0x00000c98
1299#define BNX2_DMA_RCHAN_STAT_72 0x00000c9c
1300#define BNX2_DMA_WCHAN_STAT_00 0x00000ca0
1301#define BNX2_DMA_WCHAN_STAT_00_WCHAN_STA_HOST_ADDR_LOW (0xffffffffL<<0)
1302
1303#define BNX2_DMA_WCHAN_STAT_01 0x00000ca4
1304#define BNX2_DMA_WCHAN_STAT_01_WCHAN_STA_HOST_ADDR_HIGH (0xffffffffL<<0)
1305
1306#define BNX2_DMA_WCHAN_STAT_02 0x00000ca8
1307#define BNX2_DMA_WCHAN_STAT_02_LENGTH (0xffffL<<0)
1308#define BNX2_DMA_WCHAN_STAT_02_WORD_SWAP (1L<<16)
1309#define BNX2_DMA_WCHAN_STAT_02_BYTE_SWAP (1L<<17)
1310#define BNX2_DMA_WCHAN_STAT_02_PRIORITY_LVL (1L<<18)
1311
1312#define BNX2_DMA_WCHAN_STAT_10 0x00000cac
1313#define BNX2_DMA_WCHAN_STAT_11 0x00000cb0
1314#define BNX2_DMA_WCHAN_STAT_12 0x00000cb4
1315#define BNX2_DMA_WCHAN_STAT_20 0x00000cb8
1316#define BNX2_DMA_WCHAN_STAT_21 0x00000cbc
1317#define BNX2_DMA_WCHAN_STAT_22 0x00000cc0
1318#define BNX2_DMA_WCHAN_STAT_30 0x00000cc4
1319#define BNX2_DMA_WCHAN_STAT_31 0x00000cc8
1320#define BNX2_DMA_WCHAN_STAT_32 0x00000ccc
1321#define BNX2_DMA_WCHAN_STAT_40 0x00000cd0
1322#define BNX2_DMA_WCHAN_STAT_41 0x00000cd4
1323#define BNX2_DMA_WCHAN_STAT_42 0x00000cd8
1324#define BNX2_DMA_WCHAN_STAT_50 0x00000cdc
1325#define BNX2_DMA_WCHAN_STAT_51 0x00000ce0
1326#define BNX2_DMA_WCHAN_STAT_52 0x00000ce4
1327#define BNX2_DMA_WCHAN_STAT_60 0x00000ce8
1328#define BNX2_DMA_WCHAN_STAT_61 0x00000cec
1329#define BNX2_DMA_WCHAN_STAT_62 0x00000cf0
1330#define BNX2_DMA_WCHAN_STAT_70 0x00000cf4
1331#define BNX2_DMA_WCHAN_STAT_71 0x00000cf8
1332#define BNX2_DMA_WCHAN_STAT_72 0x00000cfc
1333#define BNX2_DMA_ARB_STAT_00 0x00000d00
1334#define BNX2_DMA_ARB_STAT_00_MASTER (0xffffL<<0)
1335#define BNX2_DMA_ARB_STAT_00_MASTER_ENC (0xffL<<16)
1336#define BNX2_DMA_ARB_STAT_00_CUR_BINMSTR (0xffL<<24)
1337
1338#define BNX2_DMA_ARB_STAT_01 0x00000d04
1339#define BNX2_DMA_ARB_STAT_01_LPR_RPTR (0xfL<<0)
1340#define BNX2_DMA_ARB_STAT_01_LPR_WPTR (0xfL<<4)
1341#define BNX2_DMA_ARB_STAT_01_LPB_RPTR (0xfL<<8)
1342#define BNX2_DMA_ARB_STAT_01_LPB_WPTR (0xfL<<12)
1343#define BNX2_DMA_ARB_STAT_01_HPR_RPTR (0xfL<<16)
1344#define BNX2_DMA_ARB_STAT_01_HPR_WPTR (0xfL<<20)
1345#define BNX2_DMA_ARB_STAT_01_HPB_RPTR (0xfL<<24)
1346#define BNX2_DMA_ARB_STAT_01_HPB_WPTR (0xfL<<28)
1347
1348#define BNX2_DMA_FUSE_CTRL0_CMD 0x00000f00
1349#define BNX2_DMA_FUSE_CTRL0_CMD_PWRUP_DONE (1L<<0)
1350#define BNX2_DMA_FUSE_CTRL0_CMD_SHIFT_DONE (1L<<1)
1351#define BNX2_DMA_FUSE_CTRL0_CMD_SHIFT (1L<<2)
1352#define BNX2_DMA_FUSE_CTRL0_CMD_LOAD (1L<<3)
1353#define BNX2_DMA_FUSE_CTRL0_CMD_SEL (0xfL<<8)
1354
1355#define BNX2_DMA_FUSE_CTRL0_DATA 0x00000f04
1356#define BNX2_DMA_FUSE_CTRL1_CMD 0x00000f08
1357#define BNX2_DMA_FUSE_CTRL1_CMD_PWRUP_DONE (1L<<0)
1358#define BNX2_DMA_FUSE_CTRL1_CMD_SHIFT_DONE (1L<<1)
1359#define BNX2_DMA_FUSE_CTRL1_CMD_SHIFT (1L<<2)
1360#define BNX2_DMA_FUSE_CTRL1_CMD_LOAD (1L<<3)
1361#define BNX2_DMA_FUSE_CTRL1_CMD_SEL (0xfL<<8)
1362
1363#define BNX2_DMA_FUSE_CTRL1_DATA 0x00000f0c
1364#define BNX2_DMA_FUSE_CTRL2_CMD 0x00000f10
1365#define BNX2_DMA_FUSE_CTRL2_CMD_PWRUP_DONE (1L<<0)
1366#define BNX2_DMA_FUSE_CTRL2_CMD_SHIFT_DONE (1L<<1)
1367#define BNX2_DMA_FUSE_CTRL2_CMD_SHIFT (1L<<2)
1368#define BNX2_DMA_FUSE_CTRL2_CMD_LOAD (1L<<3)
1369#define BNX2_DMA_FUSE_CTRL2_CMD_SEL (0xfL<<8)
1370
1371#define BNX2_DMA_FUSE_CTRL2_DATA 0x00000f14
1372
1373
1374/*
1375 * context_reg definition
1376 * offset: 0x1000
1377 */
1378#define BNX2_CTX_COMMAND 0x00001000
1379#define BNX2_CTX_COMMAND_ENABLED (1L<<0)
1380
1381#define BNX2_CTX_STATUS 0x00001004
1382#define BNX2_CTX_STATUS_LOCK_WAIT (1L<<0)
1383#define BNX2_CTX_STATUS_READ_STAT (1L<<16)
1384#define BNX2_CTX_STATUS_WRITE_STAT (1L<<17)
1385#define BNX2_CTX_STATUS_ACC_STALL_STAT (1L<<18)
1386#define BNX2_CTX_STATUS_LOCK_STALL_STAT (1L<<19)
1387
1388#define BNX2_CTX_VIRT_ADDR 0x00001008
1389#define BNX2_CTX_VIRT_ADDR_VIRT_ADDR (0x7fffL<<6)
1390
1391#define BNX2_CTX_PAGE_TBL 0x0000100c
1392#define BNX2_CTX_PAGE_TBL_PAGE_TBL (0x3fffL<<6)
1393
1394#define BNX2_CTX_DATA_ADR 0x00001010
1395#define BNX2_CTX_DATA_ADR_DATA_ADR (0x7ffffL<<2)
1396
1397#define BNX2_CTX_DATA 0x00001014
1398#define BNX2_CTX_LOCK 0x00001018
1399#define BNX2_CTX_LOCK_TYPE (0x7L<<0)
1400#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_VOID (0x0L<<0)
1401#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_COMPLETE (0x7L<<0)
1402#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_PROTOCOL (0x1L<<0)
1403#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_TX (0x2L<<0)
1404#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_TIMER (0x4L<<0)
1405#define BNX2_CTX_LOCK_CID_VALUE (0x3fffL<<7)
1406#define BNX2_CTX_LOCK_GRANTED (1L<<26)
1407#define BNX2_CTX_LOCK_MODE (0x7L<<27)
1408#define BNX2_CTX_LOCK_MODE_UNLOCK (0x0L<<27)
1409#define BNX2_CTX_LOCK_MODE_IMMEDIATE (0x1L<<27)
1410#define BNX2_CTX_LOCK_MODE_SURE (0x2L<<27)
1411#define BNX2_CTX_LOCK_STATUS (1L<<30)
1412#define BNX2_CTX_LOCK_REQ (1L<<31)
1413
1414#define BNX2_CTX_ACCESS_STATUS 0x00001040
1415#define BNX2_CTX_ACCESS_STATUS_MASTERENCODED (0xfL<<0)
1416#define BNX2_CTX_ACCESS_STATUS_ACCESSMEMORYSM (0x3L<<10)
1417#define BNX2_CTX_ACCESS_STATUS_PAGETABLEINITSM (0x3L<<12)
1418#define BNX2_CTX_ACCESS_STATUS_ACCESSMEMORYINITSM (0x3L<<14)
1419#define BNX2_CTX_ACCESS_STATUS_QUALIFIED_REQUEST (0x7ffL<<17)
1420
1421#define BNX2_CTX_DBG_LOCK_STATUS 0x00001044
1422#define BNX2_CTX_DBG_LOCK_STATUS_SM (0x3ffL<<0)
1423#define BNX2_CTX_DBG_LOCK_STATUS_MATCH (0x3ffL<<22)
1424
1425#define BNX2_CTX_CHNL_LOCK_STATUS_0 0x00001080
1426#define BNX2_CTX_CHNL_LOCK_STATUS_0_CID (0x3fffL<<0)
1427#define BNX2_CTX_CHNL_LOCK_STATUS_0_TYPE (0x3L<<14)
1428#define BNX2_CTX_CHNL_LOCK_STATUS_0_MODE (1L<<16)
1429
1430#define BNX2_CTX_CHNL_LOCK_STATUS_1 0x00001084
1431#define BNX2_CTX_CHNL_LOCK_STATUS_2 0x00001088
1432#define BNX2_CTX_CHNL_LOCK_STATUS_3 0x0000108c
1433#define BNX2_CTX_CHNL_LOCK_STATUS_4 0x00001090
1434#define BNX2_CTX_CHNL_LOCK_STATUS_5 0x00001094
1435#define BNX2_CTX_CHNL_LOCK_STATUS_6 0x00001098
1436#define BNX2_CTX_CHNL_LOCK_STATUS_7 0x0000109c
1437#define BNX2_CTX_CHNL_LOCK_STATUS_8 0x000010a0
1438
1439
1440/*
1441 * emac_reg definition
1442 * offset: 0x1400
1443 */
1444#define BNX2_EMAC_MODE 0x00001400
1445#define BNX2_EMAC_MODE_RESET (1L<<0)
1446#define BNX2_EMAC_MODE_HALF_DUPLEX (1L<<1)
1447#define BNX2_EMAC_MODE_PORT (0x3L<<2)
1448#define BNX2_EMAC_MODE_PORT_NONE (0L<<2)
1449#define BNX2_EMAC_MODE_PORT_MII (1L<<2)
1450#define BNX2_EMAC_MODE_PORT_GMII (2L<<2)
1451#define BNX2_EMAC_MODE_PORT_UNDEF (3L<<2)
1452#define BNX2_EMAC_MODE_MAC_LOOP (1L<<4)
1453#define BNX2_EMAC_MODE_TAGGED_MAC_CTL (1L<<7)
1454#define BNX2_EMAC_MODE_TX_BURST (1L<<8)
1455#define BNX2_EMAC_MODE_MAX_DEFER_DROP_ENA (1L<<9)
1456#define BNX2_EMAC_MODE_EXT_LINK_POL (1L<<10)
1457#define BNX2_EMAC_MODE_FORCE_LINK (1L<<11)
1458#define BNX2_EMAC_MODE_MPKT (1L<<18)
1459#define BNX2_EMAC_MODE_MPKT_RCVD (1L<<19)
1460#define BNX2_EMAC_MODE_ACPI_RCVD (1L<<20)
1461
1462#define BNX2_EMAC_STATUS 0x00001404
1463#define BNX2_EMAC_STATUS_LINK (1L<<11)
1464#define BNX2_EMAC_STATUS_LINK_CHANGE (1L<<12)
1465#define BNX2_EMAC_STATUS_MI_COMPLETE (1L<<22)
1466#define BNX2_EMAC_STATUS_MI_INT (1L<<23)
1467#define BNX2_EMAC_STATUS_AP_ERROR (1L<<24)
1468#define BNX2_EMAC_STATUS_PARITY_ERROR_STATE (1L<<31)
1469
1470#define BNX2_EMAC_ATTENTION_ENA 0x00001408
1471#define BNX2_EMAC_ATTENTION_ENA_LINK (1L<<11)
1472#define BNX2_EMAC_ATTENTION_ENA_MI_COMPLETE (1L<<22)
1473#define BNX2_EMAC_ATTENTION_ENA_MI_INT (1L<<23)
1474#define BNX2_EMAC_ATTENTION_ENA_AP_ERROR (1L<<24)
1475
1476#define BNX2_EMAC_LED 0x0000140c
1477#define BNX2_EMAC_LED_OVERRIDE (1L<<0)
1478#define BNX2_EMAC_LED_1000MB_OVERRIDE (1L<<1)
1479#define BNX2_EMAC_LED_100MB_OVERRIDE (1L<<2)
1480#define BNX2_EMAC_LED_10MB_OVERRIDE (1L<<3)
1481#define BNX2_EMAC_LED_TRAFFIC_OVERRIDE (1L<<4)
1482#define BNX2_EMAC_LED_BLNK_TRAFFIC (1L<<5)
1483#define BNX2_EMAC_LED_TRAFFIC (1L<<6)
1484#define BNX2_EMAC_LED_1000MB (1L<<7)
1485#define BNX2_EMAC_LED_100MB (1L<<8)
1486#define BNX2_EMAC_LED_10MB (1L<<9)
1487#define BNX2_EMAC_LED_TRAFFIC_STAT (1L<<10)
1488#define BNX2_EMAC_LED_BLNK_RATE (0xfffL<<19)
1489#define BNX2_EMAC_LED_BLNK_RATE_ENA (1L<<31)
1490
1491#define BNX2_EMAC_MAC_MATCH0 0x00001410
1492#define BNX2_EMAC_MAC_MATCH1 0x00001414
1493#define BNX2_EMAC_MAC_MATCH2 0x00001418
1494#define BNX2_EMAC_MAC_MATCH3 0x0000141c
1495#define BNX2_EMAC_MAC_MATCH4 0x00001420
1496#define BNX2_EMAC_MAC_MATCH5 0x00001424
1497#define BNX2_EMAC_MAC_MATCH6 0x00001428
1498#define BNX2_EMAC_MAC_MATCH7 0x0000142c
1499#define BNX2_EMAC_MAC_MATCH8 0x00001430
1500#define BNX2_EMAC_MAC_MATCH9 0x00001434
1501#define BNX2_EMAC_MAC_MATCH10 0x00001438
1502#define BNX2_EMAC_MAC_MATCH11 0x0000143c
1503#define BNX2_EMAC_MAC_MATCH12 0x00001440
1504#define BNX2_EMAC_MAC_MATCH13 0x00001444
1505#define BNX2_EMAC_MAC_MATCH14 0x00001448
1506#define BNX2_EMAC_MAC_MATCH15 0x0000144c
1507#define BNX2_EMAC_MAC_MATCH16 0x00001450
1508#define BNX2_EMAC_MAC_MATCH17 0x00001454
1509#define BNX2_EMAC_MAC_MATCH18 0x00001458
1510#define BNX2_EMAC_MAC_MATCH19 0x0000145c
1511#define BNX2_EMAC_MAC_MATCH20 0x00001460
1512#define BNX2_EMAC_MAC_MATCH21 0x00001464
1513#define BNX2_EMAC_MAC_MATCH22 0x00001468
1514#define BNX2_EMAC_MAC_MATCH23 0x0000146c
1515#define BNX2_EMAC_MAC_MATCH24 0x00001470
1516#define BNX2_EMAC_MAC_MATCH25 0x00001474
1517#define BNX2_EMAC_MAC_MATCH26 0x00001478
1518#define BNX2_EMAC_MAC_MATCH27 0x0000147c
1519#define BNX2_EMAC_MAC_MATCH28 0x00001480
1520#define BNX2_EMAC_MAC_MATCH29 0x00001484
1521#define BNX2_EMAC_MAC_MATCH30 0x00001488
1522#define BNX2_EMAC_MAC_MATCH31 0x0000148c
1523#define BNX2_EMAC_BACKOFF_SEED 0x00001498
1524#define BNX2_EMAC_BACKOFF_SEED_EMAC_BACKOFF_SEED (0x3ffL<<0)
1525
1526#define BNX2_EMAC_RX_MTU_SIZE 0x0000149c
1527#define BNX2_EMAC_RX_MTU_SIZE_MTU_SIZE (0xffffL<<0)
1528#define BNX2_EMAC_RX_MTU_SIZE_JUMBO_ENA (1L<<31)
1529
1530#define BNX2_EMAC_SERDES_CNTL 0x000014a4
1531#define BNX2_EMAC_SERDES_CNTL_RXR (0x7L<<0)
1532#define BNX2_EMAC_SERDES_CNTL_RXG (0x3L<<3)
1533#define BNX2_EMAC_SERDES_CNTL_RXCKSEL (1L<<6)
1534#define BNX2_EMAC_SERDES_CNTL_TXBIAS (0x7L<<7)
1535#define BNX2_EMAC_SERDES_CNTL_BGMAX (1L<<10)
1536#define BNX2_EMAC_SERDES_CNTL_BGMIN (1L<<11)
1537#define BNX2_EMAC_SERDES_CNTL_TXMODE (1L<<12)
1538#define BNX2_EMAC_SERDES_CNTL_TXEDGE (1L<<13)
1539#define BNX2_EMAC_SERDES_CNTL_SERDES_MODE (1L<<14)
1540#define BNX2_EMAC_SERDES_CNTL_PLLTEST (1L<<15)
1541#define BNX2_EMAC_SERDES_CNTL_CDET_EN (1L<<16)
1542#define BNX2_EMAC_SERDES_CNTL_TBI_LBK (1L<<17)
1543#define BNX2_EMAC_SERDES_CNTL_REMOTE_LBK (1L<<18)
1544#define BNX2_EMAC_SERDES_CNTL_REV_PHASE (1L<<19)
1545#define BNX2_EMAC_SERDES_CNTL_REGCTL12 (0x3L<<20)
1546#define BNX2_EMAC_SERDES_CNTL_REGCTL25 (0x3L<<22)
1547
1548#define BNX2_EMAC_SERDES_STATUS 0x000014a8
1549#define BNX2_EMAC_SERDES_STATUS_RX_STAT (0xffL<<0)
1550#define BNX2_EMAC_SERDES_STATUS_COMMA_DET (1L<<8)
1551
1552#define BNX2_EMAC_MDIO_COMM 0x000014ac
1553#define BNX2_EMAC_MDIO_COMM_DATA (0xffffL<<0)
1554#define BNX2_EMAC_MDIO_COMM_REG_ADDR (0x1fL<<16)
1555#define BNX2_EMAC_MDIO_COMM_PHY_ADDR (0x1fL<<21)
1556#define BNX2_EMAC_MDIO_COMM_COMMAND (0x3L<<26)
1557#define BNX2_EMAC_MDIO_COMM_COMMAND_UNDEFINED_0 (0L<<26)
1558#define BNX2_EMAC_MDIO_COMM_COMMAND_WRITE (1L<<26)
1559#define BNX2_EMAC_MDIO_COMM_COMMAND_READ (2L<<26)
1560#define BNX2_EMAC_MDIO_COMM_COMMAND_UNDEFINED_3 (3L<<26)
1561#define BNX2_EMAC_MDIO_COMM_FAIL (1L<<28)
1562#define BNX2_EMAC_MDIO_COMM_START_BUSY (1L<<29)
1563#define BNX2_EMAC_MDIO_COMM_DISEXT (1L<<30)
1564
1565#define BNX2_EMAC_MDIO_STATUS 0x000014b0
1566#define BNX2_EMAC_MDIO_STATUS_LINK (1L<<0)
1567#define BNX2_EMAC_MDIO_STATUS_10MB (1L<<1)
1568
1569#define BNX2_EMAC_MDIO_MODE 0x000014b4
1570#define BNX2_EMAC_MDIO_MODE_SHORT_PREAMBLE (1L<<1)
1571#define BNX2_EMAC_MDIO_MODE_AUTO_POLL (1L<<4)
1572#define BNX2_EMAC_MDIO_MODE_BIT_BANG (1L<<8)
1573#define BNX2_EMAC_MDIO_MODE_MDIO (1L<<9)
1574#define BNX2_EMAC_MDIO_MODE_MDIO_OE (1L<<10)
1575#define BNX2_EMAC_MDIO_MODE_MDC (1L<<11)
1576#define BNX2_EMAC_MDIO_MODE_MDINT (1L<<12)
1577#define BNX2_EMAC_MDIO_MODE_CLOCK_CNT (0x1fL<<16)
1578
1579#define BNX2_EMAC_MDIO_AUTO_STATUS 0x000014b8
1580#define BNX2_EMAC_MDIO_AUTO_STATUS_AUTO_ERR (1L<<0)
1581
1582#define BNX2_EMAC_TX_MODE 0x000014bc
1583#define BNX2_EMAC_TX_MODE_RESET (1L<<0)
1584#define BNX2_EMAC_TX_MODE_EXT_PAUSE_EN (1L<<3)
1585#define BNX2_EMAC_TX_MODE_FLOW_EN (1L<<4)
1586#define BNX2_EMAC_TX_MODE_BIG_BACKOFF (1L<<5)
1587#define BNX2_EMAC_TX_MODE_LONG_PAUSE (1L<<6)
1588#define BNX2_EMAC_TX_MODE_LINK_AWARE (1L<<7)
1589
1590#define BNX2_EMAC_TX_STATUS 0x000014c0
1591#define BNX2_EMAC_TX_STATUS_XOFFED (1L<<0)
1592#define BNX2_EMAC_TX_STATUS_XOFF_SENT (1L<<1)
1593#define BNX2_EMAC_TX_STATUS_XON_SENT (1L<<2)
1594#define BNX2_EMAC_TX_STATUS_LINK_UP (1L<<3)
1595#define BNX2_EMAC_TX_STATUS_UNDERRUN (1L<<4)
1596
1597#define BNX2_EMAC_TX_LENGTHS 0x000014c4
1598#define BNX2_EMAC_TX_LENGTHS_SLOT (0xffL<<0)
1599#define BNX2_EMAC_TX_LENGTHS_IPG (0xfL<<8)
1600#define BNX2_EMAC_TX_LENGTHS_IPG_CRS (0x3L<<12)
1601
1602#define BNX2_EMAC_RX_MODE 0x000014c8
1603#define BNX2_EMAC_RX_MODE_RESET (1L<<0)
1604#define BNX2_EMAC_RX_MODE_FLOW_EN (1L<<2)
1605#define BNX2_EMAC_RX_MODE_KEEP_MAC_CONTROL (1L<<3)
1606#define BNX2_EMAC_RX_MODE_KEEP_PAUSE (1L<<4)
1607#define BNX2_EMAC_RX_MODE_ACCEPT_OVERSIZE (1L<<5)
1608#define BNX2_EMAC_RX_MODE_ACCEPT_RUNTS (1L<<6)
1609#define BNX2_EMAC_RX_MODE_LLC_CHK (1L<<7)
1610#define BNX2_EMAC_RX_MODE_PROMISCUOUS (1L<<8)
1611#define BNX2_EMAC_RX_MODE_NO_CRC_CHK (1L<<9)
1612#define BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG (1L<<10)
1613#define BNX2_EMAC_RX_MODE_FILT_BROADCAST (1L<<11)
1614#define BNX2_EMAC_RX_MODE_SORT_MODE (1L<<12)
1615
1616#define BNX2_EMAC_RX_STATUS 0x000014cc
1617#define BNX2_EMAC_RX_STATUS_FFED (1L<<0)
1618#define BNX2_EMAC_RX_STATUS_FF_RECEIVED (1L<<1)
1619#define BNX2_EMAC_RX_STATUS_N_RECEIVED (1L<<2)
1620
1621#define BNX2_EMAC_MULTICAST_HASH0 0x000014d0
1622#define BNX2_EMAC_MULTICAST_HASH1 0x000014d4
1623#define BNX2_EMAC_MULTICAST_HASH2 0x000014d8
1624#define BNX2_EMAC_MULTICAST_HASH3 0x000014dc
1625#define BNX2_EMAC_MULTICAST_HASH4 0x000014e0
1626#define BNX2_EMAC_MULTICAST_HASH5 0x000014e4
1627#define BNX2_EMAC_MULTICAST_HASH6 0x000014e8
1628#define BNX2_EMAC_MULTICAST_HASH7 0x000014ec
1629#define BNX2_EMAC_RX_STAT_IFHCINOCTETS 0x00001500
1630#define BNX2_EMAC_RX_STAT_IFHCINBADOCTETS 0x00001504
1631#define BNX2_EMAC_RX_STAT_ETHERSTATSFRAGMENTS 0x00001508
1632#define BNX2_EMAC_RX_STAT_IFHCINUCASTPKTS 0x0000150c
1633#define BNX2_EMAC_RX_STAT_IFHCINMULTICASTPKTS 0x00001510
1634#define BNX2_EMAC_RX_STAT_IFHCINBROADCASTPKTS 0x00001514
1635#define BNX2_EMAC_RX_STAT_DOT3STATSFCSERRORS 0x00001518
1636#define BNX2_EMAC_RX_STAT_DOT3STATSALIGNMENTERRORS 0x0000151c
1637#define BNX2_EMAC_RX_STAT_DOT3STATSCARRIERSENSEERRORS 0x00001520
1638#define BNX2_EMAC_RX_STAT_XONPAUSEFRAMESRECEIVED 0x00001524
1639#define BNX2_EMAC_RX_STAT_XOFFPAUSEFRAMESRECEIVED 0x00001528
1640#define BNX2_EMAC_RX_STAT_MACCONTROLFRAMESRECEIVED 0x0000152c
1641#define BNX2_EMAC_RX_STAT_XOFFSTATEENTERED 0x00001530
1642#define BNX2_EMAC_RX_STAT_DOT3STATSFRAMESTOOLONG 0x00001534
1643#define BNX2_EMAC_RX_STAT_ETHERSTATSJABBERS 0x00001538
1644#define BNX2_EMAC_RX_STAT_ETHERSTATSUNDERSIZEPKTS 0x0000153c
1645#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS64OCTETS 0x00001540
1646#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS65OCTETSTO127OCTETS 0x00001544
1647#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS128OCTETSTO255OCTETS 0x00001548
1648#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS256OCTETSTO511OCTETS 0x0000154c
1649#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS512OCTETSTO1023OCTETS 0x00001550
1650#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS1024OCTETSTO1522OCTETS 0x00001554
1651#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS1523OCTETSTO9022OCTETS 0x00001558
1652#define BNX2_EMAC_RXMAC_DEBUG0 0x0000155c
1653#define BNX2_EMAC_RXMAC_DEBUG1 0x00001560
1654#define BNX2_EMAC_RXMAC_DEBUG1_LENGTH_NE_BYTE_COUNT (1L<<0)
1655#define BNX2_EMAC_RXMAC_DEBUG1_LENGTH_OUT_RANGE (1L<<1)
1656#define BNX2_EMAC_RXMAC_DEBUG1_BAD_CRC (1L<<2)
1657#define BNX2_EMAC_RXMAC_DEBUG1_RX_ERROR (1L<<3)
1658#define BNX2_EMAC_RXMAC_DEBUG1_ALIGN_ERROR (1L<<4)
1659#define BNX2_EMAC_RXMAC_DEBUG1_LAST_DATA (1L<<5)
1660#define BNX2_EMAC_RXMAC_DEBUG1_ODD_BYTE_START (1L<<6)
1661#define BNX2_EMAC_RXMAC_DEBUG1_BYTE_COUNT (0xffffL<<7)
1662#define BNX2_EMAC_RXMAC_DEBUG1_SLOT_TIME (0xffL<<23)
1663
1664#define BNX2_EMAC_RXMAC_DEBUG2 0x00001564
1665#define BNX2_EMAC_RXMAC_DEBUG2_SM_STATE (0x7L<<0)
1666#define BNX2_EMAC_RXMAC_DEBUG2_SM_STATE_IDLE (0x0L<<0)
1667#define BNX2_EMAC_RXMAC_DEBUG2_SM_STATE_SFD (0x1L<<0)
1668#define BNX2_EMAC_RXMAC_DEBUG2_SM_STATE_DATA (0x2L<<0)
1669#define BNX2_EMAC_RXMAC_DEBUG2_SM_STATE_SKEEP (0x3L<<0)
1670#define BNX2_EMAC_RXMAC_DEBUG2_SM_STATE_EXT (0x4L<<0)
1671#define BNX2_EMAC_RXMAC_DEBUG2_SM_STATE_DROP (0x5L<<0)
1672#define BNX2_EMAC_RXMAC_DEBUG2_SM_STATE_SDROP (0x6L<<0)
1673#define BNX2_EMAC_RXMAC_DEBUG2_SM_STATE_FC (0x7L<<0)
1674#define BNX2_EMAC_RXMAC_DEBUG2_IDI_STATE (0xfL<<3)
1675#define BNX2_EMAC_RXMAC_DEBUG2_IDI_STATE_IDLE (0x0L<<3)
1676#define BNX2_EMAC_RXMAC_DEBUG2_IDI_STATE_DATA0 (0x1L<<3)
1677#define BNX2_EMAC_RXMAC_DEBUG2_IDI_STATE_DATA1 (0x2L<<3)
1678#define BNX2_EMAC_RXMAC_DEBUG2_IDI_STATE_DATA2 (0x3L<<3)
1679#define BNX2_EMAC_RXMAC_DEBUG2_IDI_STATE_DATA3 (0x4L<<3)
1680#define BNX2_EMAC_RXMAC_DEBUG2_IDI_STATE_ABORT (0x5L<<3)
1681#define BNX2_EMAC_RXMAC_DEBUG2_IDI_STATE_WAIT (0x6L<<3)
1682#define BNX2_EMAC_RXMAC_DEBUG2_IDI_STATE_STATUS (0x7L<<3)
1683#define BNX2_EMAC_RXMAC_DEBUG2_IDI_STATE_LAST (0x8L<<3)
1684#define BNX2_EMAC_RXMAC_DEBUG2_BYTE_IN (0xffL<<7)
1685#define BNX2_EMAC_RXMAC_DEBUG2_FALSEC (1L<<15)
1686#define BNX2_EMAC_RXMAC_DEBUG2_TAGGED (1L<<16)
1687#define BNX2_EMAC_RXMAC_DEBUG2_PAUSE_STATE (1L<<18)
1688#define BNX2_EMAC_RXMAC_DEBUG2_PAUSE_STATE_IDLE (0L<<18)
1689#define BNX2_EMAC_RXMAC_DEBUG2_PAUSE_STATE_PAUSED (1L<<18)
1690#define BNX2_EMAC_RXMAC_DEBUG2_SE_COUNTER (0xfL<<19)
1691#define BNX2_EMAC_RXMAC_DEBUG2_QUANTA (0x1fL<<23)
1692
1693#define BNX2_EMAC_RXMAC_DEBUG3 0x00001568
1694#define BNX2_EMAC_RXMAC_DEBUG3_PAUSE_CTR (0xffffL<<0)
1695#define BNX2_EMAC_RXMAC_DEBUG3_TMP_PAUSE_CTR (0xffffL<<16)
1696
1697#define BNX2_EMAC_RXMAC_DEBUG4 0x0000156c
1698#define BNX2_EMAC_RXMAC_DEBUG4_TYPE_FIELD (0xffffL<<0)
1699#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE (0x3fL<<16)
1700#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_IDLE (0x0L<<16)
1701#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UMAC2 (0x1L<<16)
1702#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UMAC3 (0x2L<<16)
1703#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UNI (0x3L<<16)
1704#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MMAC2 (0x7L<<16)
1705#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MMAC3 (0x5L<<16)
1706#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA1 (0x6L<<16)
1707#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA2 (0x7L<<16)
1708#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA3 (0x8L<<16)
1709#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MC2 (0x9L<<16)
1710#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MC3 (0xaL<<16)
1711#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MWAIT1 (0xeL<<16)
1712#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MWAIT2 (0xfL<<16)
1713#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MCHECK (0x10L<<16)
1714#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MC (0x11L<<16)
1715#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_BC2 (0x12L<<16)
1716#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_BC3 (0x13L<<16)
1717#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_BSA1 (0x14L<<16)
1718#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_BSA2 (0x15L<<16)
1719#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_BSA3 (0x16L<<16)
1720#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_BTYPE (0x17L<<16)
1721#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_BC (0x18L<<16)
1722#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PTYPE (0x19L<<16)
1723#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_CMD (0x1aL<<16)
1724#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MAC (0x1bL<<16)
1725#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_LATCH (0x1cL<<16)
1726#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_XOFF (0x1dL<<16)
1727#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_XON (0x1eL<<16)
1728#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PAUSED (0x1fL<<16)
1729#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_NPAUSED (0x20L<<16)
1730#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_TTYPE (0x21L<<16)
1731#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_TVAL (0x22L<<16)
1732#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_USA1 (0x23L<<16)
1733#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_USA2 (0x24L<<16)
1734#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_USA3 (0x25L<<16)
1735#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UTYPE (0x26L<<16)
1736#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UTTYPE (0x27L<<16)
1737#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UTVAL (0x28L<<16)
1738#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MTYPE (0x29L<<16)
1739#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_DROP (0x2aL<<16)
1740#define BNX2_EMAC_RXMAC_DEBUG4_DROP_PKT (1L<<22)
1741#define BNX2_EMAC_RXMAC_DEBUG4_SLOT_FILLED (1L<<23)
1742#define BNX2_EMAC_RXMAC_DEBUG4_FALSE_CARRIER (1L<<24)
1743#define BNX2_EMAC_RXMAC_DEBUG4_LAST_DATA (1L<<25)
1744#define BNX2_EMAC_RXMAC_DEBUG4_sfd_FOUND (1L<<26)
1745#define BNX2_EMAC_RXMAC_DEBUG4_ADVANCE (1L<<27)
1746#define BNX2_EMAC_RXMAC_DEBUG4_START (1L<<28)
1747
1748#define BNX2_EMAC_RXMAC_DEBUG5 0x00001570
1749#define BNX2_EMAC_RXMAC_DEBUG5_PS_IDISM (0x7L<<0)
1750#define BNX2_EMAC_RXMAC_DEBUG5_PS_IDISM_IDLE (0L<<0)
1751#define BNX2_EMAC_RXMAC_DEBUG5_PS_IDISM_WAIT_EOF (1L<<0)
1752#define BNX2_EMAC_RXMAC_DEBUG5_PS_IDISM_WAIT_STAT (2L<<0)
1753#define BNX2_EMAC_RXMAC_DEBUG5_PS_IDISM_SET_EOF4FCRC (3L<<0)
1754#define BNX2_EMAC_RXMAC_DEBUG5_PS_IDISM_SET_EOF4RDE (4L<<0)
1755#define BNX2_EMAC_RXMAC_DEBUG5_PS_IDISM_SET_EOF4ALL (5L<<0)
1756#define BNX2_EMAC_RXMAC_DEBUG5_PS_IDISM_1WD_WAIT_STAT (6L<<0)
1757#define BNX2_EMAC_RXMAC_DEBUG5_CCODE_BUF1 (0x7L<<4)
1758#define BNX2_EMAC_RXMAC_DEBUG5_CCODE_BUF1_VDW (0x0L<<4)
1759#define BNX2_EMAC_RXMAC_DEBUG5_CCODE_BUF1_STAT (0x1L<<4)
1760#define BNX2_EMAC_RXMAC_DEBUG5_CCODE_BUF1_AEOF (0x2L<<4)
1761#define BNX2_EMAC_RXMAC_DEBUG5_CCODE_BUF1_NEOF (0x3L<<4)
1762#define BNX2_EMAC_RXMAC_DEBUG5_CCODE_BUF1_SOF (0x4L<<4)
1763#define BNX2_EMAC_RXMAC_DEBUG5_CCODE_BUF1_SAEOF (0x6L<<4)
1764#define BNX2_EMAC_RXMAC_DEBUG5_CCODE_BUF1_SNEOF (0x7L<<4)
1765#define BNX2_EMAC_RXMAC_DEBUG5_EOF_DETECTED (1L<<7)
1766#define BNX2_EMAC_RXMAC_DEBUG5_CCODE_BUF0 (0x7L<<8)
1767#define BNX2_EMAC_RXMAC_DEBUG5_RPM_IDI_FIFO_FULL (1L<<11)
1768#define BNX2_EMAC_RXMAC_DEBUG5_LOAD_CCODE (1L<<12)
1769#define BNX2_EMAC_RXMAC_DEBUG5_LOAD_DATA (1L<<13)
1770#define BNX2_EMAC_RXMAC_DEBUG5_LOAD_STAT (1L<<14)
1771#define BNX2_EMAC_RXMAC_DEBUG5_CLR_STAT (1L<<15)
1772#define BNX2_EMAC_RXMAC_DEBUG5_IDI_RPM_CCODE (0x3L<<16)
1773#define BNX2_EMAC_RXMAC_DEBUG5_IDI_RPM_ACCEPT (1L<<19)
1774#define BNX2_EMAC_RXMAC_DEBUG5_FMLEN (0xfffL<<20)
1775
1776#define BNX2_EMAC_RX_STAT_AC0 0x00001580
1777#define BNX2_EMAC_RX_STAT_AC1 0x00001584
1778#define BNX2_EMAC_RX_STAT_AC2 0x00001588
1779#define BNX2_EMAC_RX_STAT_AC3 0x0000158c
1780#define BNX2_EMAC_RX_STAT_AC4 0x00001590
1781#define BNX2_EMAC_RX_STAT_AC5 0x00001594
1782#define BNX2_EMAC_RX_STAT_AC6 0x00001598
1783#define BNX2_EMAC_RX_STAT_AC7 0x0000159c
1784#define BNX2_EMAC_RX_STAT_AC8 0x000015a0
1785#define BNX2_EMAC_RX_STAT_AC9 0x000015a4
1786#define BNX2_EMAC_RX_STAT_AC10 0x000015a8
1787#define BNX2_EMAC_RX_STAT_AC11 0x000015ac
1788#define BNX2_EMAC_RX_STAT_AC12 0x000015b0
1789#define BNX2_EMAC_RX_STAT_AC13 0x000015b4
1790#define BNX2_EMAC_RX_STAT_AC14 0x000015b8
1791#define BNX2_EMAC_RX_STAT_AC15 0x000015bc
1792#define BNX2_EMAC_RX_STAT_AC16 0x000015c0
1793#define BNX2_EMAC_RX_STAT_AC17 0x000015c4
1794#define BNX2_EMAC_RX_STAT_AC18 0x000015c8
1795#define BNX2_EMAC_RX_STAT_AC19 0x000015cc
1796#define BNX2_EMAC_RX_STAT_AC20 0x000015d0
1797#define BNX2_EMAC_RX_STAT_AC21 0x000015d4
1798#define BNX2_EMAC_RX_STAT_AC22 0x000015d8
1799#define BNX2_EMAC_RXMAC_SUC_DBG_OVERRUNVEC 0x000015dc
1800#define BNX2_EMAC_TX_STAT_IFHCOUTOCTETS 0x00001600
1801#define BNX2_EMAC_TX_STAT_IFHCOUTBADOCTETS 0x00001604
1802#define BNX2_EMAC_TX_STAT_ETHERSTATSCOLLISIONS 0x00001608
1803#define BNX2_EMAC_TX_STAT_OUTXONSENT 0x0000160c
1804#define BNX2_EMAC_TX_STAT_OUTXOFFSENT 0x00001610
1805#define BNX2_EMAC_TX_STAT_FLOWCONTROLDONE 0x00001614
1806#define BNX2_EMAC_TX_STAT_DOT3STATSSINGLECOLLISIONFRAMES 0x00001618
1807#define BNX2_EMAC_TX_STAT_DOT3STATSMULTIPLECOLLISIONFRAMES 0x0000161c
1808#define BNX2_EMAC_TX_STAT_DOT3STATSDEFERREDTRANSMISSIONS 0x00001620
1809#define BNX2_EMAC_TX_STAT_DOT3STATSEXCESSIVECOLLISIONS 0x00001624
1810#define BNX2_EMAC_TX_STAT_DOT3STATSLATECOLLISIONS 0x00001628
1811#define BNX2_EMAC_TX_STAT_IFHCOUTUCASTPKTS 0x0000162c
1812#define BNX2_EMAC_TX_STAT_IFHCOUTMULTICASTPKTS 0x00001630
1813#define BNX2_EMAC_TX_STAT_IFHCOUTBROADCASTPKTS 0x00001634
1814#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS64OCTETS 0x00001638
1815#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS65OCTETSTO127OCTETS 0x0000163c
1816#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS128OCTETSTO255OCTETS 0x00001640
1817#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS256OCTETSTO511OCTETS 0x00001644
1818#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS512OCTETSTO1023OCTETS 0x00001648
1819#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS1024OCTETSTO1522OCTETS 0x0000164c
1820#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS1523OCTETSTO9022OCTETS 0x00001650
1821#define BNX2_EMAC_TX_STAT_DOT3STATSINTERNALMACTRANSMITERRORS 0x00001654
1822#define BNX2_EMAC_TXMAC_DEBUG0 0x00001658
1823#define BNX2_EMAC_TXMAC_DEBUG1 0x0000165c
1824#define BNX2_EMAC_TXMAC_DEBUG1_ODI_STATE (0xfL<<0)
1825#define BNX2_EMAC_TXMAC_DEBUG1_ODI_STATE_IDLE (0x0L<<0)
1826#define BNX2_EMAC_TXMAC_DEBUG1_ODI_STATE_START0 (0x1L<<0)
1827#define BNX2_EMAC_TXMAC_DEBUG1_ODI_STATE_DATA0 (0x4L<<0)
1828#define BNX2_EMAC_TXMAC_DEBUG1_ODI_STATE_DATA1 (0x5L<<0)
1829#define BNX2_EMAC_TXMAC_DEBUG1_ODI_STATE_DATA2 (0x6L<<0)
1830#define BNX2_EMAC_TXMAC_DEBUG1_ODI_STATE_DATA3 (0x7L<<0)
1831#define BNX2_EMAC_TXMAC_DEBUG1_ODI_STATE_WAIT0 (0x8L<<0)
1832#define BNX2_EMAC_TXMAC_DEBUG1_ODI_STATE_WAIT1 (0x9L<<0)
1833#define BNX2_EMAC_TXMAC_DEBUG1_CRS_ENABLE (1L<<4)
1834#define BNX2_EMAC_TXMAC_DEBUG1_BAD_CRC (1L<<5)
1835#define BNX2_EMAC_TXMAC_DEBUG1_SE_COUNTER (0xfL<<6)
1836#define BNX2_EMAC_TXMAC_DEBUG1_SEND_PAUSE (1L<<10)
1837#define BNX2_EMAC_TXMAC_DEBUG1_LATE_COLLISION (1L<<11)
1838#define BNX2_EMAC_TXMAC_DEBUG1_MAX_DEFER (1L<<12)
1839#define BNX2_EMAC_TXMAC_DEBUG1_DEFERRED (1L<<13)
1840#define BNX2_EMAC_TXMAC_DEBUG1_ONE_BYTE (1L<<14)
1841#define BNX2_EMAC_TXMAC_DEBUG1_IPG_TIME (0xfL<<15)
1842#define BNX2_EMAC_TXMAC_DEBUG1_SLOT_TIME (0xffL<<19)
1843
1844#define BNX2_EMAC_TXMAC_DEBUG2 0x00001660
1845#define BNX2_EMAC_TXMAC_DEBUG2_BACK_OFF (0x3ffL<<0)
1846#define BNX2_EMAC_TXMAC_DEBUG2_BYTE_COUNT (0xffffL<<10)
1847#define BNX2_EMAC_TXMAC_DEBUG2_COL_COUNT (0x1fL<<26)
1848#define BNX2_EMAC_TXMAC_DEBUG2_COL_BIT (1L<<31)
1849
1850#define BNX2_EMAC_TXMAC_DEBUG3 0x00001664
1851#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE (0xfL<<0)
1852#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_IDLE (0x0L<<0)
1853#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_PRE1 (0x1L<<0)
1854#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_PRE2 (0x2L<<0)
1855#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_SFD (0x3L<<0)
1856#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_DATA (0x4L<<0)
1857#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_CRC1 (0x5L<<0)
1858#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_CRC2 (0x6L<<0)
1859#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_EXT (0x7L<<0)
1860#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_STATB (0x8L<<0)
1861#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_STATG (0x9L<<0)
1862#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_JAM (0xaL<<0)
1863#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_EJAM (0xbL<<0)
1864#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_BJAM (0xcL<<0)
1865#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_SWAIT (0xdL<<0)
1866#define BNX2_EMAC_TXMAC_DEBUG3_SM_STATE_BACKOFF (0xeL<<0)
1867#define BNX2_EMAC_TXMAC_DEBUG3_FILT_STATE (0x7L<<4)
1868#define BNX2_EMAC_TXMAC_DEBUG3_FILT_STATE_IDLE (0x0L<<4)
1869#define BNX2_EMAC_TXMAC_DEBUG3_FILT_STATE_WAIT (0x1L<<4)
1870#define BNX2_EMAC_TXMAC_DEBUG3_FILT_STATE_UNI (0x2L<<4)
1871#define BNX2_EMAC_TXMAC_DEBUG3_FILT_STATE_MC (0x3L<<4)
1872#define BNX2_EMAC_TXMAC_DEBUG3_FILT_STATE_BC2 (0x4L<<4)
1873#define BNX2_EMAC_TXMAC_DEBUG3_FILT_STATE_BC3 (0x5L<<4)
1874#define BNX2_EMAC_TXMAC_DEBUG3_FILT_STATE_BC (0x6L<<4)
1875#define BNX2_EMAC_TXMAC_DEBUG3_CRS_DONE (1L<<7)
1876#define BNX2_EMAC_TXMAC_DEBUG3_XOFF (1L<<8)
1877#define BNX2_EMAC_TXMAC_DEBUG3_SE_COUNTER (0xfL<<9)
1878#define BNX2_EMAC_TXMAC_DEBUG3_QUANTA_COUNTER (0x1fL<<13)
1879
1880#define BNX2_EMAC_TXMAC_DEBUG4 0x00001668
1881#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_COUNTER (0xffffL<<0)
1882#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE (0xfL<<16)
1883#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_IDLE (0x0L<<16)
1884#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA1 (0x2L<<16)
1885#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA2 (0x3L<<16)
1886#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA3 (0x6L<<16)
1887#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC1 (0x7L<<16)
1888#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC2 (0x5L<<16)
1889#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC3 (0x4L<<16)
1890#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_TYPE (0xcL<<16)
1891#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CMD (0xeL<<16)
1892#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_TIME (0xaL<<16)
1893#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CRC1 (0x8L<<16)
1894#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CRC2 (0x9L<<16)
1895#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_WAIT (0xdL<<16)
1896#define BNX2_EMAC_TXMAC_DEBUG4_STATS0_VALID (1L<<20)
1897#define BNX2_EMAC_TXMAC_DEBUG4_APPEND_CRC (1L<<21)
1898#define BNX2_EMAC_TXMAC_DEBUG4_SLOT_FILLED (1L<<22)
1899#define BNX2_EMAC_TXMAC_DEBUG4_MAX_DEFER (1L<<23)
1900#define BNX2_EMAC_TXMAC_DEBUG4_SEND_EXTEND (1L<<24)
1901#define BNX2_EMAC_TXMAC_DEBUG4_SEND_PADDING (1L<<25)
1902#define BNX2_EMAC_TXMAC_DEBUG4_EOF_LOC (1L<<26)
1903#define BNX2_EMAC_TXMAC_DEBUG4_COLLIDING (1L<<27)
1904#define BNX2_EMAC_TXMAC_DEBUG4_COL_IN (1L<<28)
1905#define BNX2_EMAC_TXMAC_DEBUG4_BURSTING (1L<<29)
1906#define BNX2_EMAC_TXMAC_DEBUG4_ADVANCE (1L<<30)
1907#define BNX2_EMAC_TXMAC_DEBUG4_GO (1L<<31)
1908
1909#define BNX2_EMAC_TX_STAT_AC0 0x00001680
1910#define BNX2_EMAC_TX_STAT_AC1 0x00001684
1911#define BNX2_EMAC_TX_STAT_AC2 0x00001688
1912#define BNX2_EMAC_TX_STAT_AC3 0x0000168c
1913#define BNX2_EMAC_TX_STAT_AC4 0x00001690
1914#define BNX2_EMAC_TX_STAT_AC5 0x00001694
1915#define BNX2_EMAC_TX_STAT_AC6 0x00001698
1916#define BNX2_EMAC_TX_STAT_AC7 0x0000169c
1917#define BNX2_EMAC_TX_STAT_AC8 0x000016a0
1918#define BNX2_EMAC_TX_STAT_AC9 0x000016a4
1919#define BNX2_EMAC_TX_STAT_AC10 0x000016a8
1920#define BNX2_EMAC_TX_STAT_AC11 0x000016ac
1921#define BNX2_EMAC_TX_STAT_AC12 0x000016b0
1922#define BNX2_EMAC_TX_STAT_AC13 0x000016b4
1923#define BNX2_EMAC_TX_STAT_AC14 0x000016b8
1924#define BNX2_EMAC_TX_STAT_AC15 0x000016bc
1925#define BNX2_EMAC_TX_STAT_AC16 0x000016c0
1926#define BNX2_EMAC_TX_STAT_AC17 0x000016c4
1927#define BNX2_EMAC_TX_STAT_AC18 0x000016c8
1928#define BNX2_EMAC_TX_STAT_AC19 0x000016cc
1929#define BNX2_EMAC_TX_STAT_AC20 0x000016d0
1930#define BNX2_EMAC_TX_STAT_AC21 0x000016d4
1931#define BNX2_EMAC_TXMAC_SUC_DBG_OVERRUNVEC 0x000016d8
1932
1933
1934/*
1935 * rpm_reg definition
1936 * offset: 0x1800
1937 */
1938#define BNX2_RPM_COMMAND 0x00001800
1939#define BNX2_RPM_COMMAND_ENABLED (1L<<0)
1940#define BNX2_RPM_COMMAND_OVERRUN_ABORT (1L<<4)
1941
1942#define BNX2_RPM_STATUS 0x00001804
1943#define BNX2_RPM_STATUS_MBUF_WAIT (1L<<0)
1944#define BNX2_RPM_STATUS_FREE_WAIT (1L<<1)
1945
1946#define BNX2_RPM_CONFIG 0x00001808
1947#define BNX2_RPM_CONFIG_NO_PSD_HDR_CKSUM (1L<<0)
1948#define BNX2_RPM_CONFIG_ACPI_ENA (1L<<1)
1949#define BNX2_RPM_CONFIG_ACPI_KEEP (1L<<2)
1950#define BNX2_RPM_CONFIG_MP_KEEP (1L<<3)
1951#define BNX2_RPM_CONFIG_SORT_VECT_VAL (0xfL<<4)
1952#define BNX2_RPM_CONFIG_IGNORE_VLAN (1L<<31)
1953
1954#define BNX2_RPM_VLAN_MATCH0 0x00001810
1955#define BNX2_RPM_VLAN_MATCH0_RPM_VLAN_MTCH0_VALUE (0xfffL<<0)
1956
1957#define BNX2_RPM_VLAN_MATCH1 0x00001814
1958#define BNX2_RPM_VLAN_MATCH1_RPM_VLAN_MTCH1_VALUE (0xfffL<<0)
1959
1960#define BNX2_RPM_VLAN_MATCH2 0x00001818
1961#define BNX2_RPM_VLAN_MATCH2_RPM_VLAN_MTCH2_VALUE (0xfffL<<0)
1962
1963#define BNX2_RPM_VLAN_MATCH3 0x0000181c
1964#define BNX2_RPM_VLAN_MATCH3_RPM_VLAN_MTCH3_VALUE (0xfffL<<0)
1965
1966#define BNX2_RPM_SORT_USER0 0x00001820
1967#define BNX2_RPM_SORT_USER0_PM_EN (0xffffL<<0)
1968#define BNX2_RPM_SORT_USER0_BC_EN (1L<<16)
1969#define BNX2_RPM_SORT_USER0_MC_EN (1L<<17)
1970#define BNX2_RPM_SORT_USER0_MC_HSH_EN (1L<<18)
1971#define BNX2_RPM_SORT_USER0_PROM_EN (1L<<19)
1972#define BNX2_RPM_SORT_USER0_VLAN_EN (0xfL<<20)
1973#define BNX2_RPM_SORT_USER0_PROM_VLAN (1L<<24)
1974#define BNX2_RPM_SORT_USER0_ENA (1L<<31)
1975
1976#define BNX2_RPM_SORT_USER1 0x00001824
1977#define BNX2_RPM_SORT_USER1_PM_EN (0xffffL<<0)
1978#define BNX2_RPM_SORT_USER1_BC_EN (1L<<16)
1979#define BNX2_RPM_SORT_USER1_MC_EN (1L<<17)
1980#define BNX2_RPM_SORT_USER1_MC_HSH_EN (1L<<18)
1981#define BNX2_RPM_SORT_USER1_PROM_EN (1L<<19)
1982#define BNX2_RPM_SORT_USER1_VLAN_EN (0xfL<<20)
1983#define BNX2_RPM_SORT_USER1_PROM_VLAN (1L<<24)
1984#define BNX2_RPM_SORT_USER1_ENA (1L<<31)
1985
1986#define BNX2_RPM_SORT_USER2 0x00001828
1987#define BNX2_RPM_SORT_USER2_PM_EN (0xffffL<<0)
1988#define BNX2_RPM_SORT_USER2_BC_EN (1L<<16)
1989#define BNX2_RPM_SORT_USER2_MC_EN (1L<<17)
1990#define BNX2_RPM_SORT_USER2_MC_HSH_EN (1L<<18)
1991#define BNX2_RPM_SORT_USER2_PROM_EN (1L<<19)
1992#define BNX2_RPM_SORT_USER2_VLAN_EN (0xfL<<20)
1993#define BNX2_RPM_SORT_USER2_PROM_VLAN (1L<<24)
1994#define BNX2_RPM_SORT_USER2_ENA (1L<<31)
1995
1996#define BNX2_RPM_SORT_USER3 0x0000182c
1997#define BNX2_RPM_SORT_USER3_PM_EN (0xffffL<<0)
1998#define BNX2_RPM_SORT_USER3_BC_EN (1L<<16)
1999#define BNX2_RPM_SORT_USER3_MC_EN (1L<<17)
2000#define BNX2_RPM_SORT_USER3_MC_HSH_EN (1L<<18)
2001#define BNX2_RPM_SORT_USER3_PROM_EN (1L<<19)
2002#define BNX2_RPM_SORT_USER3_VLAN_EN (0xfL<<20)
2003#define BNX2_RPM_SORT_USER3_PROM_VLAN (1L<<24)
2004#define BNX2_RPM_SORT_USER3_ENA (1L<<31)
2005
2006#define BNX2_RPM_STAT_L2_FILTER_DISCARDS 0x00001840
2007#define BNX2_RPM_STAT_RULE_CHECKER_DISCARDS 0x00001844
2008#define BNX2_RPM_STAT_IFINFTQDISCARDS 0x00001848
2009#define BNX2_RPM_STAT_IFINMBUFDISCARD 0x0000184c
2010#define BNX2_RPM_STAT_RULE_CHECKER_P4_HIT 0x00001850
2011#define BNX2_RPM_STAT_AC0 0x00001880
2012#define BNX2_RPM_STAT_AC1 0x00001884
2013#define BNX2_RPM_STAT_AC2 0x00001888
2014#define BNX2_RPM_STAT_AC3 0x0000188c
2015#define BNX2_RPM_STAT_AC4 0x00001890
2016#define BNX2_RPM_RC_CNTL_0 0x00001900
2017#define BNX2_RPM_RC_CNTL_0_OFFSET (0xffL<<0)
2018#define BNX2_RPM_RC_CNTL_0_CLASS (0x7L<<8)
2019#define BNX2_RPM_RC_CNTL_0_PRIORITY (1L<<11)
2020#define BNX2_RPM_RC_CNTL_0_P4 (1L<<12)
2021#define BNX2_RPM_RC_CNTL_0_HDR_TYPE (0x7L<<13)
2022#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_START (0L<<13)
2023#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_IP (1L<<13)
2024#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_TCP (2L<<13)
2025#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_UDP (3L<<13)
2026#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_DATA (4L<<13)
2027#define BNX2_RPM_RC_CNTL_0_COMP (0x3L<<16)
2028#define BNX2_RPM_RC_CNTL_0_COMP_EQUAL (0L<<16)
2029#define BNX2_RPM_RC_CNTL_0_COMP_NEQUAL (1L<<16)
2030#define BNX2_RPM_RC_CNTL_0_COMP_GREATER (2L<<16)
2031#define BNX2_RPM_RC_CNTL_0_COMP_LESS (3L<<16)
2032#define BNX2_RPM_RC_CNTL_0_SBIT (1L<<19)
2033#define BNX2_RPM_RC_CNTL_0_CMDSEL (0xfL<<20)
2034#define BNX2_RPM_RC_CNTL_0_MAP (1L<<24)
2035#define BNX2_RPM_RC_CNTL_0_DISCARD (1L<<25)
2036#define BNX2_RPM_RC_CNTL_0_MASK (1L<<26)
2037#define BNX2_RPM_RC_CNTL_0_P1 (1L<<27)
2038#define BNX2_RPM_RC_CNTL_0_P2 (1L<<28)
2039#define BNX2_RPM_RC_CNTL_0_P3 (1L<<29)
2040#define BNX2_RPM_RC_CNTL_0_NBIT (1L<<30)
2041
2042#define BNX2_RPM_RC_VALUE_MASK_0 0x00001904
2043#define BNX2_RPM_RC_VALUE_MASK_0_VALUE (0xffffL<<0)
2044#define BNX2_RPM_RC_VALUE_MASK_0_MASK (0xffffL<<16)
2045
2046#define BNX2_RPM_RC_CNTL_1 0x00001908
2047#define BNX2_RPM_RC_CNTL_1_A (0x3ffffL<<0)
2048#define BNX2_RPM_RC_CNTL_1_B (0xfffL<<19)
2049
2050#define BNX2_RPM_RC_VALUE_MASK_1 0x0000190c
2051#define BNX2_RPM_RC_CNTL_2 0x00001910
2052#define BNX2_RPM_RC_CNTL_2_A (0x3ffffL<<0)
2053#define BNX2_RPM_RC_CNTL_2_B (0xfffL<<19)
2054
2055#define BNX2_RPM_RC_VALUE_MASK_2 0x00001914
2056#define BNX2_RPM_RC_CNTL_3 0x00001918
2057#define BNX2_RPM_RC_CNTL_3_A (0x3ffffL<<0)
2058#define BNX2_RPM_RC_CNTL_3_B (0xfffL<<19)
2059
2060#define BNX2_RPM_RC_VALUE_MASK_3 0x0000191c
2061#define BNX2_RPM_RC_CNTL_4 0x00001920
2062#define BNX2_RPM_RC_CNTL_4_A (0x3ffffL<<0)
2063#define BNX2_RPM_RC_CNTL_4_B (0xfffL<<19)
2064
2065#define BNX2_RPM_RC_VALUE_MASK_4 0x00001924
2066#define BNX2_RPM_RC_CNTL_5 0x00001928
2067#define BNX2_RPM_RC_CNTL_5_A (0x3ffffL<<0)
2068#define BNX2_RPM_RC_CNTL_5_B (0xfffL<<19)
2069
2070#define BNX2_RPM_RC_VALUE_MASK_5 0x0000192c
2071#define BNX2_RPM_RC_CNTL_6 0x00001930
2072#define BNX2_RPM_RC_CNTL_6_A (0x3ffffL<<0)
2073#define BNX2_RPM_RC_CNTL_6_B (0xfffL<<19)
2074
2075#define BNX2_RPM_RC_VALUE_MASK_6 0x00001934
2076#define BNX2_RPM_RC_CNTL_7 0x00001938
2077#define BNX2_RPM_RC_CNTL_7_A (0x3ffffL<<0)
2078#define BNX2_RPM_RC_CNTL_7_B (0xfffL<<19)
2079
2080#define BNX2_RPM_RC_VALUE_MASK_7 0x0000193c
2081#define BNX2_RPM_RC_CNTL_8 0x00001940
2082#define BNX2_RPM_RC_CNTL_8_A (0x3ffffL<<0)
2083#define BNX2_RPM_RC_CNTL_8_B (0xfffL<<19)
2084
2085#define BNX2_RPM_RC_VALUE_MASK_8 0x00001944
2086#define BNX2_RPM_RC_CNTL_9 0x00001948
2087#define BNX2_RPM_RC_CNTL_9_A (0x3ffffL<<0)
2088#define BNX2_RPM_RC_CNTL_9_B (0xfffL<<19)
2089
2090#define BNX2_RPM_RC_VALUE_MASK_9 0x0000194c
2091#define BNX2_RPM_RC_CNTL_10 0x00001950
2092#define BNX2_RPM_RC_CNTL_10_A (0x3ffffL<<0)
2093#define BNX2_RPM_RC_CNTL_10_B (0xfffL<<19)
2094
2095#define BNX2_RPM_RC_VALUE_MASK_10 0x00001954
2096#define BNX2_RPM_RC_CNTL_11 0x00001958
2097#define BNX2_RPM_RC_CNTL_11_A (0x3ffffL<<0)
2098#define BNX2_RPM_RC_CNTL_11_B (0xfffL<<19)
2099
2100#define BNX2_RPM_RC_VALUE_MASK_11 0x0000195c
2101#define BNX2_RPM_RC_CNTL_12 0x00001960
2102#define BNX2_RPM_RC_CNTL_12_A (0x3ffffL<<0)
2103#define BNX2_RPM_RC_CNTL_12_B (0xfffL<<19)
2104
2105#define BNX2_RPM_RC_VALUE_MASK_12 0x00001964
2106#define BNX2_RPM_RC_CNTL_13 0x00001968
2107#define BNX2_RPM_RC_CNTL_13_A (0x3ffffL<<0)
2108#define BNX2_RPM_RC_CNTL_13_B (0xfffL<<19)
2109
2110#define BNX2_RPM_RC_VALUE_MASK_13 0x0000196c
2111#define BNX2_RPM_RC_CNTL_14 0x00001970
2112#define BNX2_RPM_RC_CNTL_14_A (0x3ffffL<<0)
2113#define BNX2_RPM_RC_CNTL_14_B (0xfffL<<19)
2114
2115#define BNX2_RPM_RC_VALUE_MASK_14 0x00001974
2116#define BNX2_RPM_RC_CNTL_15 0x00001978
2117#define BNX2_RPM_RC_CNTL_15_A (0x3ffffL<<0)
2118#define BNX2_RPM_RC_CNTL_15_B (0xfffL<<19)
2119
2120#define BNX2_RPM_RC_VALUE_MASK_15 0x0000197c
2121#define BNX2_RPM_RC_CONFIG 0x00001980
2122#define BNX2_RPM_RC_CONFIG_RULE_ENABLE (0xffffL<<0)
2123#define BNX2_RPM_RC_CONFIG_DEF_CLASS (0x7L<<24)
2124
2125#define BNX2_RPM_DEBUG0 0x00001984
2126#define BNX2_RPM_DEBUG0_FM_BCNT (0xffffL<<0)
2127#define BNX2_RPM_DEBUG0_T_DATA_OFST_VLD (1L<<16)
2128#define BNX2_RPM_DEBUG0_T_UDP_OFST_VLD (1L<<17)
2129#define BNX2_RPM_DEBUG0_T_TCP_OFST_VLD (1L<<18)
2130#define BNX2_RPM_DEBUG0_T_IP_OFST_VLD (1L<<19)
2131#define BNX2_RPM_DEBUG0_IP_MORE_FRGMT (1L<<20)
2132#define BNX2_RPM_DEBUG0_T_IP_NO_TCP_UDP_HDR (1L<<21)
2133#define BNX2_RPM_DEBUG0_LLC_SNAP (1L<<22)
2134#define BNX2_RPM_DEBUG0_FM_STARTED (1L<<23)
2135#define BNX2_RPM_DEBUG0_DONE (1L<<24)
2136#define BNX2_RPM_DEBUG0_WAIT_4_DONE (1L<<25)
2137#define BNX2_RPM_DEBUG0_USE_TPBUF_CKSUM (1L<<26)
2138#define BNX2_RPM_DEBUG0_RX_NO_PSD_HDR_CKSUM (1L<<27)
2139#define BNX2_RPM_DEBUG0_IGNORE_VLAN (1L<<28)
2140#define BNX2_RPM_DEBUG0_RP_ENA_ACTIVE (1L<<31)
2141
2142#define BNX2_RPM_DEBUG1 0x00001988
2143#define BNX2_RPM_DEBUG1_FSM_CUR_ST (0xffffL<<0)
2144#define BNX2_RPM_DEBUG1_FSM_CUR_ST_IDLE (0L<<0)
2145#define BNX2_RPM_DEBUG1_FSM_CUR_ST_ETYPE_B6_ALL (1L<<0)
2146#define BNX2_RPM_DEBUG1_FSM_CUR_ST_ETYPE_B2_IPLLC (2L<<0)
2147#define BNX2_RPM_DEBUG1_FSM_CUR_ST_ETYPE_B6_IP (4L<<0)
2148#define BNX2_RPM_DEBUG1_FSM_CUR_ST_ETYPE_B2_IP (8L<<0)
2149#define BNX2_RPM_DEBUG1_FSM_CUR_ST_IP_START (16L<<0)
2150#define BNX2_RPM_DEBUG1_FSM_CUR_ST_IP (32L<<0)
2151#define BNX2_RPM_DEBUG1_FSM_CUR_ST_TCP (64L<<0)
2152#define BNX2_RPM_DEBUG1_FSM_CUR_ST_UDP (128L<<0)
2153#define BNX2_RPM_DEBUG1_FSM_CUR_ST_AH (256L<<0)
2154#define BNX2_RPM_DEBUG1_FSM_CUR_ST_ESP (512L<<0)
2155#define BNX2_RPM_DEBUG1_FSM_CUR_ST_ESP_PAYLOAD (1024L<<0)
2156#define BNX2_RPM_DEBUG1_FSM_CUR_ST_DATA (2048L<<0)
2157#define BNX2_RPM_DEBUG1_FSM_CUR_ST_ADD_CARRY (0x2000L<<0)
2158#define BNX2_RPM_DEBUG1_FSM_CUR_ST_ADD_CARRYOUT (0x4000L<<0)
2159#define BNX2_RPM_DEBUG1_FSM_CUR_ST_LATCH_RESULT (0x8000L<<0)
2160#define BNX2_RPM_DEBUG1_HDR_BCNT (0x7ffL<<16)
2161#define BNX2_RPM_DEBUG1_UNKNOWN_ETYPE_D (1L<<28)
2162#define BNX2_RPM_DEBUG1_VLAN_REMOVED_D2 (1L<<29)
2163#define BNX2_RPM_DEBUG1_VLAN_REMOVED_D1 (1L<<30)
2164#define BNX2_RPM_DEBUG1_EOF_0XTRA_WD (1L<<31)
2165
2166#define BNX2_RPM_DEBUG2 0x0000198c
2167#define BNX2_RPM_DEBUG2_CMD_HIT_VEC (0xffffL<<0)
2168#define BNX2_RPM_DEBUG2_IP_BCNT (0xffL<<16)
2169#define BNX2_RPM_DEBUG2_THIS_CMD_M4 (1L<<24)
2170#define BNX2_RPM_DEBUG2_THIS_CMD_M3 (1L<<25)
2171#define BNX2_RPM_DEBUG2_THIS_CMD_M2 (1L<<26)
2172#define BNX2_RPM_DEBUG2_THIS_CMD_M1 (1L<<27)
2173#define BNX2_RPM_DEBUG2_IPIPE_EMPTY (1L<<28)
2174#define BNX2_RPM_DEBUG2_FM_DISCARD (1L<<29)
2175#define BNX2_RPM_DEBUG2_LAST_RULE_IN_FM_D2 (1L<<30)
2176#define BNX2_RPM_DEBUG2_LAST_RULE_IN_FM_D1 (1L<<31)
2177
2178#define BNX2_RPM_DEBUG3 0x00001990
2179#define BNX2_RPM_DEBUG3_AVAIL_MBUF_PTR (0x1ffL<<0)
2180#define BNX2_RPM_DEBUG3_RDE_RLUPQ_WR_REQ_INT (1L<<9)
2181#define BNX2_RPM_DEBUG3_RDE_RBUF_WR_LAST_INT (1L<<10)
2182#define BNX2_RPM_DEBUG3_RDE_RBUF_WR_REQ_INT (1L<<11)
2183#define BNX2_RPM_DEBUG3_RDE_RBUF_FREE_REQ (1L<<12)
2184#define BNX2_RPM_DEBUG3_RDE_RBUF_ALLOC_REQ (1L<<13)
2185#define BNX2_RPM_DEBUG3_DFSM_MBUF_NOTAVAIL (1L<<14)
2186#define BNX2_RPM_DEBUG3_RBUF_RDE_SOF_DROP (1L<<15)
2187#define BNX2_RPM_DEBUG3_DFIFO_VLD_ENTRY_CT (0xfL<<16)
2188#define BNX2_RPM_DEBUG3_RDE_SRC_FIFO_ALMFULL (1L<<21)
2189#define BNX2_RPM_DEBUG3_DROP_NXT_VLD (1L<<22)
2190#define BNX2_RPM_DEBUG3_DROP_NXT (1L<<23)
2191#define BNX2_RPM_DEBUG3_FTQ_FSM (0x3L<<24)
2192#define BNX2_RPM_DEBUG3_FTQ_FSM_IDLE (0x0L<<24)
2193#define BNX2_RPM_DEBUG3_FTQ_FSM_WAIT_ACK (0x1L<<24)
2194#define BNX2_RPM_DEBUG3_FTQ_FSM_WAIT_FREE (0x2L<<24)
2195#define BNX2_RPM_DEBUG3_MBWRITE_FSM (0x3L<<26)
2196#define BNX2_RPM_DEBUG3_MBWRITE_FSM_WAIT_SOF (0x0L<<26)
2197#define BNX2_RPM_DEBUG3_MBWRITE_FSM_GET_MBUF (0x1L<<26)
2198#define BNX2_RPM_DEBUG3_MBWRITE_FSM_DMA_DATA (0x2L<<26)
2199#define BNX2_RPM_DEBUG3_MBWRITE_FSM_WAIT_DATA (0x3L<<26)
2200#define BNX2_RPM_DEBUG3_MBWRITE_FSM_WAIT_EOF (0x4L<<26)
2201#define BNX2_RPM_DEBUG3_MBWRITE_FSM_WAIT_MF_ACK (0x5L<<26)
2202#define BNX2_RPM_DEBUG3_MBWRITE_FSM_WAIT_DROP_NXT_VLD (0x6L<<26)
2203#define BNX2_RPM_DEBUG3_MBWRITE_FSM_DONE (0x7L<<26)
2204#define BNX2_RPM_DEBUG3_MBFREE_FSM (1L<<29)
2205#define BNX2_RPM_DEBUG3_MBFREE_FSM_IDLE (0L<<29)
2206#define BNX2_RPM_DEBUG3_MBFREE_FSM_WAIT_ACK (1L<<29)
2207#define BNX2_RPM_DEBUG3_MBALLOC_FSM (1L<<30)
2208#define BNX2_RPM_DEBUG3_MBALLOC_FSM_ET_MBUF (0x0L<<30)
2209#define BNX2_RPM_DEBUG3_MBALLOC_FSM_IVE_MBUF (0x1L<<30)
2210#define BNX2_RPM_DEBUG3_CCODE_EOF_ERROR (1L<<31)
2211
2212#define BNX2_RPM_DEBUG4 0x00001994
2213#define BNX2_RPM_DEBUG4_DFSM_MBUF_CLUSTER (0x1ffffffL<<0)
2214#define BNX2_RPM_DEBUG4_DFIFO_CUR_CCODE (0x7L<<25)
2215#define BNX2_RPM_DEBUG4_MBWRITE_FSM (0x7L<<28)
2216#define BNX2_RPM_DEBUG4_DFIFO_EMPTY (1L<<31)
2217
2218#define BNX2_RPM_DEBUG5 0x00001998
2219#define BNX2_RPM_DEBUG5_RDROP_WPTR (0x1fL<<0)
2220#define BNX2_RPM_DEBUG5_RDROP_ACPI_RPTR (0x1fL<<5)
2221#define BNX2_RPM_DEBUG5_RDROP_MC_RPTR (0x1fL<<10)
2222#define BNX2_RPM_DEBUG5_RDROP_RC_RPTR (0x1fL<<15)
2223#define BNX2_RPM_DEBUG5_RDROP_ACPI_EMPTY (1L<<20)
2224#define BNX2_RPM_DEBUG5_RDROP_MC_EMPTY (1L<<21)
2225#define BNX2_RPM_DEBUG5_RDROP_AEOF_VEC_AT_RDROP_MC_RPTR (1L<<22)
2226#define BNX2_RPM_DEBUG5_HOLDREG_WOL_DROP_INT (1L<<23)
2227#define BNX2_RPM_DEBUG5_HOLDREG_DISCARD (1L<<24)
2228#define BNX2_RPM_DEBUG5_HOLDREG_MBUF_NOTAVAIL (1L<<25)
2229#define BNX2_RPM_DEBUG5_HOLDREG_MC_EMPTY (1L<<26)
2230#define BNX2_RPM_DEBUG5_HOLDREG_RC_EMPTY (1L<<27)
2231#define BNX2_RPM_DEBUG5_HOLDREG_FC_EMPTY (1L<<28)
2232#define BNX2_RPM_DEBUG5_HOLDREG_ACPI_EMPTY (1L<<29)
2233#define BNX2_RPM_DEBUG5_HOLDREG_FULL_T (1L<<30)
2234#define BNX2_RPM_DEBUG5_HOLDREG_RD (1L<<31)
2235
2236#define BNX2_RPM_DEBUG6 0x0000199c
2237#define BNX2_RPM_DEBUG6_ACPI_VEC (0xffffL<<0)
2238#define BNX2_RPM_DEBUG6_VEC (0xffffL<<16)
2239
2240#define BNX2_RPM_DEBUG7 0x000019a0
2241#define BNX2_RPM_DEBUG7_RPM_DBG7_LAST_CRC (0xffffffffL<<0)
2242
2243#define BNX2_RPM_DEBUG8 0x000019a4
2244#define BNX2_RPM_DEBUG8_PS_ACPI_FSM (0xfL<<0)
2245#define BNX2_RPM_DEBUG8_PS_ACPI_FSM_IDLE (0L<<0)
2246#define BNX2_RPM_DEBUG8_PS_ACPI_FSM_SOF_W1_ADDR (1L<<0)
2247#define BNX2_RPM_DEBUG8_PS_ACPI_FSM_SOF_W2_ADDR (2L<<0)
2248#define BNX2_RPM_DEBUG8_PS_ACPI_FSM_SOF_W3_ADDR (3L<<0)
2249#define BNX2_RPM_DEBUG8_PS_ACPI_FSM_SOF_WAIT_THBUF (4L<<0)
2250#define BNX2_RPM_DEBUG8_PS_ACPI_FSM_W3_DATA (5L<<0)
2251#define BNX2_RPM_DEBUG8_PS_ACPI_FSM_W0_ADDR (6L<<0)
2252#define BNX2_RPM_DEBUG8_PS_ACPI_FSM_W1_ADDR (7L<<0)
2253#define BNX2_RPM_DEBUG8_PS_ACPI_FSM_W2_ADDR (8L<<0)
2254#define BNX2_RPM_DEBUG8_PS_ACPI_FSM_W3_ADDR (9L<<0)
2255#define BNX2_RPM_DEBUG8_PS_ACPI_FSM_WAIT_THBUF (10L<<0)
2256#define BNX2_RPM_DEBUG8_COMPARE_AT_W0 (1L<<4)
2257#define BNX2_RPM_DEBUG8_COMPARE_AT_W3_DATA (1L<<5)
2258#define BNX2_RPM_DEBUG8_COMPARE_AT_SOF_WAIT (1L<<6)
2259#define BNX2_RPM_DEBUG8_COMPARE_AT_SOF_W3 (1L<<7)
2260#define BNX2_RPM_DEBUG8_COMPARE_AT_SOF_W2 (1L<<8)
2261#define BNX2_RPM_DEBUG8_EOF_W_LTEQ6_VLDBYTES (1L<<9)
2262#define BNX2_RPM_DEBUG8_EOF_W_LTEQ4_VLDBYTES (1L<<10)
2263#define BNX2_RPM_DEBUG8_NXT_EOF_W_12_VLDBYTES (1L<<11)
2264#define BNX2_RPM_DEBUG8_EOF_DET (1L<<12)
2265#define BNX2_RPM_DEBUG8_SOF_DET (1L<<13)
2266#define BNX2_RPM_DEBUG8_WAIT_4_SOF (1L<<14)
2267#define BNX2_RPM_DEBUG8_ALL_DONE (1L<<15)
2268#define BNX2_RPM_DEBUG8_THBUF_ADDR (0x7fL<<16)
2269#define BNX2_RPM_DEBUG8_BYTE_CTR (0xffL<<24)
2270
2271#define BNX2_RPM_DEBUG9 0x000019a8
2272#define BNX2_RPM_DEBUG9_OUTFIFO_COUNT (0x7L<<0)
2273#define BNX2_RPM_DEBUG9_RDE_ACPI_RDY (1L<<3)
2274#define BNX2_RPM_DEBUG9_VLD_RD_ENTRY_CT (0x7L<<4)
2275#define BNX2_RPM_DEBUG9_OUTFIFO_OVERRUN_OCCURRED (1L<<28)
2276#define BNX2_RPM_DEBUG9_INFIFO_OVERRUN_OCCURRED (1L<<29)
2277#define BNX2_RPM_DEBUG9_ACPI_MATCH_INT (1L<<30)
2278#define BNX2_RPM_DEBUG9_ACPI_ENABLE_SYN (1L<<31)
2279
2280#define BNX2_RPM_ACPI_DBG_BUF_W00 0x000019c0
2281#define BNX2_RPM_ACPI_DBG_BUF_W01 0x000019c4
2282#define BNX2_RPM_ACPI_DBG_BUF_W02 0x000019c8
2283#define BNX2_RPM_ACPI_DBG_BUF_W03 0x000019cc
2284#define BNX2_RPM_ACPI_DBG_BUF_W10 0x000019d0
2285#define BNX2_RPM_ACPI_DBG_BUF_W11 0x000019d4
2286#define BNX2_RPM_ACPI_DBG_BUF_W12 0x000019d8
2287#define BNX2_RPM_ACPI_DBG_BUF_W13 0x000019dc
2288#define BNX2_RPM_ACPI_DBG_BUF_W20 0x000019e0
2289#define BNX2_RPM_ACPI_DBG_BUF_W21 0x000019e4
2290#define BNX2_RPM_ACPI_DBG_BUF_W22 0x000019e8
2291#define BNX2_RPM_ACPI_DBG_BUF_W23 0x000019ec
2292#define BNX2_RPM_ACPI_DBG_BUF_W30 0x000019f0
2293#define BNX2_RPM_ACPI_DBG_BUF_W31 0x000019f4
2294#define BNX2_RPM_ACPI_DBG_BUF_W32 0x000019f8
2295#define BNX2_RPM_ACPI_DBG_BUF_W33 0x000019fc
2296
2297
2298/*
2299 * rbuf_reg definition
2300 * offset: 0x200000
2301 */
2302#define BNX2_RBUF_COMMAND 0x00200000
2303#define BNX2_RBUF_COMMAND_ENABLED (1L<<0)
2304#define BNX2_RBUF_COMMAND_FREE_INIT (1L<<1)
2305#define BNX2_RBUF_COMMAND_RAM_INIT (1L<<2)
2306#define BNX2_RBUF_COMMAND_OVER_FREE (1L<<4)
2307#define BNX2_RBUF_COMMAND_ALLOC_REQ (1L<<5)
2308
2309#define BNX2_RBUF_STATUS1 0x00200004
2310#define BNX2_RBUF_STATUS1_FREE_COUNT (0x3ffL<<0)
2311
2312#define BNX2_RBUF_STATUS2 0x00200008
2313#define BNX2_RBUF_STATUS2_FREE_TAIL (0x3ffL<<0)
2314#define BNX2_RBUF_STATUS2_FREE_HEAD (0x3ffL<<16)
2315
2316#define BNX2_RBUF_CONFIG 0x0020000c
2317#define BNX2_RBUF_CONFIG_XOFF_TRIP (0x3ffL<<0)
2318#define BNX2_RBUF_CONFIG_XON_TRIP (0x3ffL<<16)
2319
2320#define BNX2_RBUF_FW_BUF_ALLOC 0x00200010
2321#define BNX2_RBUF_FW_BUF_ALLOC_VALUE (0x1ffL<<7)
2322
2323#define BNX2_RBUF_FW_BUF_FREE 0x00200014
2324#define BNX2_RBUF_FW_BUF_FREE_COUNT (0x7fL<<0)
2325#define BNX2_RBUF_FW_BUF_FREE_TAIL (0x1ffL<<7)
2326#define BNX2_RBUF_FW_BUF_FREE_HEAD (0x1ffL<<16)
2327
2328#define BNX2_RBUF_FW_BUF_SEL 0x00200018
2329#define BNX2_RBUF_FW_BUF_SEL_COUNT (0x7fL<<0)
2330#define BNX2_RBUF_FW_BUF_SEL_TAIL (0x1ffL<<7)
2331#define BNX2_RBUF_FW_BUF_SEL_HEAD (0x1ffL<<16)
2332
2333#define BNX2_RBUF_CONFIG2 0x0020001c
2334#define BNX2_RBUF_CONFIG2_MAC_DROP_TRIP (0x3ffL<<0)
2335#define BNX2_RBUF_CONFIG2_MAC_KEEP_TRIP (0x3ffL<<16)
2336
2337#define BNX2_RBUF_CONFIG3 0x00200020
2338#define BNX2_RBUF_CONFIG3_CU_DROP_TRIP (0x3ffL<<0)
2339#define BNX2_RBUF_CONFIG3_CU_KEEP_TRIP (0x3ffL<<16)
2340
2341#define BNX2_RBUF_PKT_DATA 0x00208000
2342#define BNX2_RBUF_CLIST_DATA 0x00210000
2343#define BNX2_RBUF_BUF_DATA 0x00220000
2344
2345
2346/*
2347 * rv2p_reg definition
2348 * offset: 0x2800
2349 */
2350#define BNX2_RV2P_COMMAND 0x00002800
2351#define BNX2_RV2P_COMMAND_ENABLED (1L<<0)
2352#define BNX2_RV2P_COMMAND_PROC1_INTRPT (1L<<1)
2353#define BNX2_RV2P_COMMAND_PROC2_INTRPT (1L<<2)
2354#define BNX2_RV2P_COMMAND_ABORT0 (1L<<4)
2355#define BNX2_RV2P_COMMAND_ABORT1 (1L<<5)
2356#define BNX2_RV2P_COMMAND_ABORT2 (1L<<6)
2357#define BNX2_RV2P_COMMAND_ABORT3 (1L<<7)
2358#define BNX2_RV2P_COMMAND_ABORT4 (1L<<8)
2359#define BNX2_RV2P_COMMAND_ABORT5 (1L<<9)
2360#define BNX2_RV2P_COMMAND_PROC1_RESET (1L<<16)
2361#define BNX2_RV2P_COMMAND_PROC2_RESET (1L<<17)
2362#define BNX2_RV2P_COMMAND_CTXIF_RESET (1L<<18)
2363
2364#define BNX2_RV2P_STATUS 0x00002804
2365#define BNX2_RV2P_STATUS_ALWAYS_0 (1L<<0)
2366#define BNX2_RV2P_STATUS_RV2P_GEN_STAT0_CNT (1L<<8)
2367#define BNX2_RV2P_STATUS_RV2P_GEN_STAT1_CNT (1L<<9)
2368#define BNX2_RV2P_STATUS_RV2P_GEN_STAT2_CNT (1L<<10)
2369#define BNX2_RV2P_STATUS_RV2P_GEN_STAT3_CNT (1L<<11)
2370#define BNX2_RV2P_STATUS_RV2P_GEN_STAT4_CNT (1L<<12)
2371#define BNX2_RV2P_STATUS_RV2P_GEN_STAT5_CNT (1L<<13)
2372
2373#define BNX2_RV2P_CONFIG 0x00002808
2374#define BNX2_RV2P_CONFIG_STALL_PROC1 (1L<<0)
2375#define BNX2_RV2P_CONFIG_STALL_PROC2 (1L<<1)
2376#define BNX2_RV2P_CONFIG_PROC1_STALL_ON_ABORT0 (1L<<8)
2377#define BNX2_RV2P_CONFIG_PROC1_STALL_ON_ABORT1 (1L<<9)
2378#define BNX2_RV2P_CONFIG_PROC1_STALL_ON_ABORT2 (1L<<10)
2379#define BNX2_RV2P_CONFIG_PROC1_STALL_ON_ABORT3 (1L<<11)
2380#define BNX2_RV2P_CONFIG_PROC1_STALL_ON_ABORT4 (1L<<12)
2381#define BNX2_RV2P_CONFIG_PROC1_STALL_ON_ABORT5 (1L<<13)
2382#define BNX2_RV2P_CONFIG_PROC2_STALL_ON_ABORT0 (1L<<16)
2383#define BNX2_RV2P_CONFIG_PROC2_STALL_ON_ABORT1 (1L<<17)
2384#define BNX2_RV2P_CONFIG_PROC2_STALL_ON_ABORT2 (1L<<18)
2385#define BNX2_RV2P_CONFIG_PROC2_STALL_ON_ABORT3 (1L<<19)
2386#define BNX2_RV2P_CONFIG_PROC2_STALL_ON_ABORT4 (1L<<20)
2387#define BNX2_RV2P_CONFIG_PROC2_STALL_ON_ABORT5 (1L<<21)
2388#define BNX2_RV2P_CONFIG_PAGE_SIZE (0xfL<<24)
2389#define BNX2_RV2P_CONFIG_PAGE_SIZE_256 (0L<<24)
2390#define BNX2_RV2P_CONFIG_PAGE_SIZE_512 (1L<<24)
2391#define BNX2_RV2P_CONFIG_PAGE_SIZE_1K (2L<<24)
2392#define BNX2_RV2P_CONFIG_PAGE_SIZE_2K (3L<<24)
2393#define BNX2_RV2P_CONFIG_PAGE_SIZE_4K (4L<<24)
2394#define BNX2_RV2P_CONFIG_PAGE_SIZE_8K (5L<<24)
2395#define BNX2_RV2P_CONFIG_PAGE_SIZE_16K (6L<<24)
2396#define BNX2_RV2P_CONFIG_PAGE_SIZE_32K (7L<<24)
2397#define BNX2_RV2P_CONFIG_PAGE_SIZE_64K (8L<<24)
2398#define BNX2_RV2P_CONFIG_PAGE_SIZE_128K (9L<<24)
2399#define BNX2_RV2P_CONFIG_PAGE_SIZE_256K (10L<<24)
2400#define BNX2_RV2P_CONFIG_PAGE_SIZE_512K (11L<<24)
2401#define BNX2_RV2P_CONFIG_PAGE_SIZE_1M (12L<<24)
2402
2403#define BNX2_RV2P_GEN_BFR_ADDR_0 0x00002810
2404#define BNX2_RV2P_GEN_BFR_ADDR_0_VALUE (0xffffL<<16)
2405
2406#define BNX2_RV2P_GEN_BFR_ADDR_1 0x00002814
2407#define BNX2_RV2P_GEN_BFR_ADDR_1_VALUE (0xffffL<<16)
2408
2409#define BNX2_RV2P_GEN_BFR_ADDR_2 0x00002818
2410#define BNX2_RV2P_GEN_BFR_ADDR_2_VALUE (0xffffL<<16)
2411
2412#define BNX2_RV2P_GEN_BFR_ADDR_3 0x0000281c
2413#define BNX2_RV2P_GEN_BFR_ADDR_3_VALUE (0xffffL<<16)
2414
2415#define BNX2_RV2P_INSTR_HIGH 0x00002830
2416#define BNX2_RV2P_INSTR_HIGH_HIGH (0x1fL<<0)
2417
2418#define BNX2_RV2P_INSTR_LOW 0x00002834
2419#define BNX2_RV2P_PROC1_ADDR_CMD 0x00002838
2420#define BNX2_RV2P_PROC1_ADDR_CMD_ADD (0x3ffL<<0)
2421#define BNX2_RV2P_PROC1_ADDR_CMD_RDWR (1L<<31)
2422
2423#define BNX2_RV2P_PROC2_ADDR_CMD 0x0000283c
2424#define BNX2_RV2P_PROC2_ADDR_CMD_ADD (0x3ffL<<0)
2425#define BNX2_RV2P_PROC2_ADDR_CMD_RDWR (1L<<31)
2426
2427#define BNX2_RV2P_PROC1_GRC_DEBUG 0x00002840
2428#define BNX2_RV2P_PROC2_GRC_DEBUG 0x00002844
2429#define BNX2_RV2P_GRC_PROC_DEBUG 0x00002848
2430#define BNX2_RV2P_DEBUG_VECT_PEEK 0x0000284c
2431#define BNX2_RV2P_DEBUG_VECT_PEEK_1_VALUE (0x7ffL<<0)
2432#define BNX2_RV2P_DEBUG_VECT_PEEK_1_PEEK_EN (1L<<11)
2433#define BNX2_RV2P_DEBUG_VECT_PEEK_1_SEL (0xfL<<12)
2434#define BNX2_RV2P_DEBUG_VECT_PEEK_2_VALUE (0x7ffL<<16)
2435#define BNX2_RV2P_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
2436#define BNX2_RV2P_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
2437
2438#define BNX2_RV2P_PFTQ_DATA 0x00002b40
2439#define BNX2_RV2P_PFTQ_CMD 0x00002b78
2440#define BNX2_RV2P_PFTQ_CMD_OFFSET (0x3ffL<<0)
2441#define BNX2_RV2P_PFTQ_CMD_WR_TOP (1L<<10)
2442#define BNX2_RV2P_PFTQ_CMD_WR_TOP_0 (0L<<10)
2443#define BNX2_RV2P_PFTQ_CMD_WR_TOP_1 (1L<<10)
2444#define BNX2_RV2P_PFTQ_CMD_SFT_RESET (1L<<25)
2445#define BNX2_RV2P_PFTQ_CMD_RD_DATA (1L<<26)
2446#define BNX2_RV2P_PFTQ_CMD_ADD_INTERVEN (1L<<27)
2447#define BNX2_RV2P_PFTQ_CMD_ADD_DATA (1L<<28)
2448#define BNX2_RV2P_PFTQ_CMD_INTERVENE_CLR (1L<<29)
2449#define BNX2_RV2P_PFTQ_CMD_POP (1L<<30)
2450#define BNX2_RV2P_PFTQ_CMD_BUSY (1L<<31)
2451
2452#define BNX2_RV2P_PFTQ_CTL 0x00002b7c
2453#define BNX2_RV2P_PFTQ_CTL_INTERVENE (1L<<0)
2454#define BNX2_RV2P_PFTQ_CTL_OVERFLOW (1L<<1)
2455#define BNX2_RV2P_PFTQ_CTL_FORCE_INTERVENE (1L<<2)
2456#define BNX2_RV2P_PFTQ_CTL_MAX_DEPTH (0x3ffL<<12)
2457#define BNX2_RV2P_PFTQ_CTL_CUR_DEPTH (0x3ffL<<22)
2458
2459#define BNX2_RV2P_TFTQ_DATA 0x00002b80
2460#define BNX2_RV2P_TFTQ_CMD 0x00002bb8
2461#define BNX2_RV2P_TFTQ_CMD_OFFSET (0x3ffL<<0)
2462#define BNX2_RV2P_TFTQ_CMD_WR_TOP (1L<<10)
2463#define BNX2_RV2P_TFTQ_CMD_WR_TOP_0 (0L<<10)
2464#define BNX2_RV2P_TFTQ_CMD_WR_TOP_1 (1L<<10)
2465#define BNX2_RV2P_TFTQ_CMD_SFT_RESET (1L<<25)
2466#define BNX2_RV2P_TFTQ_CMD_RD_DATA (1L<<26)
2467#define BNX2_RV2P_TFTQ_CMD_ADD_INTERVEN (1L<<27)
2468#define BNX2_RV2P_TFTQ_CMD_ADD_DATA (1L<<28)
2469#define BNX2_RV2P_TFTQ_CMD_INTERVENE_CLR (1L<<29)
2470#define BNX2_RV2P_TFTQ_CMD_POP (1L<<30)
2471#define BNX2_RV2P_TFTQ_CMD_BUSY (1L<<31)
2472
2473#define BNX2_RV2P_TFTQ_CTL 0x00002bbc
2474#define BNX2_RV2P_TFTQ_CTL_INTERVENE (1L<<0)
2475#define BNX2_RV2P_TFTQ_CTL_OVERFLOW (1L<<1)
2476#define BNX2_RV2P_TFTQ_CTL_FORCE_INTERVENE (1L<<2)
2477#define BNX2_RV2P_TFTQ_CTL_MAX_DEPTH (0x3ffL<<12)
2478#define BNX2_RV2P_TFTQ_CTL_CUR_DEPTH (0x3ffL<<22)
2479
2480#define BNX2_RV2P_MFTQ_DATA 0x00002bc0
2481#define BNX2_RV2P_MFTQ_CMD 0x00002bf8
2482#define BNX2_RV2P_MFTQ_CMD_OFFSET (0x3ffL<<0)
2483#define BNX2_RV2P_MFTQ_CMD_WR_TOP (1L<<10)
2484#define BNX2_RV2P_MFTQ_CMD_WR_TOP_0 (0L<<10)
2485#define BNX2_RV2P_MFTQ_CMD_WR_TOP_1 (1L<<10)
2486#define BNX2_RV2P_MFTQ_CMD_SFT_RESET (1L<<25)
2487#define BNX2_RV2P_MFTQ_CMD_RD_DATA (1L<<26)
2488#define BNX2_RV2P_MFTQ_CMD_ADD_INTERVEN (1L<<27)
2489#define BNX2_RV2P_MFTQ_CMD_ADD_DATA (1L<<28)
2490#define BNX2_RV2P_MFTQ_CMD_INTERVENE_CLR (1L<<29)
2491#define BNX2_RV2P_MFTQ_CMD_POP (1L<<30)
2492#define BNX2_RV2P_MFTQ_CMD_BUSY (1L<<31)
2493
2494#define BNX2_RV2P_MFTQ_CTL 0x00002bfc
2495#define BNX2_RV2P_MFTQ_CTL_INTERVENE (1L<<0)
2496#define BNX2_RV2P_MFTQ_CTL_OVERFLOW (1L<<1)
2497#define BNX2_RV2P_MFTQ_CTL_FORCE_INTERVENE (1L<<2)
2498#define BNX2_RV2P_MFTQ_CTL_MAX_DEPTH (0x3ffL<<12)
2499#define BNX2_RV2P_MFTQ_CTL_CUR_DEPTH (0x3ffL<<22)
2500
2501
2502
2503/*
2504 * mq_reg definition
2505 * offset: 0x3c00
2506 */
2507#define BNX2_MQ_COMMAND 0x00003c00
2508#define BNX2_MQ_COMMAND_ENABLED (1L<<0)
2509#define BNX2_MQ_COMMAND_OVERFLOW (1L<<4)
2510#define BNX2_MQ_COMMAND_WR_ERROR (1L<<5)
2511#define BNX2_MQ_COMMAND_RD_ERROR (1L<<6)
2512
2513#define BNX2_MQ_STATUS 0x00003c04
2514#define BNX2_MQ_STATUS_CTX_ACCESS_STAT (1L<<16)
2515#define BNX2_MQ_STATUS_CTX_ACCESS64_STAT (1L<<17)
2516#define BNX2_MQ_STATUS_PCI_STALL_STAT (1L<<18)
2517
2518#define BNX2_MQ_CONFIG 0x00003c08
2519#define BNX2_MQ_CONFIG_TX_HIGH_PRI (1L<<0)
2520#define BNX2_MQ_CONFIG_HALT_DIS (1L<<1)
2521#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE (0x7L<<4)
2522#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256 (0L<<4)
2523#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_512 (1L<<4)
2524#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_1K (2L<<4)
2525#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_2K (3L<<4)
2526#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_4K (4L<<4)
2527#define BNX2_MQ_CONFIG_MAX_DEPTH (0x7fL<<8)
2528#define BNX2_MQ_CONFIG_CUR_DEPTH (0x7fL<<20)
2529
2530#define BNX2_MQ_ENQUEUE1 0x00003c0c
2531#define BNX2_MQ_ENQUEUE1_OFFSET (0x3fL<<2)
2532#define BNX2_MQ_ENQUEUE1_CID (0x3fffL<<8)
2533#define BNX2_MQ_ENQUEUE1_BYTE_MASK (0xfL<<24)
2534#define BNX2_MQ_ENQUEUE1_KNL_MODE (1L<<28)
2535
2536#define BNX2_MQ_ENQUEUE2 0x00003c10
2537#define BNX2_MQ_BAD_WR_ADDR 0x00003c14
2538#define BNX2_MQ_BAD_RD_ADDR 0x00003c18
2539#define BNX2_MQ_KNL_BYP_WIND_START 0x00003c1c
2540#define BNX2_MQ_KNL_BYP_WIND_START_VALUE (0xfffffL<<12)
2541
2542#define BNX2_MQ_KNL_WIND_END 0x00003c20
2543#define BNX2_MQ_KNL_WIND_END_VALUE (0xffffffL<<8)
2544
2545#define BNX2_MQ_KNL_WRITE_MASK1 0x00003c24
2546#define BNX2_MQ_KNL_TX_MASK1 0x00003c28
2547#define BNX2_MQ_KNL_CMD_MASK1 0x00003c2c
2548#define BNX2_MQ_KNL_COND_ENQUEUE_MASK1 0x00003c30
2549#define BNX2_MQ_KNL_RX_V2P_MASK1 0x00003c34
2550#define BNX2_MQ_KNL_WRITE_MASK2 0x00003c38
2551#define BNX2_MQ_KNL_TX_MASK2 0x00003c3c
2552#define BNX2_MQ_KNL_CMD_MASK2 0x00003c40
2553#define BNX2_MQ_KNL_COND_ENQUEUE_MASK2 0x00003c44
2554#define BNX2_MQ_KNL_RX_V2P_MASK2 0x00003c48
2555#define BNX2_MQ_KNL_BYP_WRITE_MASK1 0x00003c4c
2556#define BNX2_MQ_KNL_BYP_TX_MASK1 0x00003c50
2557#define BNX2_MQ_KNL_BYP_CMD_MASK1 0x00003c54
2558#define BNX2_MQ_KNL_BYP_COND_ENQUEUE_MASK1 0x00003c58
2559#define BNX2_MQ_KNL_BYP_RX_V2P_MASK1 0x00003c5c
2560#define BNX2_MQ_KNL_BYP_WRITE_MASK2 0x00003c60
2561#define BNX2_MQ_KNL_BYP_TX_MASK2 0x00003c64
2562#define BNX2_MQ_KNL_BYP_CMD_MASK2 0x00003c68
2563#define BNX2_MQ_KNL_BYP_COND_ENQUEUE_MASK2 0x00003c6c
2564#define BNX2_MQ_KNL_BYP_RX_V2P_MASK2 0x00003c70
2565#define BNX2_MQ_MEM_WR_ADDR 0x00003c74
2566#define BNX2_MQ_MEM_WR_ADDR_VALUE (0x3fL<<0)
2567
2568#define BNX2_MQ_MEM_WR_DATA0 0x00003c78
2569#define BNX2_MQ_MEM_WR_DATA0_VALUE (0xffffffffL<<0)
2570
2571#define BNX2_MQ_MEM_WR_DATA1 0x00003c7c
2572#define BNX2_MQ_MEM_WR_DATA1_VALUE (0xffffffffL<<0)
2573
2574#define BNX2_MQ_MEM_WR_DATA2 0x00003c80
2575#define BNX2_MQ_MEM_WR_DATA2_VALUE (0x3fffffffL<<0)
2576
2577#define BNX2_MQ_MEM_RD_ADDR 0x00003c84
2578#define BNX2_MQ_MEM_RD_ADDR_VALUE (0x3fL<<0)
2579
2580#define BNX2_MQ_MEM_RD_DATA0 0x00003c88
2581#define BNX2_MQ_MEM_RD_DATA0_VALUE (0xffffffffL<<0)
2582
2583#define BNX2_MQ_MEM_RD_DATA1 0x00003c8c
2584#define BNX2_MQ_MEM_RD_DATA1_VALUE (0xffffffffL<<0)
2585
2586#define BNX2_MQ_MEM_RD_DATA2 0x00003c90
2587#define BNX2_MQ_MEM_RD_DATA2_VALUE (0x3fffffffL<<0)
2588
2589
2590
2591/*
2592 * tbdr_reg definition
2593 * offset: 0x5000
2594 */
2595#define BNX2_TBDR_COMMAND 0x00005000
2596#define BNX2_TBDR_COMMAND_ENABLE (1L<<0)
2597#define BNX2_TBDR_COMMAND_SOFT_RST (1L<<1)
2598#define BNX2_TBDR_COMMAND_MSTR_ABORT (1L<<4)
2599
2600#define BNX2_TBDR_STATUS 0x00005004
2601#define BNX2_TBDR_STATUS_DMA_WAIT (1L<<0)
2602#define BNX2_TBDR_STATUS_FTQ_WAIT (1L<<1)
2603#define BNX2_TBDR_STATUS_FIFO_OVERFLOW (1L<<2)
2604#define BNX2_TBDR_STATUS_FIFO_UNDERFLOW (1L<<3)
2605#define BNX2_TBDR_STATUS_SEARCHMISS_ERROR (1L<<4)
2606#define BNX2_TBDR_STATUS_FTQ_ENTRY_CNT (1L<<5)
2607#define BNX2_TBDR_STATUS_BURST_CNT (1L<<6)
2608
2609#define BNX2_TBDR_CONFIG 0x00005008
2610#define BNX2_TBDR_CONFIG_MAX_BDS (0xffL<<0)
2611#define BNX2_TBDR_CONFIG_SWAP_MODE (1L<<8)
2612#define BNX2_TBDR_CONFIG_PRIORITY (1L<<9)
2613#define BNX2_TBDR_CONFIG_CACHE_NEXT_PAGE_PTRS (1L<<10)
2614#define BNX2_TBDR_CONFIG_PAGE_SIZE (0xfL<<24)
2615#define BNX2_TBDR_CONFIG_PAGE_SIZE_256 (0L<<24)
2616#define BNX2_TBDR_CONFIG_PAGE_SIZE_512 (1L<<24)
2617#define BNX2_TBDR_CONFIG_PAGE_SIZE_1K (2L<<24)
2618#define BNX2_TBDR_CONFIG_PAGE_SIZE_2K (3L<<24)
2619#define BNX2_TBDR_CONFIG_PAGE_SIZE_4K (4L<<24)
2620#define BNX2_TBDR_CONFIG_PAGE_SIZE_8K (5L<<24)
2621#define BNX2_TBDR_CONFIG_PAGE_SIZE_16K (6L<<24)
2622#define BNX2_TBDR_CONFIG_PAGE_SIZE_32K (7L<<24)
2623#define BNX2_TBDR_CONFIG_PAGE_SIZE_64K (8L<<24)
2624#define BNX2_TBDR_CONFIG_PAGE_SIZE_128K (9L<<24)
2625#define BNX2_TBDR_CONFIG_PAGE_SIZE_256K (10L<<24)
2626#define BNX2_TBDR_CONFIG_PAGE_SIZE_512K (11L<<24)
2627#define BNX2_TBDR_CONFIG_PAGE_SIZE_1M (12L<<24)
2628
2629#define BNX2_TBDR_DEBUG_VECT_PEEK 0x0000500c
2630#define BNX2_TBDR_DEBUG_VECT_PEEK_1_VALUE (0x7ffL<<0)
2631#define BNX2_TBDR_DEBUG_VECT_PEEK_1_PEEK_EN (1L<<11)
2632#define BNX2_TBDR_DEBUG_VECT_PEEK_1_SEL (0xfL<<12)
2633#define BNX2_TBDR_DEBUG_VECT_PEEK_2_VALUE (0x7ffL<<16)
2634#define BNX2_TBDR_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
2635#define BNX2_TBDR_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
2636
2637#define BNX2_TBDR_FTQ_DATA 0x000053c0
2638#define BNX2_TBDR_FTQ_CMD 0x000053f8
2639#define BNX2_TBDR_FTQ_CMD_OFFSET (0x3ffL<<0)
2640#define BNX2_TBDR_FTQ_CMD_WR_TOP (1L<<10)
2641#define BNX2_TBDR_FTQ_CMD_WR_TOP_0 (0L<<10)
2642#define BNX2_TBDR_FTQ_CMD_WR_TOP_1 (1L<<10)
2643#define BNX2_TBDR_FTQ_CMD_SFT_RESET (1L<<25)
2644#define BNX2_TBDR_FTQ_CMD_RD_DATA (1L<<26)
2645#define BNX2_TBDR_FTQ_CMD_ADD_INTERVEN (1L<<27)
2646#define BNX2_TBDR_FTQ_CMD_ADD_DATA (1L<<28)
2647#define BNX2_TBDR_FTQ_CMD_INTERVENE_CLR (1L<<29)
2648#define BNX2_TBDR_FTQ_CMD_POP (1L<<30)
2649#define BNX2_TBDR_FTQ_CMD_BUSY (1L<<31)
2650
2651#define BNX2_TBDR_FTQ_CTL 0x000053fc
2652#define BNX2_TBDR_FTQ_CTL_INTERVENE (1L<<0)
2653#define BNX2_TBDR_FTQ_CTL_OVERFLOW (1L<<1)
2654#define BNX2_TBDR_FTQ_CTL_FORCE_INTERVENE (1L<<2)
2655#define BNX2_TBDR_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
2656#define BNX2_TBDR_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
2657
2658
2659
2660/*
2661 * tdma_reg definition
2662 * offset: 0x5c00
2663 */
2664#define BNX2_TDMA_COMMAND 0x00005c00
2665#define BNX2_TDMA_COMMAND_ENABLED (1L<<0)
2666#define BNX2_TDMA_COMMAND_MASTER_ABORT (1L<<4)
2667#define BNX2_TDMA_COMMAND_BAD_L2_LENGTH_ABORT (1L<<7)
2668
2669#define BNX2_TDMA_STATUS 0x00005c04
2670#define BNX2_TDMA_STATUS_DMA_WAIT (1L<<0)
2671#define BNX2_TDMA_STATUS_PAYLOAD_WAIT (1L<<1)
2672#define BNX2_TDMA_STATUS_PATCH_FTQ_WAIT (1L<<2)
2673#define BNX2_TDMA_STATUS_LOCK_WAIT (1L<<3)
2674#define BNX2_TDMA_STATUS_FTQ_ENTRY_CNT (1L<<16)
2675#define BNX2_TDMA_STATUS_BURST_CNT (1L<<17)
2676
2677#define BNX2_TDMA_CONFIG 0x00005c08
2678#define BNX2_TDMA_CONFIG_ONE_DMA (1L<<0)
2679#define BNX2_TDMA_CONFIG_ONE_RECORD (1L<<1)
2680#define BNX2_TDMA_CONFIG_LIMIT_SZ (0xfL<<4)
2681#define BNX2_TDMA_CONFIG_LIMIT_SZ_64 (0L<<4)
2682#define BNX2_TDMA_CONFIG_LIMIT_SZ_128 (0x4L<<4)
2683#define BNX2_TDMA_CONFIG_LIMIT_SZ_256 (0x6L<<4)
2684#define BNX2_TDMA_CONFIG_LIMIT_SZ_512 (0x8L<<4)
2685#define BNX2_TDMA_CONFIG_LINE_SZ (0xfL<<8)
2686#define BNX2_TDMA_CONFIG_LINE_SZ_64 (0L<<8)
2687#define BNX2_TDMA_CONFIG_LINE_SZ_128 (4L<<8)
2688#define BNX2_TDMA_CONFIG_LINE_SZ_256 (6L<<8)
2689#define BNX2_TDMA_CONFIG_LINE_SZ_512 (8L<<8)
2690#define BNX2_TDMA_CONFIG_ALIGN_ENA (1L<<15)
2691#define BNX2_TDMA_CONFIG_CHK_L2_BD (1L<<16)
2692#define BNX2_TDMA_CONFIG_FIFO_CMP (0xfL<<20)
2693
2694#define BNX2_TDMA_PAYLOAD_PROD 0x00005c0c
2695#define BNX2_TDMA_PAYLOAD_PROD_VALUE (0x1fffL<<3)
2696
2697#define BNX2_TDMA_DBG_WATCHDOG 0x00005c10
2698#define BNX2_TDMA_DBG_TRIGGER 0x00005c14
2699#define BNX2_TDMA_DMAD_FSM 0x00005c80
2700#define BNX2_TDMA_DMAD_FSM_BD_INVLD (1L<<0)
2701#define BNX2_TDMA_DMAD_FSM_PUSH (0xfL<<4)
2702#define BNX2_TDMA_DMAD_FSM_ARB_TBDC (0x3L<<8)
2703#define BNX2_TDMA_DMAD_FSM_ARB_CTX (1L<<12)
2704#define BNX2_TDMA_DMAD_FSM_DR_INTF (1L<<16)
2705#define BNX2_TDMA_DMAD_FSM_DMAD (0x7L<<20)
2706#define BNX2_TDMA_DMAD_FSM_BD (0xfL<<24)
2707
2708#define BNX2_TDMA_DMAD_STATUS 0x00005c84
2709#define BNX2_TDMA_DMAD_STATUS_RHOLD_PUSH_ENTRY (0x3L<<0)
2710#define BNX2_TDMA_DMAD_STATUS_RHOLD_DMAD_ENTRY (0x3L<<4)
2711#define BNX2_TDMA_DMAD_STATUS_RHOLD_BD_ENTRY (0x3L<<8)
2712#define BNX2_TDMA_DMAD_STATUS_IFTQ_ENUM (0xfL<<12)
2713
2714#define BNX2_TDMA_DR_INTF_FSM 0x00005c88
2715#define BNX2_TDMA_DR_INTF_FSM_L2_COMP (0x3L<<0)
2716#define BNX2_TDMA_DR_INTF_FSM_TPATQ (0x7L<<4)
2717#define BNX2_TDMA_DR_INTF_FSM_TPBUF (0x3L<<8)
2718#define BNX2_TDMA_DR_INTF_FSM_DR_BUF (0x7L<<12)
2719#define BNX2_TDMA_DR_INTF_FSM_DMAD (0x7L<<16)
2720
2721#define BNX2_TDMA_DR_INTF_STATUS 0x00005c8c
2722#define BNX2_TDMA_DR_INTF_STATUS_HOLE_PHASE (0x7L<<0)
2723#define BNX2_TDMA_DR_INTF_STATUS_DATA_AVAIL (0x3L<<4)
2724#define BNX2_TDMA_DR_INTF_STATUS_SHIFT_ADDR (0x7L<<8)
2725#define BNX2_TDMA_DR_INTF_STATUS_NXT_PNTR (0xfL<<12)
2726#define BNX2_TDMA_DR_INTF_STATUS_BYTE_COUNT (0x7L<<16)
2727
2728#define BNX2_TDMA_FTQ_DATA 0x00005fc0
2729#define BNX2_TDMA_FTQ_CMD 0x00005ff8
2730#define BNX2_TDMA_FTQ_CMD_OFFSET (0x3ffL<<0)
2731#define BNX2_TDMA_FTQ_CMD_WR_TOP (1L<<10)
2732#define BNX2_TDMA_FTQ_CMD_WR_TOP_0 (0L<<10)
2733#define BNX2_TDMA_FTQ_CMD_WR_TOP_1 (1L<<10)
2734#define BNX2_TDMA_FTQ_CMD_SFT_RESET (1L<<25)
2735#define BNX2_TDMA_FTQ_CMD_RD_DATA (1L<<26)
2736#define BNX2_TDMA_FTQ_CMD_ADD_INTERVEN (1L<<27)
2737#define BNX2_TDMA_FTQ_CMD_ADD_DATA (1L<<28)
2738#define BNX2_TDMA_FTQ_CMD_INTERVENE_CLR (1L<<29)
2739#define BNX2_TDMA_FTQ_CMD_POP (1L<<30)
2740#define BNX2_TDMA_FTQ_CMD_BUSY (1L<<31)
2741
2742#define BNX2_TDMA_FTQ_CTL 0x00005ffc
2743#define BNX2_TDMA_FTQ_CTL_INTERVENE (1L<<0)
2744#define BNX2_TDMA_FTQ_CTL_OVERFLOW (1L<<1)
2745#define BNX2_TDMA_FTQ_CTL_FORCE_INTERVENE (1L<<2)
2746#define BNX2_TDMA_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
2747#define BNX2_TDMA_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
2748
2749
2750
2751/*
2752 * hc_reg definition
2753 * offset: 0x6800
2754 */
2755#define BNX2_HC_COMMAND 0x00006800
2756#define BNX2_HC_COMMAND_ENABLE (1L<<0)
2757#define BNX2_HC_COMMAND_SKIP_ABORT (1L<<4)
2758#define BNX2_HC_COMMAND_COAL_NOW (1L<<16)
2759#define BNX2_HC_COMMAND_COAL_NOW_WO_INT (1L<<17)
2760#define BNX2_HC_COMMAND_STATS_NOW (1L<<18)
2761#define BNX2_HC_COMMAND_FORCE_INT (0x3L<<19)
2762#define BNX2_HC_COMMAND_FORCE_INT_NULL (0L<<19)
2763#define BNX2_HC_COMMAND_FORCE_INT_HIGH (1L<<19)
2764#define BNX2_HC_COMMAND_FORCE_INT_LOW (2L<<19)
2765#define BNX2_HC_COMMAND_FORCE_INT_FREE (3L<<19)
2766#define BNX2_HC_COMMAND_CLR_STAT_NOW (1L<<21)
2767
2768#define BNX2_HC_STATUS 0x00006804
2769#define BNX2_HC_STATUS_MASTER_ABORT (1L<<0)
2770#define BNX2_HC_STATUS_PARITY_ERROR_STATE (1L<<1)
2771#define BNX2_HC_STATUS_PCI_CLK_CNT_STAT (1L<<16)
2772#define BNX2_HC_STATUS_CORE_CLK_CNT_STAT (1L<<17)
2773#define BNX2_HC_STATUS_NUM_STATUS_BLOCKS_STAT (1L<<18)
2774#define BNX2_HC_STATUS_NUM_INT_GEN_STAT (1L<<19)
2775#define BNX2_HC_STATUS_NUM_INT_MBOX_WR_STAT (1L<<20)
2776#define BNX2_HC_STATUS_CORE_CLKS_TO_HW_INTACK_STAT (1L<<23)
2777#define BNX2_HC_STATUS_CORE_CLKS_TO_SW_INTACK_STAT (1L<<24)
2778#define BNX2_HC_STATUS_CORE_CLKS_DURING_SW_INTACK_STAT (1L<<25)
2779
2780#define BNX2_HC_CONFIG 0x00006808
2781#define BNX2_HC_CONFIG_COLLECT_STATS (1L<<0)
2782#define BNX2_HC_CONFIG_RX_TMR_MODE (1L<<1)
2783#define BNX2_HC_CONFIG_TX_TMR_MODE (1L<<2)
2784#define BNX2_HC_CONFIG_COM_TMR_MODE (1L<<3)
2785#define BNX2_HC_CONFIG_CMD_TMR_MODE (1L<<4)
2786#define BNX2_HC_CONFIG_STATISTIC_PRIORITY (1L<<5)
2787#define BNX2_HC_CONFIG_STATUS_PRIORITY (1L<<6)
2788#define BNX2_HC_CONFIG_STAT_MEM_ADDR (0xffL<<8)
2789
2790#define BNX2_HC_ATTN_BITS_ENABLE 0x0000680c
2791#define BNX2_HC_STATUS_ADDR_L 0x00006810
2792#define BNX2_HC_STATUS_ADDR_H 0x00006814
2793#define BNX2_HC_STATISTICS_ADDR_L 0x00006818
2794#define BNX2_HC_STATISTICS_ADDR_H 0x0000681c
2795#define BNX2_HC_TX_QUICK_CONS_TRIP 0x00006820
2796#define BNX2_HC_TX_QUICK_CONS_TRIP_VALUE (0xffL<<0)
2797#define BNX2_HC_TX_QUICK_CONS_TRIP_INT (0xffL<<16)
2798
2799#define BNX2_HC_COMP_PROD_TRIP 0x00006824
2800#define BNX2_HC_COMP_PROD_TRIP_VALUE (0xffL<<0)
2801#define BNX2_HC_COMP_PROD_TRIP_INT (0xffL<<16)
2802
2803#define BNX2_HC_RX_QUICK_CONS_TRIP 0x00006828
2804#define BNX2_HC_RX_QUICK_CONS_TRIP_VALUE (0xffL<<0)
2805#define BNX2_HC_RX_QUICK_CONS_TRIP_INT (0xffL<<16)
2806
2807#define BNX2_HC_RX_TICKS 0x0000682c
2808#define BNX2_HC_RX_TICKS_VALUE (0x3ffL<<0)
2809#define BNX2_HC_RX_TICKS_INT (0x3ffL<<16)
2810
2811#define BNX2_HC_TX_TICKS 0x00006830
2812#define BNX2_HC_TX_TICKS_VALUE (0x3ffL<<0)
2813#define BNX2_HC_TX_TICKS_INT (0x3ffL<<16)
2814
2815#define BNX2_HC_COM_TICKS 0x00006834
2816#define BNX2_HC_COM_TICKS_VALUE (0x3ffL<<0)
2817#define BNX2_HC_COM_TICKS_INT (0x3ffL<<16)
2818
2819#define BNX2_HC_CMD_TICKS 0x00006838
2820#define BNX2_HC_CMD_TICKS_VALUE (0x3ffL<<0)
2821#define BNX2_HC_CMD_TICKS_INT (0x3ffL<<16)
2822
2823#define BNX2_HC_PERIODIC_TICKS 0x0000683c
2824#define BNX2_HC_PERIODIC_TICKS_HC_PERIODIC_TICKS (0xffffL<<0)
2825
2826#define BNX2_HC_STAT_COLLECT_TICKS 0x00006840
2827#define BNX2_HC_STAT_COLLECT_TICKS_HC_STAT_COLL_TICKS (0xffL<<4)
2828
2829#define BNX2_HC_STATS_TICKS 0x00006844
2830#define BNX2_HC_STATS_TICKS_HC_STAT_TICKS (0xffffL<<8)
2831
2832#define BNX2_HC_STAT_MEM_DATA 0x0000684c
2833#define BNX2_HC_STAT_GEN_SEL_0 0x00006850
2834#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0 (0x7fL<<0)
2835#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT0 (0L<<0)
2836#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT1 (1L<<0)
2837#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT2 (2L<<0)
2838#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT3 (3L<<0)
2839#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT4 (4L<<0)
2840#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT5 (5L<<0)
2841#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT6 (6L<<0)
2842#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT7 (7L<<0)
2843#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT8 (8L<<0)
2844#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT9 (9L<<0)
2845#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT10 (10L<<0)
2846#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXP_STAT11 (11L<<0)
2847#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TXP_STAT0 (12L<<0)
2848#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TXP_STAT1 (13L<<0)
2849#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TXP_STAT2 (14L<<0)
2850#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TXP_STAT3 (15L<<0)
2851#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TXP_STAT4 (16L<<0)
2852#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TXP_STAT5 (17L<<0)
2853#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TXP_STAT6 (18L<<0)
2854#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TXP_STAT7 (19L<<0)
2855#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT0 (20L<<0)
2856#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT1 (21L<<0)
2857#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT2 (22L<<0)
2858#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT3 (23L<<0)
2859#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT4 (24L<<0)
2860#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT5 (25L<<0)
2861#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT6 (26L<<0)
2862#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT7 (27L<<0)
2863#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT8 (28L<<0)
2864#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT9 (29L<<0)
2865#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT10 (30L<<0)
2866#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COM_STAT11 (31L<<0)
2867#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TPAT_STAT0 (32L<<0)
2868#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TPAT_STAT1 (33L<<0)
2869#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TPAT_STAT2 (34L<<0)
2870#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TPAT_STAT3 (35L<<0)
2871#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CP_STAT0 (36L<<0)
2872#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CP_STAT1 (37L<<0)
2873#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CP_STAT2 (38L<<0)
2874#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CP_STAT3 (39L<<0)
2875#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CP_STAT4 (40L<<0)
2876#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CP_STAT5 (41L<<0)
2877#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CP_STAT6 (42L<<0)
2878#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CP_STAT7 (43L<<0)
2879#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MCP_STAT0 (44L<<0)
2880#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MCP_STAT1 (45L<<0)
2881#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MCP_STAT2 (46L<<0)
2882#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MCP_STAT3 (47L<<0)
2883#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MCP_STAT4 (48L<<0)
2884#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MCP_STAT5 (49L<<0)
2885#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MCP_STAT6 (50L<<0)
2886#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MCP_STAT7 (51L<<0)
2887#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_PCI_CLK_CNT (52L<<0)
2888#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CORE_CLK_CNT (53L<<0)
2889#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS (54L<<0)
2890#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN (55L<<0)
2891#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR (56L<<0)
2892#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK (59L<<0)
2893#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK (60L<<0)
2894#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK (61L<<0)
2895#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TSCH_CMD_CNT (62L<<0)
2896#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TSCH_SLOT_CNT (63L<<0)
2897#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CSCH_CMD_CNT (64L<<0)
2898#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CSCH_SLOT_CNT (65L<<0)
2899#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RLUPQ_VALID_CNT (66L<<0)
2900#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXPQ_VALID_CNT (67L<<0)
2901#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RXPCQ_VALID_CNT (68L<<0)
2902#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2PPQ_VALID_CNT (69L<<0)
2903#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2PMQ_VALID_CNT (70L<<0)
2904#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2PTQ_VALID_CNT (71L<<0)
2905#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RDMAQ_VALID_CNT (72L<<0)
2906#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TSCHQ_VALID_CNT (73L<<0)
2907#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TBDRQ_VALID_CNT (74L<<0)
2908#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TXPQ_VALID_CNT (75L<<0)
2909#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TDMAQ_VALID_CNT (76L<<0)
2910#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TPATQ_VALID_CNT (77L<<0)
2911#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TASQ_VALID_CNT (78L<<0)
2912#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CSQ_VALID_CNT (79L<<0)
2913#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CPQ_VALID_CNT (80L<<0)
2914#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COMXQ_VALID_CNT (81L<<0)
2915#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COMTQ_VALID_CNT (82L<<0)
2916#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_COMQ_VALID_CNT (83L<<0)
2917#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MGMQ_VALID_CNT (84L<<0)
2918#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_DMAE_READ_TRANSFERS_CNT (85L<<0)
2919#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_DMAE_READ_DELAY_PCI_CLKS_CNT (86L<<0)
2920#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_DMAE_BIG_READ_TRANSFERS_CNT (87L<<0)
2921#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_DMAE_BIG_READ_DELAY_PCI_CLKS_CNT (88L<<0)
2922#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_DMAE_BIG_READ_RETRY_AFTER_DATA_CNT (89L<<0)
2923#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_DMAE_WRITE_TRANSFERS_CNT (90L<<0)
2924#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_DMAE_WRITE_DELAY_PCI_CLKS_CNT (91L<<0)
2925#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_DMAE_BIG_WRITE_TRANSFERS_CNT (92L<<0)
2926#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_DMAE_BIG_WRITE_DELAY_PCI_CLKS_CNT (93L<<0)
2927#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_DMAE_BIG_WRITE_RETRY_AFTER_DATA_CNT (94L<<0)
2928#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_WR_CNT64 (95L<<0)
2929#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_RD_CNT64 (96L<<0)
2930#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_ACC_STALL_CLKS (97L<<0)
2931#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_LOCK_STALL_CLKS (98L<<0)
2932#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MBQ_CTX_ACCESS_STAT (99L<<0)
2933#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MBQ_CTX_ACCESS64_STAT (100L<<0)
2934#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MBQ_PCI_STALL_STAT (101L<<0)
2935#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TBDR_FTQ_ENTRY_CNT (102L<<0)
2936#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TBDR_BURST_CNT (103L<<0)
2937#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TDMA_FTQ_ENTRY_CNT (104L<<0)
2938#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TDMA_BURST_CNT (105L<<0)
2939#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RDMA_FTQ_ENTRY_CNT (106L<<0)
2940#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RDMA_BURST_CNT (107L<<0)
2941#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RLUP_MATCH_CNT (108L<<0)
2942#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TMR_POLL_PASS_CNT (109L<<0)
2943#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TMR_TMR1_CNT (110L<<0)
2944#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TMR_TMR2_CNT (111L<<0)
2945#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TMR_TMR3_CNT (112L<<0)
2946#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TMR_TMR4_CNT (113L<<0)
2947#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_TMR_TMR5_CNT (114L<<0)
2948#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2P_STAT0 (115L<<0)
2949#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2P_STAT1 (116L<<0)
2950#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2P_STAT2 (117L<<0)
2951#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2P_STAT3 (118L<<0)
2952#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2P_STAT4 (119L<<0)
2953#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2P_STAT5 (120L<<0)
2954#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RBDC_PROC1_MISS (121L<<0)
2955#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RBDC_PROC2_MISS (122L<<0)
2956#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RBDC_BURST_CNT (127L<<0)
2957#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_1 (0x7fL<<8)
2958#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_2 (0x7fL<<16)
2959#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_3 (0x7fL<<24)
2960
2961#define BNX2_HC_STAT_GEN_SEL_1 0x00006854
2962#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_4 (0x7fL<<0)
2963#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_5 (0x7fL<<8)
2964#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_6 (0x7fL<<16)
2965#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_7 (0x7fL<<24)
2966
2967#define BNX2_HC_STAT_GEN_SEL_2 0x00006858
2968#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_8 (0x7fL<<0)
2969#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_9 (0x7fL<<8)
2970#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_10 (0x7fL<<16)
2971#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_11 (0x7fL<<24)
2972
2973#define BNX2_HC_STAT_GEN_SEL_3 0x0000685c
2974#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_12 (0x7fL<<0)
2975#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_13 (0x7fL<<8)
2976#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_14 (0x7fL<<16)
2977#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_15 (0x7fL<<24)
2978
2979#define BNX2_HC_STAT_GEN_STAT0 0x00006888
2980#define BNX2_HC_STAT_GEN_STAT1 0x0000688c
2981#define BNX2_HC_STAT_GEN_STAT2 0x00006890
2982#define BNX2_HC_STAT_GEN_STAT3 0x00006894
2983#define BNX2_HC_STAT_GEN_STAT4 0x00006898
2984#define BNX2_HC_STAT_GEN_STAT5 0x0000689c
2985#define BNX2_HC_STAT_GEN_STAT6 0x000068a0
2986#define BNX2_HC_STAT_GEN_STAT7 0x000068a4
2987#define BNX2_HC_STAT_GEN_STAT8 0x000068a8
2988#define BNX2_HC_STAT_GEN_STAT9 0x000068ac
2989#define BNX2_HC_STAT_GEN_STAT10 0x000068b0
2990#define BNX2_HC_STAT_GEN_STAT11 0x000068b4
2991#define BNX2_HC_STAT_GEN_STAT12 0x000068b8
2992#define BNX2_HC_STAT_GEN_STAT13 0x000068bc
2993#define BNX2_HC_STAT_GEN_STAT14 0x000068c0
2994#define BNX2_HC_STAT_GEN_STAT15 0x000068c4
2995#define BNX2_HC_STAT_GEN_STAT_AC0 0x000068c8
2996#define BNX2_HC_STAT_GEN_STAT_AC1 0x000068cc
2997#define BNX2_HC_STAT_GEN_STAT_AC2 0x000068d0
2998#define BNX2_HC_STAT_GEN_STAT_AC3 0x000068d4
2999#define BNX2_HC_STAT_GEN_STAT_AC4 0x000068d8
3000#define BNX2_HC_STAT_GEN_STAT_AC5 0x000068dc
3001#define BNX2_HC_STAT_GEN_STAT_AC6 0x000068e0
3002#define BNX2_HC_STAT_GEN_STAT_AC7 0x000068e4
3003#define BNX2_HC_STAT_GEN_STAT_AC8 0x000068e8
3004#define BNX2_HC_STAT_GEN_STAT_AC9 0x000068ec
3005#define BNX2_HC_STAT_GEN_STAT_AC10 0x000068f0
3006#define BNX2_HC_STAT_GEN_STAT_AC11 0x000068f4
3007#define BNX2_HC_STAT_GEN_STAT_AC12 0x000068f8
3008#define BNX2_HC_STAT_GEN_STAT_AC13 0x000068fc
3009#define BNX2_HC_STAT_GEN_STAT_AC14 0x00006900
3010#define BNX2_HC_STAT_GEN_STAT_AC15 0x00006904
3011#define BNX2_HC_VIS 0x00006908
3012#define BNX2_HC_VIS_STAT_BUILD_STATE (0xfL<<0)
3013#define BNX2_HC_VIS_STAT_BUILD_STATE_IDLE (0L<<0)
3014#define BNX2_HC_VIS_STAT_BUILD_STATE_START (1L<<0)
3015#define BNX2_HC_VIS_STAT_BUILD_STATE_REQUEST (2L<<0)
3016#define BNX2_HC_VIS_STAT_BUILD_STATE_UPDATE64 (3L<<0)
3017#define BNX2_HC_VIS_STAT_BUILD_STATE_UPDATE32 (4L<<0)
3018#define BNX2_HC_VIS_STAT_BUILD_STATE_UPDATE_DONE (5L<<0)
3019#define BNX2_HC_VIS_STAT_BUILD_STATE_DMA (6L<<0)
3020#define BNX2_HC_VIS_STAT_BUILD_STATE_MSI_CONTROL (7L<<0)
3021#define BNX2_HC_VIS_STAT_BUILD_STATE_MSI_LOW (8L<<0)
3022#define BNX2_HC_VIS_STAT_BUILD_STATE_MSI_HIGH (9L<<0)
3023#define BNX2_HC_VIS_STAT_BUILD_STATE_MSI_DATA (10L<<0)
3024#define BNX2_HC_VIS_DMA_STAT_STATE (0xfL<<8)
3025#define BNX2_HC_VIS_DMA_STAT_STATE_IDLE (0L<<8)
3026#define BNX2_HC_VIS_DMA_STAT_STATE_STATUS_PARAM (1L<<8)
3027#define BNX2_HC_VIS_DMA_STAT_STATE_STATUS_DMA (2L<<8)
3028#define BNX2_HC_VIS_DMA_STAT_STATE_WRITE_COMP (3L<<8)
3029#define BNX2_HC_VIS_DMA_STAT_STATE_COMP (4L<<8)
3030#define BNX2_HC_VIS_DMA_STAT_STATE_STATISTIC_PARAM (5L<<8)
3031#define BNX2_HC_VIS_DMA_STAT_STATE_STATISTIC_DMA (6L<<8)
3032#define BNX2_HC_VIS_DMA_STAT_STATE_WRITE_COMP_1 (7L<<8)
3033#define BNX2_HC_VIS_DMA_STAT_STATE_WRITE_COMP_2 (8L<<8)
3034#define BNX2_HC_VIS_DMA_STAT_STATE_WAIT (9L<<8)
3035#define BNX2_HC_VIS_DMA_STAT_STATE_ABORT (15L<<8)
3036#define BNX2_HC_VIS_DMA_MSI_STATE (0x7L<<12)
3037#define BNX2_HC_VIS_STATISTIC_DMA_EN_STATE (0x3L<<15)
3038#define BNX2_HC_VIS_STATISTIC_DMA_EN_STATE_IDLE (0L<<15)
3039#define BNX2_HC_VIS_STATISTIC_DMA_EN_STATE_COUNT (1L<<15)
3040#define BNX2_HC_VIS_STATISTIC_DMA_EN_STATE_START (2L<<15)
3041
3042#define BNX2_HC_VIS_1 0x0000690c
3043#define BNX2_HC_VIS_1_HW_INTACK_STATE (1L<<4)
3044#define BNX2_HC_VIS_1_HW_INTACK_STATE_IDLE (0L<<4)
3045#define BNX2_HC_VIS_1_HW_INTACK_STATE_COUNT (1L<<4)
3046#define BNX2_HC_VIS_1_SW_INTACK_STATE (1L<<5)
3047#define BNX2_HC_VIS_1_SW_INTACK_STATE_IDLE (0L<<5)
3048#define BNX2_HC_VIS_1_SW_INTACK_STATE_COUNT (1L<<5)
3049#define BNX2_HC_VIS_1_DURING_SW_INTACK_STATE (1L<<6)
3050#define BNX2_HC_VIS_1_DURING_SW_INTACK_STATE_IDLE (0L<<6)
3051#define BNX2_HC_VIS_1_DURING_SW_INTACK_STATE_COUNT (1L<<6)
3052#define BNX2_HC_VIS_1_MAILBOX_COUNT_STATE (1L<<7)
3053#define BNX2_HC_VIS_1_MAILBOX_COUNT_STATE_IDLE (0L<<7)
3054#define BNX2_HC_VIS_1_MAILBOX_COUNT_STATE_COUNT (1L<<7)
3055#define BNX2_HC_VIS_1_RAM_RD_ARB_STATE (0xfL<<17)
3056#define BNX2_HC_VIS_1_RAM_RD_ARB_STATE_IDLE (0L<<17)
3057#define BNX2_HC_VIS_1_RAM_RD_ARB_STATE_DMA (1L<<17)
3058#define BNX2_HC_VIS_1_RAM_RD_ARB_STATE_UPDATE (2L<<17)
3059#define BNX2_HC_VIS_1_RAM_RD_ARB_STATE_ASSIGN (3L<<17)
3060#define BNX2_HC_VIS_1_RAM_RD_ARB_STATE_WAIT (4L<<17)
3061#define BNX2_HC_VIS_1_RAM_RD_ARB_STATE_REG_UPDATE (5L<<17)
3062#define BNX2_HC_VIS_1_RAM_RD_ARB_STATE_REG_ASSIGN (6L<<17)
3063#define BNX2_HC_VIS_1_RAM_RD_ARB_STATE_REG_WAIT (7L<<17)
3064#define BNX2_HC_VIS_1_RAM_WR_ARB_STATE (0x3L<<21)
3065#define BNX2_HC_VIS_1_RAM_WR_ARB_STATE_NORMAL (0L<<21)
3066#define BNX2_HC_VIS_1_RAM_WR_ARB_STATE_CLEAR (1L<<21)
3067#define BNX2_HC_VIS_1_INT_GEN_STATE (1L<<23)
3068#define BNX2_HC_VIS_1_INT_GEN_STATE_DLE (0L<<23)
3069#define BNX2_HC_VIS_1_INT_GEN_STATE_NTERRUPT (1L<<23)
3070#define BNX2_HC_VIS_1_STAT_CHAN_ID (0x7L<<24)
3071#define BNX2_HC_VIS_1_INT_B (1L<<27)
3072
3073#define BNX2_HC_DEBUG_VECT_PEEK 0x00006910
3074#define BNX2_HC_DEBUG_VECT_PEEK_1_VALUE (0x7ffL<<0)
3075#define BNX2_HC_DEBUG_VECT_PEEK_1_PEEK_EN (1L<<11)
3076#define BNX2_HC_DEBUG_VECT_PEEK_1_SEL (0xfL<<12)
3077#define BNX2_HC_DEBUG_VECT_PEEK_2_VALUE (0x7ffL<<16)
3078#define BNX2_HC_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
3079#define BNX2_HC_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
3080
3081
3082
3083/*
3084 * txp_reg definition
3085 * offset: 0x40000
3086 */
3087#define BNX2_TXP_CPU_MODE 0x00045000
3088#define BNX2_TXP_CPU_MODE_LOCAL_RST (1L<<0)
3089#define BNX2_TXP_CPU_MODE_STEP_ENA (1L<<1)
3090#define BNX2_TXP_CPU_MODE_PAGE_0_DATA_ENA (1L<<2)
3091#define BNX2_TXP_CPU_MODE_PAGE_0_INST_ENA (1L<<3)
3092#define BNX2_TXP_CPU_MODE_MSG_BIT1 (1L<<6)
3093#define BNX2_TXP_CPU_MODE_INTERRUPT_ENA (1L<<7)
3094#define BNX2_TXP_CPU_MODE_SOFT_HALT (1L<<10)
3095#define BNX2_TXP_CPU_MODE_BAD_DATA_HALT_ENA (1L<<11)
3096#define BNX2_TXP_CPU_MODE_BAD_INST_HALT_ENA (1L<<12)
3097#define BNX2_TXP_CPU_MODE_FIO_ABORT_HALT_ENA (1L<<13)
3098#define BNX2_TXP_CPU_MODE_SPAD_UNDERFLOW_HALT_ENA (1L<<15)
3099
3100#define BNX2_TXP_CPU_STATE 0x00045004
3101#define BNX2_TXP_CPU_STATE_BREAKPOINT (1L<<0)
3102#define BNX2_TXP_CPU_STATE_BAD_INST_HALTED (1L<<2)
3103#define BNX2_TXP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3104#define BNX2_TXP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3105#define BNX2_TXP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3106#define BNX2_TXP_CPU_STATE_BAD_pc_HALTED (1L<<6)
3107#define BNX2_TXP_CPU_STATE_ALIGN_HALTED (1L<<7)
3108#define BNX2_TXP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3109#define BNX2_TXP_CPU_STATE_SOFT_HALTED (1L<<10)
3110#define BNX2_TXP_CPU_STATE_SPAD_UNDERFLOW (1L<<11)
3111#define BNX2_TXP_CPU_STATE_INTERRRUPT (1L<<12)
3112#define BNX2_TXP_CPU_STATE_DATA_ACCESS_STALL (1L<<14)
3113#define BNX2_TXP_CPU_STATE_INST_FETCH_STALL (1L<<15)
3114#define BNX2_TXP_CPU_STATE_BLOCKED_READ (1L<<31)
3115
3116#define BNX2_TXP_CPU_EVENT_MASK 0x00045008
3117#define BNX2_TXP_CPU_EVENT_MASK_BREAKPOINT_MASK (1L<<0)
3118#define BNX2_TXP_CPU_EVENT_MASK_BAD_INST_HALTED_MASK (1L<<2)
3119#define BNX2_TXP_CPU_EVENT_MASK_PAGE_0_DATA_HALTED_MASK (1L<<3)
3120#define BNX2_TXP_CPU_EVENT_MASK_PAGE_0_INST_HALTED_MASK (1L<<4)
3121#define BNX2_TXP_CPU_EVENT_MASK_BAD_DATA_ADDR_HALTED_MASK (1L<<5)
3122#define BNX2_TXP_CPU_EVENT_MASK_BAD_PC_HALTED_MASK (1L<<6)
3123#define BNX2_TXP_CPU_EVENT_MASK_ALIGN_HALTED_MASK (1L<<7)
3124#define BNX2_TXP_CPU_EVENT_MASK_FIO_ABORT_MASK (1L<<8)
3125#define BNX2_TXP_CPU_EVENT_MASK_SOFT_HALTED_MASK (1L<<10)
3126#define BNX2_TXP_CPU_EVENT_MASK_SPAD_UNDERFLOW_MASK (1L<<11)
3127#define BNX2_TXP_CPU_EVENT_MASK_INTERRUPT_MASK (1L<<12)
3128
3129#define BNX2_TXP_CPU_PROGRAM_COUNTER 0x0004501c
3130#define BNX2_TXP_CPU_INSTRUCTION 0x00045020
3131#define BNX2_TXP_CPU_DATA_ACCESS 0x00045024
3132#define BNX2_TXP_CPU_INTERRUPT_ENABLE 0x00045028
3133#define BNX2_TXP_CPU_INTERRUPT_VECTOR 0x0004502c
3134#define BNX2_TXP_CPU_INTERRUPT_SAVED_PC 0x00045030
3135#define BNX2_TXP_CPU_HW_BREAKPOINT 0x00045034
3136#define BNX2_TXP_CPU_HW_BREAKPOINT_DISABLE (1L<<0)
3137#define BNX2_TXP_CPU_HW_BREAKPOINT_ADDRESS (0x3fffffffL<<2)
3138
3139#define BNX2_TXP_CPU_DEBUG_VECT_PEEK 0x00045038
3140#define BNX2_TXP_CPU_DEBUG_VECT_PEEK_1_VALUE (0x7ffL<<0)
3141#define BNX2_TXP_CPU_DEBUG_VECT_PEEK_1_PEEK_EN (1L<<11)
3142#define BNX2_TXP_CPU_DEBUG_VECT_PEEK_1_SEL (0xfL<<12)
3143#define BNX2_TXP_CPU_DEBUG_VECT_PEEK_2_VALUE (0x7ffL<<16)
3144#define BNX2_TXP_CPU_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
3145#define BNX2_TXP_CPU_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
3146
3147#define BNX2_TXP_CPU_LAST_BRANCH_ADDR 0x00045048
3148#define BNX2_TXP_CPU_LAST_BRANCH_ADDR_TYPE (1L<<1)
3149#define BNX2_TXP_CPU_LAST_BRANCH_ADDR_TYPE_JUMP (0L<<1)
3150#define BNX2_TXP_CPU_LAST_BRANCH_ADDR_TYPE_BRANCH (1L<<1)
3151#define BNX2_TXP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3152
3153#define BNX2_TXP_CPU_REG_FILE 0x00045200
3154#define BNX2_TXP_FTQ_DATA 0x000453c0
3155#define BNX2_TXP_FTQ_CMD 0x000453f8
3156#define BNX2_TXP_FTQ_CMD_OFFSET (0x3ffL<<0)
3157#define BNX2_TXP_FTQ_CMD_WR_TOP (1L<<10)
3158#define BNX2_TXP_FTQ_CMD_WR_TOP_0 (0L<<10)
3159#define BNX2_TXP_FTQ_CMD_WR_TOP_1 (1L<<10)
3160#define BNX2_TXP_FTQ_CMD_SFT_RESET (1L<<25)
3161#define BNX2_TXP_FTQ_CMD_RD_DATA (1L<<26)
3162#define BNX2_TXP_FTQ_CMD_ADD_INTERVEN (1L<<27)
3163#define BNX2_TXP_FTQ_CMD_ADD_DATA (1L<<28)
3164#define BNX2_TXP_FTQ_CMD_INTERVENE_CLR (1L<<29)
3165#define BNX2_TXP_FTQ_CMD_POP (1L<<30)
3166#define BNX2_TXP_FTQ_CMD_BUSY (1L<<31)
3167
3168#define BNX2_TXP_FTQ_CTL 0x000453fc
3169#define BNX2_TXP_FTQ_CTL_INTERVENE (1L<<0)
3170#define BNX2_TXP_FTQ_CTL_OVERFLOW (1L<<1)
3171#define BNX2_TXP_FTQ_CTL_FORCE_INTERVENE (1L<<2)
3172#define BNX2_TXP_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3173#define BNX2_TXP_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3174
3175#define BNX2_TXP_SCRATCH 0x00060000
3176
3177
3178/*
3179 * tpat_reg definition
3180 * offset: 0x80000
3181 */
3182#define BNX2_TPAT_CPU_MODE 0x00085000
3183#define BNX2_TPAT_CPU_MODE_LOCAL_RST (1L<<0)
3184#define BNX2_TPAT_CPU_MODE_STEP_ENA (1L<<1)
3185#define BNX2_TPAT_CPU_MODE_PAGE_0_DATA_ENA (1L<<2)
3186#define BNX2_TPAT_CPU_MODE_PAGE_0_INST_ENA (1L<<3)
3187#define BNX2_TPAT_CPU_MODE_MSG_BIT1 (1L<<6)
3188#define BNX2_TPAT_CPU_MODE_INTERRUPT_ENA (1L<<7)
3189#define BNX2_TPAT_CPU_MODE_SOFT_HALT (1L<<10)
3190#define BNX2_TPAT_CPU_MODE_BAD_DATA_HALT_ENA (1L<<11)
3191#define BNX2_TPAT_CPU_MODE_BAD_INST_HALT_ENA (1L<<12)
3192#define BNX2_TPAT_CPU_MODE_FIO_ABORT_HALT_ENA (1L<<13)
3193#define BNX2_TPAT_CPU_MODE_SPAD_UNDERFLOW_HALT_ENA (1L<<15)
3194
3195#define BNX2_TPAT_CPU_STATE 0x00085004
3196#define BNX2_TPAT_CPU_STATE_BREAKPOINT (1L<<0)
3197#define BNX2_TPAT_CPU_STATE_BAD_INST_HALTED (1L<<2)
3198#define BNX2_TPAT_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3199#define BNX2_TPAT_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3200#define BNX2_TPAT_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3201#define BNX2_TPAT_CPU_STATE_BAD_pc_HALTED (1L<<6)
3202#define BNX2_TPAT_CPU_STATE_ALIGN_HALTED (1L<<7)
3203#define BNX2_TPAT_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3204#define BNX2_TPAT_CPU_STATE_SOFT_HALTED (1L<<10)
3205#define BNX2_TPAT_CPU_STATE_SPAD_UNDERFLOW (1L<<11)
3206#define BNX2_TPAT_CPU_STATE_INTERRRUPT (1L<<12)
3207#define BNX2_TPAT_CPU_STATE_DATA_ACCESS_STALL (1L<<14)
3208#define BNX2_TPAT_CPU_STATE_INST_FETCH_STALL (1L<<15)
3209#define BNX2_TPAT_CPU_STATE_BLOCKED_READ (1L<<31)
3210
3211#define BNX2_TPAT_CPU_EVENT_MASK 0x00085008
3212#define BNX2_TPAT_CPU_EVENT_MASK_BREAKPOINT_MASK (1L<<0)
3213#define BNX2_TPAT_CPU_EVENT_MASK_BAD_INST_HALTED_MASK (1L<<2)
3214#define BNX2_TPAT_CPU_EVENT_MASK_PAGE_0_DATA_HALTED_MASK (1L<<3)
3215#define BNX2_TPAT_CPU_EVENT_MASK_PAGE_0_INST_HALTED_MASK (1L<<4)
3216#define BNX2_TPAT_CPU_EVENT_MASK_BAD_DATA_ADDR_HALTED_MASK (1L<<5)
3217#define BNX2_TPAT_CPU_EVENT_MASK_BAD_PC_HALTED_MASK (1L<<6)
3218#define BNX2_TPAT_CPU_EVENT_MASK_ALIGN_HALTED_MASK (1L<<7)
3219#define BNX2_TPAT_CPU_EVENT_MASK_FIO_ABORT_MASK (1L<<8)
3220#define BNX2_TPAT_CPU_EVENT_MASK_SOFT_HALTED_MASK (1L<<10)
3221#define BNX2_TPAT_CPU_EVENT_MASK_SPAD_UNDERFLOW_MASK (1L<<11)
3222#define BNX2_TPAT_CPU_EVENT_MASK_INTERRUPT_MASK (1L<<12)
3223
3224#define BNX2_TPAT_CPU_PROGRAM_COUNTER 0x0008501c
3225#define BNX2_TPAT_CPU_INSTRUCTION 0x00085020
3226#define BNX2_TPAT_CPU_DATA_ACCESS 0x00085024
3227#define BNX2_TPAT_CPU_INTERRUPT_ENABLE 0x00085028
3228#define BNX2_TPAT_CPU_INTERRUPT_VECTOR 0x0008502c
3229#define BNX2_TPAT_CPU_INTERRUPT_SAVED_PC 0x00085030
3230#define BNX2_TPAT_CPU_HW_BREAKPOINT 0x00085034
3231#define BNX2_TPAT_CPU_HW_BREAKPOINT_DISABLE (1L<<0)
3232#define BNX2_TPAT_CPU_HW_BREAKPOINT_ADDRESS (0x3fffffffL<<2)
3233
3234#define BNX2_TPAT_CPU_DEBUG_VECT_PEEK 0x00085038
3235#define BNX2_TPAT_CPU_DEBUG_VECT_PEEK_1_VALUE (0x7ffL<<0)
3236#define BNX2_TPAT_CPU_DEBUG_VECT_PEEK_1_PEEK_EN (1L<<11)
3237#define BNX2_TPAT_CPU_DEBUG_VECT_PEEK_1_SEL (0xfL<<12)
3238#define BNX2_TPAT_CPU_DEBUG_VECT_PEEK_2_VALUE (0x7ffL<<16)
3239#define BNX2_TPAT_CPU_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
3240#define BNX2_TPAT_CPU_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
3241
3242#define BNX2_TPAT_CPU_LAST_BRANCH_ADDR 0x00085048
3243#define BNX2_TPAT_CPU_LAST_BRANCH_ADDR_TYPE (1L<<1)
3244#define BNX2_TPAT_CPU_LAST_BRANCH_ADDR_TYPE_JUMP (0L<<1)
3245#define BNX2_TPAT_CPU_LAST_BRANCH_ADDR_TYPE_BRANCH (1L<<1)
3246#define BNX2_TPAT_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3247
3248#define BNX2_TPAT_CPU_REG_FILE 0x00085200
3249#define BNX2_TPAT_FTQ_DATA 0x000853c0
3250#define BNX2_TPAT_FTQ_CMD 0x000853f8
3251#define BNX2_TPAT_FTQ_CMD_OFFSET (0x3ffL<<0)
3252#define BNX2_TPAT_FTQ_CMD_WR_TOP (1L<<10)
3253#define BNX2_TPAT_FTQ_CMD_WR_TOP_0 (0L<<10)
3254#define BNX2_TPAT_FTQ_CMD_WR_TOP_1 (1L<<10)
3255#define BNX2_TPAT_FTQ_CMD_SFT_RESET (1L<<25)
3256#define BNX2_TPAT_FTQ_CMD_RD_DATA (1L<<26)
3257#define BNX2_TPAT_FTQ_CMD_ADD_INTERVEN (1L<<27)
3258#define BNX2_TPAT_FTQ_CMD_ADD_DATA (1L<<28)
3259#define BNX2_TPAT_FTQ_CMD_INTERVENE_CLR (1L<<29)
3260#define BNX2_TPAT_FTQ_CMD_POP (1L<<30)
3261#define BNX2_TPAT_FTQ_CMD_BUSY (1L<<31)
3262
3263#define BNX2_TPAT_FTQ_CTL 0x000853fc
3264#define BNX2_TPAT_FTQ_CTL_INTERVENE (1L<<0)
3265#define BNX2_TPAT_FTQ_CTL_OVERFLOW (1L<<1)
3266#define BNX2_TPAT_FTQ_CTL_FORCE_INTERVENE (1L<<2)
3267#define BNX2_TPAT_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3268#define BNX2_TPAT_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3269
3270#define BNX2_TPAT_SCRATCH 0x000a0000
3271
3272
3273/*
3274 * rxp_reg definition
3275 * offset: 0xc0000
3276 */
3277#define BNX2_RXP_CPU_MODE 0x000c5000
3278#define BNX2_RXP_CPU_MODE_LOCAL_RST (1L<<0)
3279#define BNX2_RXP_CPU_MODE_STEP_ENA (1L<<1)
3280#define BNX2_RXP_CPU_MODE_PAGE_0_DATA_ENA (1L<<2)
3281#define BNX2_RXP_CPU_MODE_PAGE_0_INST_ENA (1L<<3)
3282#define BNX2_RXP_CPU_MODE_MSG_BIT1 (1L<<6)
3283#define BNX2_RXP_CPU_MODE_INTERRUPT_ENA (1L<<7)
3284#define BNX2_RXP_CPU_MODE_SOFT_HALT (1L<<10)
3285#define BNX2_RXP_CPU_MODE_BAD_DATA_HALT_ENA (1L<<11)
3286#define BNX2_RXP_CPU_MODE_BAD_INST_HALT_ENA (1L<<12)
3287#define BNX2_RXP_CPU_MODE_FIO_ABORT_HALT_ENA (1L<<13)
3288#define BNX2_RXP_CPU_MODE_SPAD_UNDERFLOW_HALT_ENA (1L<<15)
3289
3290#define BNX2_RXP_CPU_STATE 0x000c5004
3291#define BNX2_RXP_CPU_STATE_BREAKPOINT (1L<<0)
3292#define BNX2_RXP_CPU_STATE_BAD_INST_HALTED (1L<<2)
3293#define BNX2_RXP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3294#define BNX2_RXP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3295#define BNX2_RXP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3296#define BNX2_RXP_CPU_STATE_BAD_pc_HALTED (1L<<6)
3297#define BNX2_RXP_CPU_STATE_ALIGN_HALTED (1L<<7)
3298#define BNX2_RXP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3299#define BNX2_RXP_CPU_STATE_SOFT_HALTED (1L<<10)
3300#define BNX2_RXP_CPU_STATE_SPAD_UNDERFLOW (1L<<11)
3301#define BNX2_RXP_CPU_STATE_INTERRRUPT (1L<<12)
3302#define BNX2_RXP_CPU_STATE_DATA_ACCESS_STALL (1L<<14)
3303#define BNX2_RXP_CPU_STATE_INST_FETCH_STALL (1L<<15)
3304#define BNX2_RXP_CPU_STATE_BLOCKED_READ (1L<<31)
3305
3306#define BNX2_RXP_CPU_EVENT_MASK 0x000c5008
3307#define BNX2_RXP_CPU_EVENT_MASK_BREAKPOINT_MASK (1L<<0)
3308#define BNX2_RXP_CPU_EVENT_MASK_BAD_INST_HALTED_MASK (1L<<2)
3309#define BNX2_RXP_CPU_EVENT_MASK_PAGE_0_DATA_HALTED_MASK (1L<<3)
3310#define BNX2_RXP_CPU_EVENT_MASK_PAGE_0_INST_HALTED_MASK (1L<<4)
3311#define BNX2_RXP_CPU_EVENT_MASK_BAD_DATA_ADDR_HALTED_MASK (1L<<5)
3312#define BNX2_RXP_CPU_EVENT_MASK_BAD_PC_HALTED_MASK (1L<<6)
3313#define BNX2_RXP_CPU_EVENT_MASK_ALIGN_HALTED_MASK (1L<<7)
3314#define BNX2_RXP_CPU_EVENT_MASK_FIO_ABORT_MASK (1L<<8)
3315#define BNX2_RXP_CPU_EVENT_MASK_SOFT_HALTED_MASK (1L<<10)
3316#define BNX2_RXP_CPU_EVENT_MASK_SPAD_UNDERFLOW_MASK (1L<<11)
3317#define BNX2_RXP_CPU_EVENT_MASK_INTERRUPT_MASK (1L<<12)
3318
3319#define BNX2_RXP_CPU_PROGRAM_COUNTER 0x000c501c
3320#define BNX2_RXP_CPU_INSTRUCTION 0x000c5020
3321#define BNX2_RXP_CPU_DATA_ACCESS 0x000c5024
3322#define BNX2_RXP_CPU_INTERRUPT_ENABLE 0x000c5028
3323#define BNX2_RXP_CPU_INTERRUPT_VECTOR 0x000c502c
3324#define BNX2_RXP_CPU_INTERRUPT_SAVED_PC 0x000c5030
3325#define BNX2_RXP_CPU_HW_BREAKPOINT 0x000c5034
3326#define BNX2_RXP_CPU_HW_BREAKPOINT_DISABLE (1L<<0)
3327#define BNX2_RXP_CPU_HW_BREAKPOINT_ADDRESS (0x3fffffffL<<2)
3328
3329#define BNX2_RXP_CPU_DEBUG_VECT_PEEK 0x000c5038
3330#define BNX2_RXP_CPU_DEBUG_VECT_PEEK_1_VALUE (0x7ffL<<0)
3331#define BNX2_RXP_CPU_DEBUG_VECT_PEEK_1_PEEK_EN (1L<<11)
3332#define BNX2_RXP_CPU_DEBUG_VECT_PEEK_1_SEL (0xfL<<12)
3333#define BNX2_RXP_CPU_DEBUG_VECT_PEEK_2_VALUE (0x7ffL<<16)
3334#define BNX2_RXP_CPU_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
3335#define BNX2_RXP_CPU_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
3336
3337#define BNX2_RXP_CPU_LAST_BRANCH_ADDR 0x000c5048
3338#define BNX2_RXP_CPU_LAST_BRANCH_ADDR_TYPE (1L<<1)
3339#define BNX2_RXP_CPU_LAST_BRANCH_ADDR_TYPE_JUMP (0L<<1)
3340#define BNX2_RXP_CPU_LAST_BRANCH_ADDR_TYPE_BRANCH (1L<<1)
3341#define BNX2_RXP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3342
3343#define BNX2_RXP_CPU_REG_FILE 0x000c5200
3344#define BNX2_RXP_CFTQ_DATA 0x000c5380
3345#define BNX2_RXP_CFTQ_CMD 0x000c53b8
3346#define BNX2_RXP_CFTQ_CMD_OFFSET (0x3ffL<<0)
3347#define BNX2_RXP_CFTQ_CMD_WR_TOP (1L<<10)
3348#define BNX2_RXP_CFTQ_CMD_WR_TOP_0 (0L<<10)
3349#define BNX2_RXP_CFTQ_CMD_WR_TOP_1 (1L<<10)
3350#define BNX2_RXP_CFTQ_CMD_SFT_RESET (1L<<25)
3351#define BNX2_RXP_CFTQ_CMD_RD_DATA (1L<<26)
3352#define BNX2_RXP_CFTQ_CMD_ADD_INTERVEN (1L<<27)
3353#define BNX2_RXP_CFTQ_CMD_ADD_DATA (1L<<28)
3354#define BNX2_RXP_CFTQ_CMD_INTERVENE_CLR (1L<<29)
3355#define BNX2_RXP_CFTQ_CMD_POP (1L<<30)
3356#define BNX2_RXP_CFTQ_CMD_BUSY (1L<<31)
3357
3358#define BNX2_RXP_CFTQ_CTL 0x000c53bc
3359#define BNX2_RXP_CFTQ_CTL_INTERVENE (1L<<0)
3360#define BNX2_RXP_CFTQ_CTL_OVERFLOW (1L<<1)
3361#define BNX2_RXP_CFTQ_CTL_FORCE_INTERVENE (1L<<2)
3362#define BNX2_RXP_CFTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3363#define BNX2_RXP_CFTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3364
3365#define BNX2_RXP_FTQ_DATA 0x000c53c0
3366#define BNX2_RXP_FTQ_CMD 0x000c53f8
3367#define BNX2_RXP_FTQ_CMD_OFFSET (0x3ffL<<0)
3368#define BNX2_RXP_FTQ_CMD_WR_TOP (1L<<10)
3369#define BNX2_RXP_FTQ_CMD_WR_TOP_0 (0L<<10)
3370#define BNX2_RXP_FTQ_CMD_WR_TOP_1 (1L<<10)
3371#define BNX2_RXP_FTQ_CMD_SFT_RESET (1L<<25)
3372#define BNX2_RXP_FTQ_CMD_RD_DATA (1L<<26)
3373#define BNX2_RXP_FTQ_CMD_ADD_INTERVEN (1L<<27)
3374#define BNX2_RXP_FTQ_CMD_ADD_DATA (1L<<28)
3375#define BNX2_RXP_FTQ_CMD_INTERVENE_CLR (1L<<29)
3376#define BNX2_RXP_FTQ_CMD_POP (1L<<30)
3377#define BNX2_RXP_FTQ_CMD_BUSY (1L<<31)
3378
3379#define BNX2_RXP_FTQ_CTL 0x000c53fc
3380#define BNX2_RXP_FTQ_CTL_INTERVENE (1L<<0)
3381#define BNX2_RXP_FTQ_CTL_OVERFLOW (1L<<1)
3382#define BNX2_RXP_FTQ_CTL_FORCE_INTERVENE (1L<<2)
3383#define BNX2_RXP_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3384#define BNX2_RXP_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3385
3386#define BNX2_RXP_SCRATCH 0x000e0000
3387
3388
3389/*
3390 * com_reg definition
3391 * offset: 0x100000
3392 */
3393#define BNX2_COM_CPU_MODE 0x00105000
3394#define BNX2_COM_CPU_MODE_LOCAL_RST (1L<<0)
3395#define BNX2_COM_CPU_MODE_STEP_ENA (1L<<1)
3396#define BNX2_COM_CPU_MODE_PAGE_0_DATA_ENA (1L<<2)
3397#define BNX2_COM_CPU_MODE_PAGE_0_INST_ENA (1L<<3)
3398#define BNX2_COM_CPU_MODE_MSG_BIT1 (1L<<6)
3399#define BNX2_COM_CPU_MODE_INTERRUPT_ENA (1L<<7)
3400#define BNX2_COM_CPU_MODE_SOFT_HALT (1L<<10)
3401#define BNX2_COM_CPU_MODE_BAD_DATA_HALT_ENA (1L<<11)
3402#define BNX2_COM_CPU_MODE_BAD_INST_HALT_ENA (1L<<12)
3403#define BNX2_COM_CPU_MODE_FIO_ABORT_HALT_ENA (1L<<13)
3404#define BNX2_COM_CPU_MODE_SPAD_UNDERFLOW_HALT_ENA (1L<<15)
3405
3406#define BNX2_COM_CPU_STATE 0x00105004
3407#define BNX2_COM_CPU_STATE_BREAKPOINT (1L<<0)
3408#define BNX2_COM_CPU_STATE_BAD_INST_HALTED (1L<<2)
3409#define BNX2_COM_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3410#define BNX2_COM_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3411#define BNX2_COM_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3412#define BNX2_COM_CPU_STATE_BAD_pc_HALTED (1L<<6)
3413#define BNX2_COM_CPU_STATE_ALIGN_HALTED (1L<<7)
3414#define BNX2_COM_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3415#define BNX2_COM_CPU_STATE_SOFT_HALTED (1L<<10)
3416#define BNX2_COM_CPU_STATE_SPAD_UNDERFLOW (1L<<11)
3417#define BNX2_COM_CPU_STATE_INTERRRUPT (1L<<12)
3418#define BNX2_COM_CPU_STATE_DATA_ACCESS_STALL (1L<<14)
3419#define BNX2_COM_CPU_STATE_INST_FETCH_STALL (1L<<15)
3420#define BNX2_COM_CPU_STATE_BLOCKED_READ (1L<<31)
3421
3422#define BNX2_COM_CPU_EVENT_MASK 0x00105008
3423#define BNX2_COM_CPU_EVENT_MASK_BREAKPOINT_MASK (1L<<0)
3424#define BNX2_COM_CPU_EVENT_MASK_BAD_INST_HALTED_MASK (1L<<2)
3425#define BNX2_COM_CPU_EVENT_MASK_PAGE_0_DATA_HALTED_MASK (1L<<3)
3426#define BNX2_COM_CPU_EVENT_MASK_PAGE_0_INST_HALTED_MASK (1L<<4)
3427#define BNX2_COM_CPU_EVENT_MASK_BAD_DATA_ADDR_HALTED_MASK (1L<<5)
3428#define BNX2_COM_CPU_EVENT_MASK_BAD_PC_HALTED_MASK (1L<<6)
3429#define BNX2_COM_CPU_EVENT_MASK_ALIGN_HALTED_MASK (1L<<7)
3430#define BNX2_COM_CPU_EVENT_MASK_FIO_ABORT_MASK (1L<<8)
3431#define BNX2_COM_CPU_EVENT_MASK_SOFT_HALTED_MASK (1L<<10)
3432#define BNX2_COM_CPU_EVENT_MASK_SPAD_UNDERFLOW_MASK (1L<<11)
3433#define BNX2_COM_CPU_EVENT_MASK_INTERRUPT_MASK (1L<<12)
3434
3435#define BNX2_COM_CPU_PROGRAM_COUNTER 0x0010501c
3436#define BNX2_COM_CPU_INSTRUCTION 0x00105020
3437#define BNX2_COM_CPU_DATA_ACCESS 0x00105024
3438#define BNX2_COM_CPU_INTERRUPT_ENABLE 0x00105028
3439#define BNX2_COM_CPU_INTERRUPT_VECTOR 0x0010502c
3440#define BNX2_COM_CPU_INTERRUPT_SAVED_PC 0x00105030
3441#define BNX2_COM_CPU_HW_BREAKPOINT 0x00105034
3442#define BNX2_COM_CPU_HW_BREAKPOINT_DISABLE (1L<<0)
3443#define BNX2_COM_CPU_HW_BREAKPOINT_ADDRESS (0x3fffffffL<<2)
3444
3445#define BNX2_COM_CPU_DEBUG_VECT_PEEK 0x00105038
3446#define BNX2_COM_CPU_DEBUG_VECT_PEEK_1_VALUE (0x7ffL<<0)
3447#define BNX2_COM_CPU_DEBUG_VECT_PEEK_1_PEEK_EN (1L<<11)
3448#define BNX2_COM_CPU_DEBUG_VECT_PEEK_1_SEL (0xfL<<12)
3449#define BNX2_COM_CPU_DEBUG_VECT_PEEK_2_VALUE (0x7ffL<<16)
3450#define BNX2_COM_CPU_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
3451#define BNX2_COM_CPU_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
3452
3453#define BNX2_COM_CPU_LAST_BRANCH_ADDR 0x00105048
3454#define BNX2_COM_CPU_LAST_BRANCH_ADDR_TYPE (1L<<1)
3455#define BNX2_COM_CPU_LAST_BRANCH_ADDR_TYPE_JUMP (0L<<1)
3456#define BNX2_COM_CPU_LAST_BRANCH_ADDR_TYPE_BRANCH (1L<<1)
3457#define BNX2_COM_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3458
3459#define BNX2_COM_CPU_REG_FILE 0x00105200
3460#define BNX2_COM_COMXQ_FTQ_DATA 0x00105340
3461#define BNX2_COM_COMXQ_FTQ_CMD 0x00105378
3462#define BNX2_COM_COMXQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3463#define BNX2_COM_COMXQ_FTQ_CMD_WR_TOP (1L<<10)
3464#define BNX2_COM_COMXQ_FTQ_CMD_WR_TOP_0 (0L<<10)
3465#define BNX2_COM_COMXQ_FTQ_CMD_WR_TOP_1 (1L<<10)
3466#define BNX2_COM_COMXQ_FTQ_CMD_SFT_RESET (1L<<25)
3467#define BNX2_COM_COMXQ_FTQ_CMD_RD_DATA (1L<<26)
3468#define BNX2_COM_COMXQ_FTQ_CMD_ADD_INTERVEN (1L<<27)
3469#define BNX2_COM_COMXQ_FTQ_CMD_ADD_DATA (1L<<28)
3470#define BNX2_COM_COMXQ_FTQ_CMD_INTERVENE_CLR (1L<<29)
3471#define BNX2_COM_COMXQ_FTQ_CMD_POP (1L<<30)
3472#define BNX2_COM_COMXQ_FTQ_CMD_BUSY (1L<<31)
3473
3474#define BNX2_COM_COMXQ_FTQ_CTL 0x0010537c
3475#define BNX2_COM_COMXQ_FTQ_CTL_INTERVENE (1L<<0)
3476#define BNX2_COM_COMXQ_FTQ_CTL_OVERFLOW (1L<<1)
3477#define BNX2_COM_COMXQ_FTQ_CTL_FORCE_INTERVENE (1L<<2)
3478#define BNX2_COM_COMXQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3479#define BNX2_COM_COMXQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3480
3481#define BNX2_COM_COMTQ_FTQ_DATA 0x00105380
3482#define BNX2_COM_COMTQ_FTQ_CMD 0x001053b8
3483#define BNX2_COM_COMTQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3484#define BNX2_COM_COMTQ_FTQ_CMD_WR_TOP (1L<<10)
3485#define BNX2_COM_COMTQ_FTQ_CMD_WR_TOP_0 (0L<<10)
3486#define BNX2_COM_COMTQ_FTQ_CMD_WR_TOP_1 (1L<<10)
3487#define BNX2_COM_COMTQ_FTQ_CMD_SFT_RESET (1L<<25)
3488#define BNX2_COM_COMTQ_FTQ_CMD_RD_DATA (1L<<26)
3489#define BNX2_COM_COMTQ_FTQ_CMD_ADD_INTERVEN (1L<<27)
3490#define BNX2_COM_COMTQ_FTQ_CMD_ADD_DATA (1L<<28)
3491#define BNX2_COM_COMTQ_FTQ_CMD_INTERVENE_CLR (1L<<29)
3492#define BNX2_COM_COMTQ_FTQ_CMD_POP (1L<<30)
3493#define BNX2_COM_COMTQ_FTQ_CMD_BUSY (1L<<31)
3494
3495#define BNX2_COM_COMTQ_FTQ_CTL 0x001053bc
3496#define BNX2_COM_COMTQ_FTQ_CTL_INTERVENE (1L<<0)
3497#define BNX2_COM_COMTQ_FTQ_CTL_OVERFLOW (1L<<1)
3498#define BNX2_COM_COMTQ_FTQ_CTL_FORCE_INTERVENE (1L<<2)
3499#define BNX2_COM_COMTQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3500#define BNX2_COM_COMTQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3501
3502#define BNX2_COM_COMQ_FTQ_DATA 0x001053c0
3503#define BNX2_COM_COMQ_FTQ_CMD 0x001053f8
3504#define BNX2_COM_COMQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3505#define BNX2_COM_COMQ_FTQ_CMD_WR_TOP (1L<<10)
3506#define BNX2_COM_COMQ_FTQ_CMD_WR_TOP_0 (0L<<10)
3507#define BNX2_COM_COMQ_FTQ_CMD_WR_TOP_1 (1L<<10)
3508#define BNX2_COM_COMQ_FTQ_CMD_SFT_RESET (1L<<25)
3509#define BNX2_COM_COMQ_FTQ_CMD_RD_DATA (1L<<26)
3510#define BNX2_COM_COMQ_FTQ_CMD_ADD_INTERVEN (1L<<27)
3511#define BNX2_COM_COMQ_FTQ_CMD_ADD_DATA (1L<<28)
3512#define BNX2_COM_COMQ_FTQ_CMD_INTERVENE_CLR (1L<<29)
3513#define BNX2_COM_COMQ_FTQ_CMD_POP (1L<<30)
3514#define BNX2_COM_COMQ_FTQ_CMD_BUSY (1L<<31)
3515
3516#define BNX2_COM_COMQ_FTQ_CTL 0x001053fc
3517#define BNX2_COM_COMQ_FTQ_CTL_INTERVENE (1L<<0)
3518#define BNX2_COM_COMQ_FTQ_CTL_OVERFLOW (1L<<1)
3519#define BNX2_COM_COMQ_FTQ_CTL_FORCE_INTERVENE (1L<<2)
3520#define BNX2_COM_COMQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3521#define BNX2_COM_COMQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3522
3523#define BNX2_COM_SCRATCH 0x00120000
3524
3525
3526/*
3527 * cp_reg definition
3528 * offset: 0x180000
3529 */
3530#define BNX2_CP_CPU_MODE 0x00185000
3531#define BNX2_CP_CPU_MODE_LOCAL_RST (1L<<0)
3532#define BNX2_CP_CPU_MODE_STEP_ENA (1L<<1)
3533#define BNX2_CP_CPU_MODE_PAGE_0_DATA_ENA (1L<<2)
3534#define BNX2_CP_CPU_MODE_PAGE_0_INST_ENA (1L<<3)
3535#define BNX2_CP_CPU_MODE_MSG_BIT1 (1L<<6)
3536#define BNX2_CP_CPU_MODE_INTERRUPT_ENA (1L<<7)
3537#define BNX2_CP_CPU_MODE_SOFT_HALT (1L<<10)
3538#define BNX2_CP_CPU_MODE_BAD_DATA_HALT_ENA (1L<<11)
3539#define BNX2_CP_CPU_MODE_BAD_INST_HALT_ENA (1L<<12)
3540#define BNX2_CP_CPU_MODE_FIO_ABORT_HALT_ENA (1L<<13)
3541#define BNX2_CP_CPU_MODE_SPAD_UNDERFLOW_HALT_ENA (1L<<15)
3542
3543#define BNX2_CP_CPU_STATE 0x00185004
3544#define BNX2_CP_CPU_STATE_BREAKPOINT (1L<<0)
3545#define BNX2_CP_CPU_STATE_BAD_INST_HALTED (1L<<2)
3546#define BNX2_CP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3547#define BNX2_CP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3548#define BNX2_CP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3549#define BNX2_CP_CPU_STATE_BAD_pc_HALTED (1L<<6)
3550#define BNX2_CP_CPU_STATE_ALIGN_HALTED (1L<<7)
3551#define BNX2_CP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3552#define BNX2_CP_CPU_STATE_SOFT_HALTED (1L<<10)
3553#define BNX2_CP_CPU_STATE_SPAD_UNDERFLOW (1L<<11)
3554#define BNX2_CP_CPU_STATE_INTERRRUPT (1L<<12)
3555#define BNX2_CP_CPU_STATE_DATA_ACCESS_STALL (1L<<14)
3556#define BNX2_CP_CPU_STATE_INST_FETCH_STALL (1L<<15)
3557#define BNX2_CP_CPU_STATE_BLOCKED_READ (1L<<31)
3558
3559#define BNX2_CP_CPU_EVENT_MASK 0x00185008
3560#define BNX2_CP_CPU_EVENT_MASK_BREAKPOINT_MASK (1L<<0)
3561#define BNX2_CP_CPU_EVENT_MASK_BAD_INST_HALTED_MASK (1L<<2)
3562#define BNX2_CP_CPU_EVENT_MASK_PAGE_0_DATA_HALTED_MASK (1L<<3)
3563#define BNX2_CP_CPU_EVENT_MASK_PAGE_0_INST_HALTED_MASK (1L<<4)
3564#define BNX2_CP_CPU_EVENT_MASK_BAD_DATA_ADDR_HALTED_MASK (1L<<5)
3565#define BNX2_CP_CPU_EVENT_MASK_BAD_PC_HALTED_MASK (1L<<6)
3566#define BNX2_CP_CPU_EVENT_MASK_ALIGN_HALTED_MASK (1L<<7)
3567#define BNX2_CP_CPU_EVENT_MASK_FIO_ABORT_MASK (1L<<8)
3568#define BNX2_CP_CPU_EVENT_MASK_SOFT_HALTED_MASK (1L<<10)
3569#define BNX2_CP_CPU_EVENT_MASK_SPAD_UNDERFLOW_MASK (1L<<11)
3570#define BNX2_CP_CPU_EVENT_MASK_INTERRUPT_MASK (1L<<12)
3571
3572#define BNX2_CP_CPU_PROGRAM_COUNTER 0x0018501c
3573#define BNX2_CP_CPU_INSTRUCTION 0x00185020
3574#define BNX2_CP_CPU_DATA_ACCESS 0x00185024
3575#define BNX2_CP_CPU_INTERRUPT_ENABLE 0x00185028
3576#define BNX2_CP_CPU_INTERRUPT_VECTOR 0x0018502c
3577#define BNX2_CP_CPU_INTERRUPT_SAVED_PC 0x00185030
3578#define BNX2_CP_CPU_HW_BREAKPOINT 0x00185034
3579#define BNX2_CP_CPU_HW_BREAKPOINT_DISABLE (1L<<0)
3580#define BNX2_CP_CPU_HW_BREAKPOINT_ADDRESS (0x3fffffffL<<2)
3581
3582#define BNX2_CP_CPU_DEBUG_VECT_PEEK 0x00185038
3583#define BNX2_CP_CPU_DEBUG_VECT_PEEK_1_VALUE (0x7ffL<<0)
3584#define BNX2_CP_CPU_DEBUG_VECT_PEEK_1_PEEK_EN (1L<<11)
3585#define BNX2_CP_CPU_DEBUG_VECT_PEEK_1_SEL (0xfL<<12)
3586#define BNX2_CP_CPU_DEBUG_VECT_PEEK_2_VALUE (0x7ffL<<16)
3587#define BNX2_CP_CPU_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
3588#define BNX2_CP_CPU_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
3589
3590#define BNX2_CP_CPU_LAST_BRANCH_ADDR 0x00185048
3591#define BNX2_CP_CPU_LAST_BRANCH_ADDR_TYPE (1L<<1)
3592#define BNX2_CP_CPU_LAST_BRANCH_ADDR_TYPE_JUMP (0L<<1)
3593#define BNX2_CP_CPU_LAST_BRANCH_ADDR_TYPE_BRANCH (1L<<1)
3594#define BNX2_CP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3595
3596#define BNX2_CP_CPU_REG_FILE 0x00185200
3597#define BNX2_CP_CPQ_FTQ_DATA 0x001853c0
3598#define BNX2_CP_CPQ_FTQ_CMD 0x001853f8
3599#define BNX2_CP_CPQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3600#define BNX2_CP_CPQ_FTQ_CMD_WR_TOP (1L<<10)
3601#define BNX2_CP_CPQ_FTQ_CMD_WR_TOP_0 (0L<<10)
3602#define BNX2_CP_CPQ_FTQ_CMD_WR_TOP_1 (1L<<10)
3603#define BNX2_CP_CPQ_FTQ_CMD_SFT_RESET (1L<<25)
3604#define BNX2_CP_CPQ_FTQ_CMD_RD_DATA (1L<<26)
3605#define BNX2_CP_CPQ_FTQ_CMD_ADD_INTERVEN (1L<<27)
3606#define BNX2_CP_CPQ_FTQ_CMD_ADD_DATA (1L<<28)
3607#define BNX2_CP_CPQ_FTQ_CMD_INTERVENE_CLR (1L<<29)
3608#define BNX2_CP_CPQ_FTQ_CMD_POP (1L<<30)
3609#define BNX2_CP_CPQ_FTQ_CMD_BUSY (1L<<31)
3610
3611#define BNX2_CP_CPQ_FTQ_CTL 0x001853fc
3612#define BNX2_CP_CPQ_FTQ_CTL_INTERVENE (1L<<0)
3613#define BNX2_CP_CPQ_FTQ_CTL_OVERFLOW (1L<<1)
3614#define BNX2_CP_CPQ_FTQ_CTL_FORCE_INTERVENE (1L<<2)
3615#define BNX2_CP_CPQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3616#define BNX2_CP_CPQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3617
3618#define BNX2_CP_SCRATCH 0x001a0000
3619
3620
3621/*
3622 * mcp_reg definition
3623 * offset: 0x140000
3624 */
3625#define BNX2_MCP_CPU_MODE 0x00145000
3626#define BNX2_MCP_CPU_MODE_LOCAL_RST (1L<<0)
3627#define BNX2_MCP_CPU_MODE_STEP_ENA (1L<<1)
3628#define BNX2_MCP_CPU_MODE_PAGE_0_DATA_ENA (1L<<2)
3629#define BNX2_MCP_CPU_MODE_PAGE_0_INST_ENA (1L<<3)
3630#define BNX2_MCP_CPU_MODE_MSG_BIT1 (1L<<6)
3631#define BNX2_MCP_CPU_MODE_INTERRUPT_ENA (1L<<7)
3632#define BNX2_MCP_CPU_MODE_SOFT_HALT (1L<<10)
3633#define BNX2_MCP_CPU_MODE_BAD_DATA_HALT_ENA (1L<<11)
3634#define BNX2_MCP_CPU_MODE_BAD_INST_HALT_ENA (1L<<12)
3635#define BNX2_MCP_CPU_MODE_FIO_ABORT_HALT_ENA (1L<<13)
3636#define BNX2_MCP_CPU_MODE_SPAD_UNDERFLOW_HALT_ENA (1L<<15)
3637
3638#define BNX2_MCP_CPU_STATE 0x00145004
3639#define BNX2_MCP_CPU_STATE_BREAKPOINT (1L<<0)
3640#define BNX2_MCP_CPU_STATE_BAD_INST_HALTED (1L<<2)
3641#define BNX2_MCP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3642#define BNX2_MCP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3643#define BNX2_MCP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3644#define BNX2_MCP_CPU_STATE_BAD_pc_HALTED (1L<<6)
3645#define BNX2_MCP_CPU_STATE_ALIGN_HALTED (1L<<7)
3646#define BNX2_MCP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3647#define BNX2_MCP_CPU_STATE_SOFT_HALTED (1L<<10)
3648#define BNX2_MCP_CPU_STATE_SPAD_UNDERFLOW (1L<<11)
3649#define BNX2_MCP_CPU_STATE_INTERRRUPT (1L<<12)
3650#define BNX2_MCP_CPU_STATE_DATA_ACCESS_STALL (1L<<14)
3651#define BNX2_MCP_CPU_STATE_INST_FETCH_STALL (1L<<15)
3652#define BNX2_MCP_CPU_STATE_BLOCKED_READ (1L<<31)
3653
3654#define BNX2_MCP_CPU_EVENT_MASK 0x00145008
3655#define BNX2_MCP_CPU_EVENT_MASK_BREAKPOINT_MASK (1L<<0)
3656#define BNX2_MCP_CPU_EVENT_MASK_BAD_INST_HALTED_MASK (1L<<2)
3657#define BNX2_MCP_CPU_EVENT_MASK_PAGE_0_DATA_HALTED_MASK (1L<<3)
3658#define BNX2_MCP_CPU_EVENT_MASK_PAGE_0_INST_HALTED_MASK (1L<<4)
3659#define BNX2_MCP_CPU_EVENT_MASK_BAD_DATA_ADDR_HALTED_MASK (1L<<5)
3660#define BNX2_MCP_CPU_EVENT_MASK_BAD_PC_HALTED_MASK (1L<<6)
3661#define BNX2_MCP_CPU_EVENT_MASK_ALIGN_HALTED_MASK (1L<<7)
3662#define BNX2_MCP_CPU_EVENT_MASK_FIO_ABORT_MASK (1L<<8)
3663#define BNX2_MCP_CPU_EVENT_MASK_SOFT_HALTED_MASK (1L<<10)
3664#define BNX2_MCP_CPU_EVENT_MASK_SPAD_UNDERFLOW_MASK (1L<<11)
3665#define BNX2_MCP_CPU_EVENT_MASK_INTERRUPT_MASK (1L<<12)
3666
3667#define BNX2_MCP_CPU_PROGRAM_COUNTER 0x0014501c
3668#define BNX2_MCP_CPU_INSTRUCTION 0x00145020
3669#define BNX2_MCP_CPU_DATA_ACCESS 0x00145024
3670#define BNX2_MCP_CPU_INTERRUPT_ENABLE 0x00145028
3671#define BNX2_MCP_CPU_INTERRUPT_VECTOR 0x0014502c
3672#define BNX2_MCP_CPU_INTERRUPT_SAVED_PC 0x00145030
3673#define BNX2_MCP_CPU_HW_BREAKPOINT 0x00145034
3674#define BNX2_MCP_CPU_HW_BREAKPOINT_DISABLE (1L<<0)
3675#define BNX2_MCP_CPU_HW_BREAKPOINT_ADDRESS (0x3fffffffL<<2)
3676
3677#define BNX2_MCP_CPU_DEBUG_VECT_PEEK 0x00145038
3678#define BNX2_MCP_CPU_DEBUG_VECT_PEEK_1_VALUE (0x7ffL<<0)
3679#define BNX2_MCP_CPU_DEBUG_VECT_PEEK_1_PEEK_EN (1L<<11)
3680#define BNX2_MCP_CPU_DEBUG_VECT_PEEK_1_SEL (0xfL<<12)
3681#define BNX2_MCP_CPU_DEBUG_VECT_PEEK_2_VALUE (0x7ffL<<16)
3682#define BNX2_MCP_CPU_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
3683#define BNX2_MCP_CPU_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
3684
3685#define BNX2_MCP_CPU_LAST_BRANCH_ADDR 0x00145048
3686#define BNX2_MCP_CPU_LAST_BRANCH_ADDR_TYPE (1L<<1)
3687#define BNX2_MCP_CPU_LAST_BRANCH_ADDR_TYPE_JUMP (0L<<1)
3688#define BNX2_MCP_CPU_LAST_BRANCH_ADDR_TYPE_BRANCH (1L<<1)
3689#define BNX2_MCP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3690
3691#define BNX2_MCP_CPU_REG_FILE 0x00145200
3692#define BNX2_MCP_MCPQ_FTQ_DATA 0x001453c0
3693#define BNX2_MCP_MCPQ_FTQ_CMD 0x001453f8
3694#define BNX2_MCP_MCPQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3695#define BNX2_MCP_MCPQ_FTQ_CMD_WR_TOP (1L<<10)
3696#define BNX2_MCP_MCPQ_FTQ_CMD_WR_TOP_0 (0L<<10)
3697#define BNX2_MCP_MCPQ_FTQ_CMD_WR_TOP_1 (1L<<10)
3698#define BNX2_MCP_MCPQ_FTQ_CMD_SFT_RESET (1L<<25)
3699#define BNX2_MCP_MCPQ_FTQ_CMD_RD_DATA (1L<<26)
3700#define BNX2_MCP_MCPQ_FTQ_CMD_ADD_INTERVEN (1L<<27)
3701#define BNX2_MCP_MCPQ_FTQ_CMD_ADD_DATA (1L<<28)
3702#define BNX2_MCP_MCPQ_FTQ_CMD_INTERVENE_CLR (1L<<29)
3703#define BNX2_MCP_MCPQ_FTQ_CMD_POP (1L<<30)
3704#define BNX2_MCP_MCPQ_FTQ_CMD_BUSY (1L<<31)
3705
3706#define BNX2_MCP_MCPQ_FTQ_CTL 0x001453fc
3707#define BNX2_MCP_MCPQ_FTQ_CTL_INTERVENE (1L<<0)
3708#define BNX2_MCP_MCPQ_FTQ_CTL_OVERFLOW (1L<<1)
3709#define BNX2_MCP_MCPQ_FTQ_CTL_FORCE_INTERVENE (1L<<2)
3710#define BNX2_MCP_MCPQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3711#define BNX2_MCP_MCPQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3712
3713#define BNX2_MCP_ROM 0x00150000
3714#define BNX2_MCP_SCRATCH 0x00160000
3715
3716
3717#define NUM_MC_HASH_REGISTERS 8
3718
3719
3720/* PHY_ID1: bits 31-16; PHY_ID2: bits 15-0. */
3721#define PHY_BCM5706_PHY_ID 0x00206160
3722
3723#define PHY_ID(id) ((id) & 0xfffffff0)
3724#define PHY_REV_ID(id) ((id) & 0xf)
3725
3726#define MIN_ETHERNET_PACKET_SIZE 60
3727#define MAX_ETHERNET_PACKET_SIZE 1514
3728#define MAX_ETHERNET_JUMBO_PACKET_SIZE 9014
3729
3730#define RX_COPY_THRESH 92
3731
3732#define DMA_READ_CHANS 5
3733#define DMA_WRITE_CHANS 3
3734
3735#define BCM_PAGE_BITS 12
3736#define BCM_PAGE_SIZE (1 << BCM_PAGE_BITS)
3737
3738#define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct tx_bd))
3739#define MAX_TX_DESC_CNT (TX_DESC_CNT - 1)
3740
3741#define RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct rx_bd))
3742#define MAX_RX_DESC_CNT (RX_DESC_CNT - 1)
3743
3744#define NEXT_TX_BD(x) (((x) & (MAX_TX_DESC_CNT - 1)) == \
3745 (MAX_TX_DESC_CNT - 1)) ? \
3746 (x) + 2 : (x) + 1
3747
3748#define TX_RING_IDX(x) ((x) & MAX_TX_DESC_CNT)
3749
3750#define NEXT_RX_BD(x) (((x) & (MAX_RX_DESC_CNT - 1)) == \
3751 (MAX_RX_DESC_CNT - 1)) ? \
3752 (x) + 2 : (x) + 1
3753
3754#define RX_RING_IDX(x) ((x) & MAX_RX_DESC_CNT)
3755
3756
3757/* Context size. */
3758#define CTX_SHIFT 7
3759#define CTX_SIZE (1 << CTX_SHIFT)
3760#define CTX_MASK (CTX_SIZE - 1)
3761#define GET_CID_ADDR(_cid) ((_cid) << CTX_SHIFT)
3762#define GET_CID(_cid_addr) ((_cid_addr) >> CTX_SHIFT)
3763
3764#define PHY_CTX_SHIFT 6
3765#define PHY_CTX_SIZE (1 << PHY_CTX_SHIFT)
3766#define PHY_CTX_MASK (PHY_CTX_SIZE - 1)
3767#define GET_PCID_ADDR(_pcid) ((_pcid) << PHY_CTX_SHIFT)
3768#define GET_PCID(_pcid_addr) ((_pcid_addr) >> PHY_CTX_SHIFT)
3769
3770#define MB_KERNEL_CTX_SHIFT 8
3771#define MB_KERNEL_CTX_SIZE (1 << MB_KERNEL_CTX_SHIFT)
3772#define MB_KERNEL_CTX_MASK (MB_KERNEL_CTX_SIZE - 1)
3773#define MB_GET_CID_ADDR(_cid) (0x10000 + ((_cid) << MB_KERNEL_CTX_SHIFT))
3774
3775#define MAX_CID_CNT 0x4000
3776#define MAX_CID_ADDR (GET_CID_ADDR(MAX_CID_CNT))
3777#define INVALID_CID_ADDR 0xffffffff
3778
3779#define TX_CID 16
3780#define RX_CID 0
3781
3782#define MB_TX_CID_ADDR MB_GET_CID_ADDR(TX_CID)
3783#define MB_RX_CID_ADDR MB_GET_CID_ADDR(RX_CID)
3784
3785struct sw_bd {
3786 struct sk_buff *skb;
3787 DECLARE_PCI_UNMAP_ADDR(mapping)
3788};
3789
3790/* Buffered flash (Atmel: AT45DB011B) specific information */
3791#define SEEPROM_PAGE_BITS 2
3792#define SEEPROM_PHY_PAGE_SIZE (1 << SEEPROM_PAGE_BITS)
3793#define SEEPROM_BYTE_ADDR_MASK (SEEPROM_PHY_PAGE_SIZE-1)
3794#define SEEPROM_PAGE_SIZE 4
3795#define SEEPROM_TOTAL_SIZE 65536
3796
3797#define BUFFERED_FLASH_PAGE_BITS 9
3798#define BUFFERED_FLASH_PHY_PAGE_SIZE (1 << BUFFERED_FLASH_PAGE_BITS)
3799#define BUFFERED_FLASH_BYTE_ADDR_MASK (BUFFERED_FLASH_PHY_PAGE_SIZE-1)
3800#define BUFFERED_FLASH_PAGE_SIZE 264
3801#define BUFFERED_FLASH_TOTAL_SIZE 131072
3802
3803#define SAIFUN_FLASH_PAGE_BITS 8
3804#define SAIFUN_FLASH_PHY_PAGE_SIZE (1 << SAIFUN_FLASH_PAGE_BITS)
3805#define SAIFUN_FLASH_BYTE_ADDR_MASK (SAIFUN_FLASH_PHY_PAGE_SIZE-1)
3806#define SAIFUN_FLASH_PAGE_SIZE 256
3807#define SAIFUN_FLASH_BASE_TOTAL_SIZE 65536
3808
3809#define NVRAM_TIMEOUT_COUNT 30000
3810
3811
3812#define FLASH_STRAP_MASK (BNX2_NVM_CFG1_FLASH_MODE | \
3813 BNX2_NVM_CFG1_BUFFER_MODE | \
3814 BNX2_NVM_CFG1_PROTECT_MODE | \
3815 BNX2_NVM_CFG1_FLASH_SIZE)
3816
3817struct flash_spec {
3818 u32 strapping;
3819 u32 config1;
3820 u32 config2;
3821 u32 config3;
3822 u32 write1;
3823 u32 buffered;
3824 u32 page_bits;
3825 u32 page_size;
3826 u32 addr_mask;
3827 u32 total_size;
3828 u8 *name;
3829};
3830
3831struct bnx2 {
3832 /* Fields used in the tx and intr/napi performance paths are grouped */
3833 /* together in the beginning of the structure. */
3834 void __iomem *regview;
3835
3836 struct net_device *dev;
3837 struct pci_dev *pdev;
3838
3839 atomic_t intr_sem;
3840
3841 struct status_block *status_blk;
3842 u32 last_status_idx;
3843
3844 atomic_t tx_avail_bd;
3845 struct tx_bd *tx_desc_ring;
3846 struct sw_bd *tx_buf_ring;
3847 u32 tx_prod_bseq;
3848 u16 tx_prod;
3849 u16 tx_cons;
3850
3851#ifdef BCM_VLAN
3852 struct vlan_group *vlgrp;
3853#endif
3854
3855 u32 rx_offset;
3856 u32 rx_buf_use_size; /* useable size */
3857 u32 rx_buf_size; /* with alignment */
3858 struct rx_bd *rx_desc_ring;
3859 struct sw_bd *rx_buf_ring;
3860 u32 rx_prod_bseq;
3861 u16 rx_prod;
3862 u16 rx_cons;
3863
3864 u32 rx_csum;
3865
3866 /* Only used to synchronize netif_stop_queue/wake_queue when tx */
3867 /* ring is full */
3868 spinlock_t tx_lock;
3869
3870 /* End of fileds used in the performance code paths. */
3871
3872 char *name;
3873
3874 int timer_interval;
3875 struct timer_list timer;
3876 struct work_struct reset_task;
3877
3878 /* Used to synchronize phy accesses. */
3879 spinlock_t phy_lock;
3880
3881 u32 flags;
3882#define PCIX_FLAG 1
3883#define PCI_32BIT_FLAG 2
3884#define ONE_TDMA_FLAG 4 /* no longer used */
3885#define NO_WOL_FLAG 8
3886#define USING_DAC_FLAG 0x10
3887#define USING_MSI_FLAG 0x20
3888
3889 u32 phy_flags;
3890#define PHY_SERDES_FLAG 1
3891#define PHY_CRC_FIX_FLAG 2
3892#define PHY_PARALLEL_DETECT_FLAG 4
3893#define PHY_INT_MODE_MASK_FLAG 0x300
3894#define PHY_INT_MODE_AUTO_POLLING_FLAG 0x100
3895#define PHY_INT_MODE_LINK_READY_FLAG 0x200
3896
3897 u32 chip_id;
3898 /* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */
3899#define CHIP_NUM(bp) (((bp)->chip_id) & 0xffff0000)
3900#define CHIP_NUM_5706 0x57060000
3901
3902#define CHIP_REV(bp) (((bp)->chip_id) & 0x0000f000)
3903#define CHIP_REV_Ax 0x00000000
3904#define CHIP_REV_Bx 0x00001000
3905#define CHIP_REV_Cx 0x00002000
3906
3907#define CHIP_METAL(bp) (((bp)->chip_id) & 0x00000ff0)
3908#define CHIP_BONDING(bp) (((bp)->chip_id) & 0x0000000f)
3909
3910#define CHIP_ID(bp) (((bp)->chip_id) & 0xfffffff0)
3911#define CHIP_ID_5706_A0 0x57060000
3912#define CHIP_ID_5706_A1 0x57060010
3913
3914#define CHIP_BOND_ID(bp) (((bp)->chip_id) & 0xf)
3915
3916/* A serdes chip will have the first bit of the bond id set. */
3917#define CHIP_BOND_ID_SERDES_BIT 0x01
3918
3919 u32 phy_addr;
3920 u32 phy_id;
3921
3922 u16 bus_speed_mhz;
3923 u8 wol;
3924
3925 u8 fw_timed_out;
3926
3927 u16 fw_wr_seq;
3928 u16 fw_drv_pulse_wr_seq;
3929
3930 int tx_ring_size;
3931 dma_addr_t tx_desc_mapping;
3932
3933
3934 int rx_ring_size;
3935 dma_addr_t rx_desc_mapping;
3936
3937 u16 tx_quick_cons_trip;
3938 u16 tx_quick_cons_trip_int;
3939 u16 rx_quick_cons_trip;
3940 u16 rx_quick_cons_trip_int;
3941 u16 comp_prod_trip;
3942 u16 comp_prod_trip_int;
3943 u16 tx_ticks;
3944 u16 tx_ticks_int;
3945 u16 com_ticks;
3946 u16 com_ticks_int;
3947 u16 cmd_ticks;
3948 u16 cmd_ticks_int;
3949 u16 rx_ticks;
3950 u16 rx_ticks_int;
3951
3952 u32 stats_ticks;
3953
3954 dma_addr_t status_blk_mapping;
3955
3956 struct statistics_block *stats_blk;
3957 dma_addr_t stats_blk_mapping;
3958
3959 u32 rx_mode;
3960
3961 u16 req_line_speed;
3962 u8 req_duplex;
3963
3964 u8 link_up;
3965
3966 u16 line_speed;
3967 u8 duplex;
3968 u8 flow_ctrl; /* actual flow ctrl settings */
3969 /* may be different from */
3970 /* req_flow_ctrl if autoneg */
3971#define FLOW_CTRL_TX 1
3972#define FLOW_CTRL_RX 2
3973
3974 u32 advertising;
3975
3976 u8 req_flow_ctrl; /* flow ctrl advertisement */
3977 /* settings or forced */
3978 /* settings */
3979 u8 autoneg;
3980#define AUTONEG_SPEED 1
3981#define AUTONEG_FLOW_CTRL 2
3982
3983 u8 loopback;
3984#define MAC_LOOPBACK 1
3985#define PHY_LOOPBACK 2
3986
3987 u8 serdes_an_pending;
3988#define SERDES_AN_TIMEOUT (2 * HZ)
3989
3990 u8 mac_addr[8];
3991
3992 u32 fw_ver;
3993
3994 int pm_cap;
3995 int pcix_cap;
3996
3997 struct net_device_stats net_stats;
3998
3999 struct flash_spec *flash_info;
4000};
4001
4002static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset);
4003static void bnx2_reg_wr_ind(struct bnx2 *bp, u32 offset, u32 val);
4004
4005#define REG_RD(bp, offset) \
4006 readl(bp->regview + offset)
4007
4008#define REG_WR(bp, offset, val) \
4009 writel(val, bp->regview + offset)
4010
4011#define REG_WR16(bp, offset, val) \
4012 writew(val, bp->regview + offset)
4013
4014#define REG_RD_IND(bp, offset) \
4015 bnx2_reg_rd_ind(bp, offset)
4016
4017#define REG_WR_IND(bp, offset, val) \
4018 bnx2_reg_wr_ind(bp, offset, val)
4019
4020/* Indirect context access. Unlike the MBQ_WR, these macros will not
4021 * trigger a chip event. */
4022static void bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val);
4023
4024#define CTX_WR(bp, cid_addr, offset, val) \
4025 bnx2_ctx_wr(bp, cid_addr, offset, val)
4026
4027struct cpu_reg {
4028 u32 mode;
4029 u32 mode_value_halt;
4030 u32 mode_value_sstep;
4031
4032 u32 state;
4033 u32 state_value_clear;
4034
4035 u32 gpr0;
4036 u32 evmask;
4037 u32 pc;
4038 u32 inst;
4039 u32 bp;
4040
4041 u32 spad_base;
4042
4043 u32 mips_view_base;
4044};
4045
4046struct fw_info {
4047 u32 ver_major;
4048 u32 ver_minor;
4049 u32 ver_fix;
4050
4051 u32 start_addr;
4052
4053 /* Text section. */
4054 u32 text_addr;
4055 u32 text_len;
4056 u32 text_index;
4057 u32 *text;
4058
4059 /* Data section. */
4060 u32 data_addr;
4061 u32 data_len;
4062 u32 data_index;
4063 u32 *data;
4064
4065 /* SBSS section. */
4066 u32 sbss_addr;
4067 u32 sbss_len;
4068 u32 sbss_index;
4069 u32 *sbss;
4070
4071 /* BSS section. */
4072 u32 bss_addr;
4073 u32 bss_len;
4074 u32 bss_index;
4075 u32 *bss;
4076
4077 /* Read-only section. */
4078 u32 rodata_addr;
4079 u32 rodata_len;
4080 u32 rodata_index;
4081 u32 *rodata;
4082};
4083
4084#define RV2P_PROC1 0
4085#define RV2P_PROC2 1
4086
4087
4088/* This value (in milliseconds) determines the frequency of the driver
4089 * issuing the PULSE message code. The firmware monitors this periodic
4090 * pulse to determine when to switch to an OS-absent mode. */
4091#define DRV_PULSE_PERIOD_MS 250
4092
4093/* This value (in milliseconds) determines how long the driver should
4094 * wait for an acknowledgement from the firmware before timing out. Once
4095 * the firmware has timed out, the driver will assume there is no firmware
4096 * running and there won't be any firmware-driver synchronization during a
4097 * driver reset. */
4098#define FW_ACK_TIME_OUT_MS 50
4099
4100
4101#define BNX2_DRV_RESET_SIGNATURE 0x00000000
4102#define BNX2_DRV_RESET_SIGNATURE_MAGIC 0x4841564b /* HAVK */
4103//#define DRV_RESET_SIGNATURE_MAGIC 0x47495352 /* RSIG */
4104
4105#define BNX2_DRV_MB 0x00000004
4106#define BNX2_DRV_MSG_CODE 0xff000000
4107#define BNX2_DRV_MSG_CODE_RESET 0x01000000
4108#define BNX2_DRV_MSG_CODE_UNLOAD 0x02000000
4109#define BNX2_DRV_MSG_CODE_SHUTDOWN 0x03000000
4110#define BNX2_DRV_MSG_CODE_SUSPEND_WOL 0x04000000
4111#define BNX2_DRV_MSG_CODE_FW_TIMEOUT 0x05000000
4112#define BNX2_DRV_MSG_CODE_PULSE 0x06000000
4113#define BNX2_DRV_MSG_CODE_DIAG 0x07000000
4114#define BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL 0x09000000
4115
4116#define BNX2_DRV_MSG_DATA 0x00ff0000
4117#define BNX2_DRV_MSG_DATA_WAIT0 0x00010000
4118#define BNX2_DRV_MSG_DATA_WAIT1 0x00020000
4119#define BNX2_DRV_MSG_DATA_WAIT2 0x00030000
4120#define BNX2_DRV_MSG_DATA_WAIT3 0x00040000
4121
4122#define BNX2_DRV_MSG_SEQ 0x0000ffff
4123
4124#define BNX2_FW_MB 0x00000008
4125#define BNX2_FW_MSG_ACK 0x0000ffff
4126#define BNX2_FW_MSG_STATUS_MASK 0x00ff0000
4127#define BNX2_FW_MSG_STATUS_OK 0x00000000
4128#define BNX2_FW_MSG_STATUS_FAILURE 0x00ff0000
4129
4130#define BNX2_LINK_STATUS 0x0000000c
4131
4132#define BNX2_DRV_PULSE_MB 0x00000010
4133#define BNX2_DRV_PULSE_SEQ_MASK 0x0000ffff
4134
4135/* Indicate to the firmware not to go into the
4136 * OS absent when it is not getting driver pulse.
4137 * This is used for debugging. */
4138#define BNX2_DRV_MSG_DATA_PULSE_CODE_ALWAYS_ALIVE 0x00010000
4139
4140#define BNX2_DEV_INFO_SIGNATURE 0x00000020
4141#define BNX2_DEV_INFO_SIGNATURE_MAGIC 0x44564900
4142#define BNX2_DEV_INFO_SIGNATURE_MAGIC_MASK 0xffffff00
4143#define BNX2_DEV_INFO_FEATURE_CFG_VALID 0x01
4144#define BNX2_DEV_INFO_SECONDARY_PORT 0x80
4145#define BNX2_DEV_INFO_DRV_ALWAYS_ALIVE 0x40
4146
4147#define BNX2_SHARED_HW_CFG_PART_NUM 0x00000024
4148
4149#define BNX2_SHARED_HW_CFG_POWER_DISSIPATED 0x00000034
4150#define BNX2_SHARED_HW_CFG_POWER_STATE_D3_MASK 0xff000000
4151#define BNX2_SHARED_HW_CFG_POWER_STATE_D2_MASK 0xff0000
4152#define BNX2_SHARED_HW_CFG_POWER_STATE_D1_MASK 0xff00
4153#define BNX2_SHARED_HW_CFG_POWER_STATE_D0_MASK 0xff
4154
4155#define BNX2_SHARED_HW_CFG POWER_CONSUMED 0x00000038
4156#define BNX2_SHARED_HW_CFG_CONFIG 0x0000003c
4157#define BNX2_SHARED_HW_CFG_DESIGN_NIC 0
4158#define BNX2_SHARED_HW_CFG_DESIGN_LOM 0x1
4159#define BNX2_SHARED_HW_CFG_PHY_COPPER 0
4160#define BNX2_SHARED_HW_CFG_PHY_FIBER 0x2
4161#define BNX2_SHARED_HW_CFG_LED_MODE_SHIFT_BITS 8
4162#define BNX2_SHARED_HW_CFG_LED_MODE_MASK 0x300
4163#define BNX2_SHARED_HW_CFG_LED_MODE_MAC 0
4164#define BNX2_SHARED_HW_CFG_LED_MODE_GPHY1 0x100
4165#define BNX2_SHARED_HW_CFG_LED_MODE_GPHY2 0x200
4166
4167#define BNX2_DEV_INFO_BC_REV 0x0000004c
4168
4169#define BNX2_PORT_HW_CFG_MAC_UPPER 0x00000050
4170#define BNX2_PORT_HW_CFG_UPPERMAC_MASK 0xffff
4171
4172#define BNX2_PORT_HW_CFG_MAC_LOWER 0x00000054
4173#define BNX2_PORT_HW_CFG_CONFIG 0x00000058
4174
4175#define BNX2_PORT_HW_CFG_IMD_MAC_A_UPPER 0x00000068
4176#define BNX2_PORT_HW_CFG_IMD_MAC_A_LOWER 0x0000006c
4177#define BNX2_PORT_HW_CFG_IMD_MAC_B_UPPER 0x00000070
4178#define BNX2_PORT_HW_CFG_IMD_MAC_B_LOWER 0x00000074
4179#define BNX2_PORT_HW_CFG_ISCSI_MAC_UPPER 0x00000078
4180#define BNX2_PORT_HW_CFG_ISCSI_MAC_LOWER 0x0000007c
4181
4182#define BNX2_DEV_INFO_PER_PORT_HW_CONFIG2 0x000000b4
4183
4184#define BNX2_DEV_INFO_FORMAT_REV 0x000000c4
4185#define BNX2_DEV_INFO_FORMAT_REV_MASK 0xff000000
4186#define BNX2_DEV_INFO_FORMAT_REV_ID ('A' << 24)
4187
4188#define BNX2_SHARED_FEATURE 0x000000c8
4189#define BNX2_SHARED_FEATURE_MASK 0xffffffff
4190
4191#define BNX2_PORT_FEATURE 0x000000d8
4192#define BNX2_PORT2_FEATURE 0x00000014c
4193#define BNX2_PORT_FEATURE_WOL_ENABLED 0x01000000
4194#define BNX2_PORT_FEATURE_MBA_ENABLED 0x02000000
4195#define BNX2_PORT_FEATURE_ASF_ENABLED 0x04000000
4196#define BNX2_PORT_FEATURE_IMD_ENABLED 0x08000000
4197#define BNX2_PORT_FEATURE_BAR1_SIZE_MASK 0xf
4198#define BNX2_PORT_FEATURE_BAR1_SIZE_DISABLED 0x0
4199#define BNX2_PORT_FEATURE_BAR1_SIZE_64K 0x1
4200#define BNX2_PORT_FEATURE_BAR1_SIZE_128K 0x2
4201#define BNX2_PORT_FEATURE_BAR1_SIZE_256K 0x3
4202#define BNX2_PORT_FEATURE_BAR1_SIZE_512K 0x4
4203#define BNX2_PORT_FEATURE_BAR1_SIZE_1M 0x5
4204#define BNX2_PORT_FEATURE_BAR1_SIZE_2M 0x6
4205#define BNX2_PORT_FEATURE_BAR1_SIZE_4M 0x7
4206#define BNX2_PORT_FEATURE_BAR1_SIZE_8M 0x8
4207#define BNX2_PORT_FEATURE_BAR1_SIZE_16M 0x9
4208#define BNX2_PORT_FEATURE_BAR1_SIZE_32M 0xa
4209#define BNX2_PORT_FEATURE_BAR1_SIZE_64M 0xb
4210#define BNX2_PORT_FEATURE_BAR1_SIZE_128M 0xc
4211#define BNX2_PORT_FEATURE_BAR1_SIZE_256M 0xd
4212#define BNX2_PORT_FEATURE_BAR1_SIZE_512M 0xe
4213#define BNX2_PORT_FEATURE_BAR1_SIZE_1G 0xf
4214
4215#define BNX2_PORT_FEATURE_WOL 0xdc
4216#define BNX2_PORT2_FEATURE_WOL 0x150
4217#define BNX2_PORT_FEATURE_WOL_DEFAULT_SHIFT_BITS 4
4218#define BNX2_PORT_FEATURE_WOL_DEFAULT_MASK 0x30
4219#define BNX2_PORT_FEATURE_WOL_DEFAULT_DISABLE 0
4220#define BNX2_PORT_FEATURE_WOL_DEFAULT_MAGIC 0x10
4221#define BNX2_PORT_FEATURE_WOL_DEFAULT_ACPI 0x20
4222#define BNX2_PORT_FEATURE_WOL_DEFAULT_MAGIC_AND_ACPI 0x30
4223#define BNX2_PORT_FEATURE_WOL_LINK_SPEED_MASK 0xf
4224#define BNX2_PORT_FEATURE_WOL_LINK_SPEED_AUTONEG 0
4225#define BNX2_PORT_FEATURE_WOL_LINK_SPEED_10HALF 1
4226#define BNX2_PORT_FEATURE_WOL_LINK_SPEED_10FULL 2
4227#define BNX2_PORT_FEATURE_WOL_LINK_SPEED_100HALF 3
4228#define BNX2_PORT_FEATURE_WOL_LINK_SPEED_100FULL 4
4229#define BNX2_PORT_FEATURE_WOL_LINK_SPEED_1000HALF 5
4230#define BNX2_PORT_FEATURE_WOL_LINK_SPEED_1000FULL 6
4231#define BNX2_PORT_FEATURE_WOL_AUTONEG_ADVERTISE_1000 0x40
4232#define BNX2_PORT_FEATURE_WOL_RESERVED_PAUSE_CAP 0x400
4233#define BNX2_PORT_FEATURE_WOL_RESERVED_ASYM_PAUSE_CAP 0x800
4234
4235#define BNX2_PORT_FEATURE_MBA 0xe0
4236#define BNX2_PORT2_FEATURE_MBA 0x154
4237#define BNX2_PORT_FEATURE_MBA_BOOT_AGENT_TYPE_SHIFT_BITS 0
4238#define BNX2_PORT_FEATURE_MBA_BOOT_AGENT_TYPE_MASK 0x3
4239#define BNX2_PORT_FEATURE_MBA_BOOT_AGENT_TYPE_PXE 0
4240#define BNX2_PORT_FEATURE_MBA_BOOT_AGENT_TYPE_RPL 1
4241#define BNX2_PORT_FEATURE_MBA_BOOT_AGENT_TYPE_BOOTP 2
4242#define BNX2_PORT_FEATURE_MBA_LINK_SPEED_SHIFT_BITS 2
4243#define BNX2_PORT_FEATURE_MBA_LINK_SPEED_MASK 0x3c
4244#define BNX2_PORT_FEATURE_MBA_LINK_SPEED_AUTONEG 0
4245#define BNX2_PORT_FEATURE_MBA_LINK_SPEED_10HALF 0x4
4246#define BNX2_PORT_FEATURE_MBA_LINK_SPEED_10FULL 0x8
4247#define BNX2_PORT_FEATURE_MBA_LINK_SPEED_100HALF 0xc
4248#define BNX2_PORT_FEATURE_MBA_LINK_SPEED_100FULL 0x10
4249#define BNX2_PORT_FEATURE_MBA_LINK_SPEED_1000HALF 0x14
4250#define BNX2_PORT_FEATURE_MBA_LINK_SPEED_1000FULL 0x18
4251#define BNX2_PORT_FEATURE_MBA_SETUP_PROMPT_ENABLE 0x40
4252#define BNX2_PORT_FEATURE_MBA_HOTKEY_CTRL_S 0
4253#define BNX2_PORT_FEATURE_MBA_HOTKEY_CTRL_B 0x80
4254#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_SHIFT_BITS 8
4255#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_MASK 0xff00
4256#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_DISABLED 0
4257#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_1K 0x100
4258#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_2K 0x200
4259#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_4K 0x300
4260#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_8K 0x400
4261#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_16K 0x500
4262#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_32K 0x600
4263#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_64K 0x700
4264#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_128K 0x800
4265#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_256K 0x900
4266#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_512K 0xa00
4267#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_1M 0xb00
4268#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_2M 0xc00
4269#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_4M 0xd00
4270#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_8M 0xe00
4271#define BNX2_PORT_FEATURE_MBA_EXP_ROM_SIZE_16M 0xf00
4272#define BNX2_PORT_FEATURE_MBA_MSG_TIMEOUT_SHIFT_BITS 16
4273#define BNX2_PORT_FEATURE_MBA_MSG_TIMEOUT_MASK 0xf0000
4274#define BNX2_PORT_FEATURE_MBA_BIOS_BOOTSTRAP_SHIFT_BITS 20
4275#define BNX2_PORT_FEATURE_MBA_BIOS_BOOTSTRAP_MASK 0x300000
4276#define BNX2_PORT_FEATURE_MBA_BIOS_BOOTSTRAP_AUTO 0
4277#define BNX2_PORT_FEATURE_MBA_BIOS_BOOTSTRAP_BBS 0x100000
4278#define BNX2_PORT_FEATURE_MBA_BIOS_BOOTSTRAP_INT18H 0x200000
4279#define BNX2_PORT_FEATURE_MBA_BIOS_BOOTSTRAP_INT19H 0x300000
4280
4281#define BNX2_PORT_FEATURE_IMD 0xe4
4282#define BNX2_PORT2_FEATURE_IMD 0x158
4283#define BNX2_PORT_FEATURE_IMD_LINK_OVERRIDE_DEFAULT 0
4284#define BNX2_PORT_FEATURE_IMD_LINK_OVERRIDE_ENABLE 1
4285
4286#define BNX2_PORT_FEATURE_VLAN 0xe8
4287#define BNX2_PORT2_FEATURE_VLAN 0x15c
4288#define BNX2_PORT_FEATURE_MBA_VLAN_TAG_MASK 0xffff
4289#define BNX2_PORT_FEATURE_MBA_VLAN_ENABLE 0x10000
4290
4291#define BNX2_BC_STATE_RESET_TYPE 0x000001c0
4292#define BNX2_BC_STATE_RESET_TYPE_SIG 0x00005254
4293#define BNX2_BC_STATE_RESET_TYPE_SIG_MASK 0x0000ffff
4294#define BNX2_BC_STATE_RESET_TYPE_NONE (BNX2_BC_STATE_RESET_TYPE_SIG | \
4295 0x00010000)
4296#define BNX2_BC_STATE_RESET_TYPE_PCI (BNX2_BC_STATE_RESET_TYPE_SIG | \
4297 0x00020000)
4298#define BNX2_BC_STATE_RESET_TYPE_VAUX (BNX2_BC_STATE_RESET_TYPE_SIG | \
4299 0x00030000)
4300#define BNX2_BC_STATE_RESET_TYPE_DRV_MASK DRV_MSG_CODE
4301#define BNX2_BC_STATE_RESET_TYPE_DRV_RESET (BNX2_BC_STATE_RESET_TYPE_SIG | \
4302 DRV_MSG_CODE_RESET)
4303#define BNX2_BC_STATE_RESET_TYPE_DRV_UNLOAD (BNX2_BC_STATE_RESET_TYPE_SIG | \
4304 DRV_MSG_CODE_UNLOAD)
4305#define BNX2_BC_STATE_RESET_TYPE_DRV_SHUTDOWN (BNX2_BC_STATE_RESET_TYPE_SIG | \
4306 DRV_MSG_CODE_SHUTDOWN)
4307#define BNX2_BC_STATE_RESET_TYPE_DRV_WOL (BNX2_BC_STATE_RESET_TYPE_SIG | \
4308 DRV_MSG_CODE_WOL)
4309#define BNX2_BC_STATE_RESET_TYPE_DRV_DIAG (BNX2_BC_STATE_RESET_TYPE_SIG | \
4310 DRV_MSG_CODE_DIAG)
4311#define BNX2_BC_STATE_RESET_TYPE_VALUE(msg) (BNX2_BC_STATE_RESET_TYPE_SIG | \
4312 (msg))
4313
4314#define BNX2_BC_STATE 0x000001c4
4315#define BNX2_BC_STATE_ERR_MASK 0x0000ff00
4316#define BNX2_BC_STATE_SIGN 0x42530000
4317#define BNX2_BC_STATE_SIGN_MASK 0xffff0000
4318#define BNX2_BC_STATE_BC1_START (BNX2_BC_STATE_SIGN | 0x1)
4319#define BNX2_BC_STATE_GET_NVM_CFG1 (BNX2_BC_STATE_SIGN | 0x2)
4320#define BNX2_BC_STATE_PROG_BAR (BNX2_BC_STATE_SIGN | 0x3)
4321#define BNX2_BC_STATE_INIT_VID (BNX2_BC_STATE_SIGN | 0x4)
4322#define BNX2_BC_STATE_GET_NVM_CFG2 (BNX2_BC_STATE_SIGN | 0x5)
4323#define BNX2_BC_STATE_APPLY_WKARND (BNX2_BC_STATE_SIGN | 0x6)
4324#define BNX2_BC_STATE_LOAD_BC2 (BNX2_BC_STATE_SIGN | 0x7)
4325#define BNX2_BC_STATE_GOING_BC2 (BNX2_BC_STATE_SIGN | 0x8)
4326#define BNX2_BC_STATE_GOING_DIAG (BNX2_BC_STATE_SIGN | 0x9)
4327#define BNX2_BC_STATE_RT_FINAL_INIT (BNX2_BC_STATE_SIGN | 0x81)
4328#define BNX2_BC_STATE_RT_WKARND (BNX2_BC_STATE_SIGN | 0x82)
4329#define BNX2_BC_STATE_RT_DRV_PULSE (BNX2_BC_STATE_SIGN | 0x83)
4330#define BNX2_BC_STATE_RT_FIOEVTS (BNX2_BC_STATE_SIGN | 0x84)
4331#define BNX2_BC_STATE_RT_DRV_CMD (BNX2_BC_STATE_SIGN | 0x85)
4332#define BNX2_BC_STATE_RT_LOW_POWER (BNX2_BC_STATE_SIGN | 0x86)
4333#define BNX2_BC_STATE_RT_SET_WOL (BNX2_BC_STATE_SIGN | 0x87)
4334#define BNX2_BC_STATE_RT_OTHER_FW (BNX2_BC_STATE_SIGN | 0x88)
4335#define BNX2_BC_STATE_RT_GOING_D3 (BNX2_BC_STATE_SIGN | 0x89)
4336#define BNX2_BC_STATE_ERR_BAD_VERSION (BNX2_BC_STATE_SIGN | 0x0100)
4337#define BNX2_BC_STATE_ERR_BAD_BC2_CRC (BNX2_BC_STATE_SIGN | 0x0200)
4338#define BNX2_BC_STATE_ERR_BC1_LOOP (BNX2_BC_STATE_SIGN | 0x0300)
4339#define BNX2_BC_STATE_ERR_UNKNOWN_CMD (BNX2_BC_STATE_SIGN | 0x0400)
4340#define BNX2_BC_STATE_ERR_DRV_DEAD (BNX2_BC_STATE_SIGN | 0x0500)
4341#define BNX2_BC_STATE_ERR_NO_RXP (BNX2_BC_STATE_SIGN | 0x0600)
4342#define BNX2_BC_STATE_ERR_TOO_MANY_RBUF (BNX2_BC_STATE_SIGN | 0x0700)
4343
4344#define BNX2_BC_STATE_DEBUG_CMD 0x1dc
4345#define BNX2_BC_STATE_BC_DBG_CMD_SIGNATURE 0x42440000
4346#define BNX2_BC_STATE_BC_DBG_CMD_SIGNATURE_MASK 0xffff0000
4347#define BNX2_BC_STATE_BC_DBG_CMD_LOOP_CNT_MASK 0xffff
4348#define BNX2_BC_STATE_BC_DBG_CMD_LOOP_INFINITE 0xffff
4349
4350#define HOST_VIEW_SHMEM_BASE 0x167c00
4351
4352#endif
diff --git a/drivers/net/bnx2_fw.h b/drivers/net/bnx2_fw.h
new file mode 100644
index 000000000000..35f3a2ae5ef1
--- /dev/null
+++ b/drivers/net/bnx2_fw.h
@@ -0,0 +1,2468 @@
1/* bnx2_fw.h: Broadcom NX2 network driver.
2 *
3 * Copyright (c) 2004, 2005 Broadcom 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, except as noted below.
8 *
9 * This file contains firmware data derived from proprietary unpublished
10 * source code, Copyright (c) 2004, 2005 Broadcom Corporation.
11 *
12 * Permission is hereby granted for the distribution of this firmware data
13 * in hexadecimal or equivalent format, provided this copyright notice is
14 * accompanying it.
15 */
16
17
18static int bnx2_COM_b06FwReleaseMajor = 0x0;
19static int bnx2_COM_b06FwReleaseMinor = 0x0;
20static int bnx2_COM_b06FwReleaseFix = 0x0;
21static u32 bnx2_COM_b06FwStartAddr = 0x080004a0;
22static u32 bnx2_COM_b06FwTextAddr = 0x08000000;
23static int bnx2_COM_b06FwTextLen = 0x4594;
24static u32 bnx2_COM_b06FwDataAddr = 0x080045e0;
25static int bnx2_COM_b06FwDataLen = 0x0;
26static u32 bnx2_COM_b06FwRodataAddr = 0x08004598;
27static int bnx2_COM_b06FwRodataLen = 0x18;
28static u32 bnx2_COM_b06FwBssAddr = 0x08004600;
29static int bnx2_COM_b06FwBssLen = 0x88;
30static u32 bnx2_COM_b06FwSbssAddr = 0x080045e0;
31static int bnx2_COM_b06FwSbssLen = 0x1c;
32static u32 bnx2_COM_b06FwText[(0x4594/4) + 1] = {
33 0x0a000128, 0x00000000, 0x00000000, 0x0000000d, 0x636f6d20, 0x302e362e,
34 0x39000000, 0x00060902, 0x00000000, 0x00000003, 0x00000014, 0x00000032,
35 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
36 0x00000010, 0x000003e8, 0x0000ea60, 0x00000001, 0x00000000, 0x00000000,
37 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
38 0x0000ffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
39 0x00000000, 0x00000000, 0x00000002, 0x00000020, 0x00000000, 0x00000000,
40 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
41 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
42 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
43 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
44 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
45 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
46 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
47 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
48 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
49 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
50 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
51 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
52 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
53 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
54 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
55 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
56 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
57 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
58 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
59 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
60 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
61 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
62 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
63 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
64 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
65 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
66 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
67 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
68 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
69 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
70 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
71 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
72 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
73 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
74 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
75 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
76 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
77 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
78 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
79 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
80 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
81 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
82 0x00000000, 0x00000000, 0x00000000, 0x10000003, 0x00000000, 0x0000000d,
83 0x0000000d, 0x3c020800, 0x244245e0, 0x3c030800, 0x24634688, 0xac400000,
84 0x0043202b, 0x1480fffd, 0x24420004, 0x3c1d0800, 0x37bd7ffc, 0x03a0f021,
85 0x3c100800, 0x261004a0, 0x3c1c0800, 0x279c45e0, 0x0e0001f2, 0x00000000,
86 0x0000000d, 0x27bdffe8, 0x3c1a8000, 0x3c020008, 0x0342d825, 0x3c036010,
87 0xafbf0010, 0x8c655000, 0x3c020800, 0x24470ac8, 0x3c040800, 0x24864600,
88 0x2402ff7f, 0x00a22824, 0x34a5380c, 0xac655000, 0x00002821, 0x24020037,
89 0x24030c80, 0xaf420008, 0xaf430024, 0xacc70000, 0x24a50001, 0x2ca20016,
90 0x1440fffc, 0x24c60004, 0x24844600, 0x3c020800, 0x24420ad4, 0x3c030800,
91 0x246309d4, 0xac820004, 0x3c020800, 0x24420618, 0x3c050800, 0x24a50ca0,
92 0xac82000c, 0x3c020800, 0x24423100, 0xac830008, 0x3c030800, 0x246325c8,
93 0xac820014, 0x3c020800, 0x24422b0c, 0xac830018, 0xac83001c, 0x3c030800,
94 0x24630adc, 0xac820024, 0x3c020800, 0x24423040, 0xac83002c, 0x3c030800,
95 0x24633060, 0xac820030, 0x3c020800, 0x24422f6c, 0xac830034, 0x3c030800,
96 0x24632c60, 0xac82003c, 0x3c020800, 0x24420b6c, 0xac850010, 0xac850020,
97 0xac830040, 0x0e000bd6, 0xac820050, 0x8fbf0010, 0x03e00008, 0x27bd0018,
98 0x27bdffe0, 0xafb00010, 0x27500100, 0xafbf0018, 0xafb10014, 0x9203000b,
99 0x24020003, 0x1462005b, 0x96110008, 0x32220001, 0x10400009, 0x27430080,
100 0x8e020000, 0x96040014, 0x000211c2, 0x00021040, 0x00621821, 0xa4640000,
101 0x0a0001cb, 0x3c020800, 0x3c020800, 0x8c430020, 0x1060002a, 0x3c030800,
102 0x0e001006, 0x00000000, 0x97420108, 0x8f850018, 0x9743010c, 0x3042003e,
103 0x00021400, 0x00621825, 0xaca30000, 0x8f840018, 0x8f420100, 0xac820004,
104 0x97430116, 0x9742010e, 0x8f840018, 0x00031c00, 0x00431025, 0xac820008,
105 0x97430110, 0x97440112, 0x8f850018, 0x00031c00, 0x00832025, 0xaca4000c,
106 0x97420114, 0x8f840018, 0x3042ffff, 0xac820010, 0x8f830018, 0xac600014,
107 0x8f820018, 0x3c030800, 0xac400018, 0x9462466e, 0x8f840018, 0x3c032000,
108 0x00431025, 0xac82001c, 0x0e001044, 0x24040001, 0x3c030800, 0x8c620040,
109 0x24420001, 0xac620040, 0x3c020800, 0x8c430044, 0x32240004, 0x24630001,
110 0x10800017, 0xac430044, 0x8f4202b8, 0x04430007, 0x8e020020, 0x3c040800,
111 0x8c830060, 0x24020001, 0x24630001, 0x0a0001ed, 0xac830060, 0x3c060800,
112 0x8cc4005c, 0xaf420280, 0x96030016, 0x00001021, 0xa7430284, 0x8e050004,
113 0x24840001, 0x3c031000, 0xaf450288, 0xaf4302b8, 0x0a0001ed, 0xacc4005c,
114 0x32220002, 0x0a0001ed, 0x0002102b, 0x3c026000, 0xac400808, 0x0000000d,
115 0x00001021, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
116 0x27bdffc8, 0xafbf0034, 0xafbe0030, 0xafb7002c, 0xafb60028, 0xafb50024,
117 0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014, 0x0e00013f, 0xafb00010,
118 0x24110020, 0x24150030, 0x2794000c, 0x27930008, 0x3c124000, 0x3c1e0800,
119 0x3c170800, 0x3c160800, 0x8f820004, 0x3c040800, 0x8c830020, 0x10430004,
120 0x00000000, 0xaf830004, 0x0e00110b, 0x00000000, 0x8f500000, 0x32020007,
121 0x1040fff5, 0x32020001, 0x1040002b, 0x32020002, 0x8f420100, 0xaf420020,
122 0x8f430104, 0xaf4300a8, 0x9342010b, 0x93630000, 0x306300ff, 0x10710005,
123 0x304400ff, 0x10750006, 0x2c820016, 0x0a000227, 0x00000000, 0xaf940000,
124 0x0a000228, 0x2c820016, 0xaf930000, 0x0a000228, 0x00000000, 0xaf800000,
125 0x14400005, 0x00041880, 0x0e0002b2, 0x00000000, 0x0a000234, 0x00000000,
126 0x3c020800, 0x24424600, 0x00621821, 0x8c620000, 0x0040f809, 0x00000000,
127 0x10400005, 0x8fc20034, 0x8f420104, 0x3c016020, 0xac220014, 0x8fc20034,
128 0xaf520138, 0x24420001, 0xafc20034, 0x32020002, 0x10400019, 0x32020004,
129 0x8f420140, 0xaf420020, 0x93630000, 0x306300ff, 0x10710005, 0x00000000,
130 0x10750006, 0x00000000, 0x0a000250, 0x00000000, 0xaf940000, 0x0a000251,
131 0x00000000, 0xaf930000, 0x0a000251, 0x00000000, 0xaf800000, 0x0e0008b9,
132 0x00000000, 0x8ee20038, 0xaf520178, 0x24420001, 0xaee20038, 0x32020004,
133 0x1040ffad, 0x00000000, 0x8f420180, 0xaf420020, 0x93630000, 0x306300ff,
134 0x10710005, 0x00000000, 0x10750006, 0x00000000, 0x0a00026a, 0x00000000,
135 0xaf940000, 0x0a00026b, 0x00000000, 0xaf930000, 0x0a00026b, 0x00000000,
136 0xaf800000, 0x93620000, 0x14510004, 0x8ec2003c, 0x0e000835, 0x00000000,
137 0x8ec2003c, 0xaf5201b8, 0x24420001, 0x0a000206, 0xaec2003c, 0x27bdffe8,
138 0xafbf0010, 0x97420108, 0x24033000, 0x30447000, 0x10830012, 0x28823001,
139 0x10400007, 0x24024000, 0x1080000b, 0x24022000, 0x1082001a, 0x24020001,
140 0x0a000299, 0x00000000, 0x1082000c, 0x24025000, 0x1082000e, 0x00000000,
141 0x0a000299, 0x00000000, 0x0000000d, 0x0a00029b, 0x00001021, 0x0e000300,
142 0x00000000, 0x0a00029b, 0x00001021, 0x0e00048f, 0x00000000, 0x0a00029b,
143 0x00001021, 0x0e000fdf, 0x00000000, 0x0a00029b, 0x00001021, 0x0000000d,
144 0x00001021, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x93620000, 0x24030020,
145 0x304400ff, 0x10830005, 0x24020030, 0x10820007, 0x00000000, 0x0a0002af,
146 0x00000000, 0x2782000c, 0xaf820000, 0x03e00008, 0x00000000, 0x27820008,
147 0xaf820000, 0x03e00008, 0x00000000, 0xaf800000, 0x03e00008, 0x00000000,
148 0x0000000d, 0x03e00008, 0x00001021, 0x03e00008, 0x00001021, 0x27440100,
149 0x94830008, 0x30620004, 0x10400017, 0x30620002, 0x8f4202b8, 0x04430007,
150 0x8c820020, 0x3c040800, 0x8c830060, 0x24020001, 0x24630001, 0x03e00008,
151 0xac830060, 0xaf420280, 0x94830016, 0x3c060800, 0xa7430284, 0x8c850004,
152 0x8cc4005c, 0x00001021, 0x3c031000, 0x24840001, 0xaf450288, 0xaf4302b8,
153 0x03e00008, 0xacc4005c, 0x14400003, 0x3c040800, 0x03e00008, 0x00001021,
154 0x8c830084, 0x24020001, 0x24630001, 0x03e00008, 0xac830084, 0x27450100,
155 0x3c040800, 0x8c820088, 0x94a3000c, 0x24420001, 0x007a1821, 0xac820088,
156 0x8ca40018, 0x90664000, 0xaf440038, 0x8ca2001c, 0x2403fff8, 0x00063600,
157 0x00431024, 0x34420004, 0x3c030005, 0xaf42003c, 0xaf430030, 0x00000000,
158 0x00000000, 0x00000000, 0xaf460404, 0x00000000, 0x00000000, 0x00000000,
159 0x3c020006, 0x34420001, 0xaf420030, 0x00000000, 0x00000000, 0x00000000,
160 0x8f420000, 0x30420010, 0x1040fffd, 0x00001021, 0x03e00008, 0x00000000,
161 0x3c020800, 0x8c430020, 0x27bdffe8, 0xafb00010, 0x27500100, 0x1060001e,
162 0xafbf0014, 0x0e001006, 0x00000000, 0x8f830018, 0x8e020018, 0xac620000,
163 0x8f840018, 0x9602000c, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018,
164 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 0x8f840018,
165 0x3c026000, 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x9464466e,
166 0x8f850018, 0x00021400, 0x00441025, 0x24040001, 0x0e001044, 0xaca2001c,
167 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdffc8, 0xafb3001c,
168 0x00009821, 0xafb7002c, 0x0000b821, 0xafbe0030, 0x0000f021, 0xafb50024,
169 0x27550100, 0xafbf0034, 0xafb60028, 0xafb40020, 0xafb20018, 0xafb10014,
170 0xafb00010, 0x96a20008, 0x8f540100, 0x8eb20018, 0x30420001, 0x10400037,
171 0x02a0b021, 0x8f630054, 0x2642ffff, 0x00431023, 0x18400006, 0x00000000,
172 0x0000000d, 0x00000000, 0x24000128, 0x0a000372, 0x00002021, 0x8f62004c,
173 0x02421023, 0x18400028, 0x00002021, 0x93650120, 0x93640121, 0x3c030800,
174 0x8c62008c, 0x308400ff, 0x24420001, 0x30a500ff, 0x00803821, 0x1485000b,
175 0xac62008c, 0x3c040800, 0x8c830090, 0x24630001, 0xac830090, 0x93620122,
176 0x30420001, 0x00021023, 0x30420005, 0x0a000372, 0x34440004, 0x27660100,
177 0x00041080, 0x00c21021, 0x8c430000, 0x02431823, 0x04600004, 0x24820001,
178 0x30440007, 0x1485fff9, 0x00041080, 0x10870007, 0x3c030800, 0xa3640121,
179 0x8c620094, 0x24040005, 0x24420001, 0x0a000372, 0xac620094, 0x24040004,
180 0x00809821, 0x9362003f, 0x304400ff, 0x38830016, 0x2c630001, 0x38820010,
181 0x2c420001, 0x00621825, 0x1460000c, 0x24020001, 0x38830008, 0x2c630001,
182 0x38820014, 0x2c420001, 0x00621825, 0x14600005, 0x24020001, 0x24020012,
183 0x14820002, 0x00001021, 0x24020001, 0x50400007, 0x8eb10020, 0x8ea20020,
184 0x8f630040, 0x00408821, 0x00431023, 0x5c400001, 0x8f710040, 0x9343010b,
185 0x24020004, 0x54620005, 0x36730080, 0x96a20008, 0x36730002, 0x24170001,
186 0x305e0020, 0x2402fffb, 0x02628024, 0x1200002a, 0x3c030800, 0x8c620030,
187 0x02021024, 0x10400026, 0x3c020800, 0x8c430020, 0x10600024, 0x32620004,
188 0x0e001006, 0x00000000, 0x8f830018, 0x8f420100, 0xac620000, 0x8f840018,
189 0x02201821, 0x32620002, 0xac900004, 0x8f840018, 0x50400001, 0x8ec30014,
190 0xac830008, 0x8f830018, 0x8ec20020, 0xac62000c, 0x8f840018, 0x8f620040,
191 0xac820010, 0x8f830018, 0x8ec20018, 0xac620014, 0x8f840018, 0x3c026000,
192 0x8c434448, 0x3c020800, 0xac830018, 0x9443466e, 0x8f840018, 0x3c024010,
193 0x00621825, 0xac83001c, 0x0e001044, 0x24040001, 0x32620004, 0x10400076,
194 0x00003821, 0x3c029000, 0x34420001, 0x3c038000, 0x02821025, 0xa360007c,
195 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620023,
196 0x30420080, 0x10400011, 0x00000000, 0x8f65005c, 0x8f63004c, 0x9764003c,
197 0x8f620064, 0x00a32823, 0x00852821, 0x00a2102b, 0x54400006, 0x3c023fff,
198 0x93620023, 0x3042007f, 0xa3620023, 0xaf720064, 0x3c023fff, 0x0a0003f1,
199 0x3442ffff, 0x8f62005c, 0x02421023, 0x04400011, 0x00000000, 0x8f65005c,
200 0x8f630064, 0x9764003c, 0x3c023fff, 0x3442ffff, 0xaf720064, 0x00a32823,
201 0x00852821, 0x0045102b, 0x10400004, 0x02451021, 0x3c053fff, 0x34a5ffff,
202 0x02451021, 0xaf62005c, 0x24070001, 0xaf72004c, 0x8f620054, 0x16420005,
203 0x00000000, 0x93620023, 0x30420040, 0x10400017, 0x24020001, 0x9762006a,
204 0x00022880, 0x50a00001, 0x24050001, 0x97630068, 0x93640081, 0x3c020800,
205 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021,
206 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021, 0x8f420074,
207 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c, 0x3c028000, 0x34420001,
208 0x02821025, 0xa3600081, 0xaf420020, 0x9363007e, 0x9362007a, 0x10620004,
209 0x00000000, 0x0e000f2a, 0x00000000, 0x00403821, 0x10e00017, 0x3c029000,
210 0x34420001, 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024,
211 0x1440fffd, 0x3c028000, 0x9363007d, 0x34420001, 0x3c048000, 0x02821025,
212 0xa363007d, 0xaf420020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002,
213 0x3c031000, 0xaf5401c0, 0xa34201c4, 0xaf4301f8, 0x8ea30014, 0x8f620040,
214 0x14430003, 0x00431023, 0x0a000443, 0x00001021, 0x28420001, 0x10400034,
215 0x00000000, 0x8f620040, 0xaf630040, 0x9362003e, 0x30420001, 0x1440000b,
216 0x3c029000, 0x93620022, 0x24420001, 0xa3620022, 0x93630022, 0x3c020800,
217 0x8c440098, 0x0064182b, 0x1460001e, 0x3c020800, 0x3c029000, 0x34420001,
218 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
219 0x00000000, 0x3c038000, 0x9362007d, 0x34630001, 0x3c048000, 0x02831825,
220 0x34420001, 0xa362007d, 0xaf430020, 0x8f4201f8, 0x00441024, 0x1440fffd,
221 0x24020002, 0x3c031000, 0xaf5401c0, 0xa34201c4, 0x24020001, 0xaf4301f8,
222 0xa7620012, 0x0a000476, 0xa3600022, 0x9743007a, 0x9444002a, 0x00641821,
223 0x3063fffe, 0xa7630012, 0x0e000b68, 0x00000000, 0x12e00003, 0x00000000,
224 0x0e000f27, 0x00000000, 0x53c00004, 0x96a20008, 0x0e000c10, 0x00000000,
225 0x96a20008, 0x8fbf0034, 0x8fbe0030, 0x8fb7002c, 0x8fb60028, 0x8fb50024,
226 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x00021042,
227 0x30420001, 0x03e00008, 0x27bd0038, 0x27bdffe8, 0xafbf0010, 0x97420108,
228 0x2403000b, 0x304400ff, 0x1083004e, 0x2882000c, 0x10400011, 0x24020006,
229 0x1082003e, 0x28820007, 0x10400007, 0x28820008, 0x1080002b, 0x24020001,
230 0x1082002e, 0x3c026000, 0x0a000504, 0x00000000, 0x14400061, 0x2882000a,
231 0x1440002b, 0x00000000, 0x0a0004ec, 0x00000000, 0x2402001c, 0x1082004e,
232 0x2882001d, 0x1040000e, 0x24020019, 0x10820041, 0x2882001a, 0x10400005,
233 0x2402000e, 0x10820036, 0x00000000, 0x0a000504, 0x00000000, 0x2402001b,
234 0x1082003c, 0x00000000, 0x0a000504, 0x00000000, 0x240200c1, 0x10820040,
235 0x288200c2, 0x10400005, 0x24020080, 0x1082001f, 0x00000000, 0x0a000504,
236 0x00000000, 0x240200c2, 0x1082003b, 0x00000000, 0x0a000504, 0x00000000,
237 0x3c026000, 0x0e000c7d, 0xac400808, 0x0a000506, 0x8fbf0010, 0x8c444448,
238 0x3c030800, 0xac640064, 0x0e000c7d, 0x00000000, 0x3c026000, 0x8c444448,
239 0x3c030800, 0x0a000505, 0xac640068, 0x8f440100, 0x0e000508, 0x00000000,
240 0x3c026000, 0x8c444448, 0x3c030800, 0x0a000505, 0xac64006c, 0x0e000cab,
241 0x00000000, 0x0a000506, 0x8fbf0010, 0x8f440100, 0x0e000cd5, 0x00000000,
242 0x0a000506, 0x8fbf0010, 0x0e000d1c, 0x00000000, 0x0a000506, 0x8fbf0010,
243 0x0000000d, 0x0a000506, 0x8fbf0010, 0x0e0005d7, 0x00000000, 0x0a000506,
244 0x8fbf0010, 0x8f440100, 0x0e000d7e, 0x00000000, 0x0a000506, 0x8fbf0010,
245 0x0e000e95, 0x00000000, 0x0a000506, 0x8fbf0010, 0x0e000626, 0x00000000,
246 0x0a000506, 0x8fbf0010, 0x0e000b68, 0x00000000, 0x0a000506, 0x8fbf0010,
247 0x0000000d, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0x3c029000,
248 0x34420001, 0xafb00010, 0x00808021, 0x02021025, 0x3c038000, 0xafbf0014,
249 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620005,
250 0x34420001, 0xa3620005, 0x8f63004c, 0x8f620054, 0x10620019, 0x3c028000,
251 0x9762006a, 0x00022880, 0x50a00001, 0x24050001, 0x97630068, 0x93640081,
252 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001,
253 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021,
254 0x8f420074, 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c, 0x3c028000,
255 0x34420001, 0x02021025, 0x0e000c7d, 0xaf420020, 0x3c029000, 0x34420001,
256 0x3c038000, 0x02021025, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd,
257 0x3c028000, 0x9363007d, 0x34420001, 0x3c048000, 0x02021025, 0xa363007d,
258 0xaf420020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x8fbf0014, 0xaf5001c0,
259 0x8fb00010, 0x24020002, 0x3c031000, 0xa34201c4, 0xaf4301f8, 0x03e00008,
260 0x27bd0018, 0x27bdffd8, 0xafbf0020, 0xafb3001c, 0xafb20018, 0xafb10014,
261 0xafb00010, 0x93630005, 0x00809021, 0x24020030, 0x30630030, 0x14620072,
262 0x00a09821, 0x3c020800, 0x8c430020, 0x1060006c, 0x00000000, 0x0e001006,
263 0x00000000, 0x8f820018, 0xac520000, 0x9363003e, 0x9362003f, 0x8f840018,
264 0x00031a00, 0x00431025, 0xac820004, 0x93630081, 0x93620082, 0x8f850018,
265 0x00031e00, 0x00021400, 0x00621825, 0xaca30008, 0x8f840018, 0x8f620040,
266 0xac82000c, 0x8f830018, 0x8f620048, 0xac620010, 0x8f840018, 0x8f62004c,
267 0x3c110800, 0xac820014, 0x8f830018, 0x8f620050, 0x26304660, 0x00002021,
268 0xac620018, 0x9602000e, 0x8f850018, 0x3c03c00b, 0x00431025, 0x0e001044,
269 0xaca2001c, 0x8f830018, 0x8f620054, 0xac620000, 0x8f840018, 0x8f620058,
270 0xac820004, 0x8f830018, 0x8f62005c, 0xac620008, 0x8f840018, 0x8f620060,
271 0xac82000c, 0x8f850018, 0x8f620064, 0xaca20010, 0x97630068, 0x9762006a,
272 0x8f840018, 0x00031c00, 0x00431025, 0xac820014, 0x8f830018, 0x00002021,
273 0xac600018, 0x9602000e, 0x8f850018, 0x3c03c00c, 0x00431025, 0x0e001044,
274 0xaca2001c, 0x8f840018, 0x8f630018, 0xac830000, 0x936200c4, 0x30420002,
275 0x10400006, 0x00000000, 0x976200c8, 0x8f830018, 0x3042ffff, 0x0a0005b5,
276 0xac620004, 0x8f820018, 0xac400004, 0x8f830018, 0x8f62006c, 0xac620008,
277 0x8f840018, 0x8f6200dc, 0xac82000c, 0x8f830018, 0xac600010, 0x93620005,
278 0x8f830018, 0x00021600, 0x00531025, 0xac620014, 0x8f850018, 0x3c026000,
279 0x8c434448, 0x24040001, 0x26224660, 0xaca30018, 0x9443000e, 0x8f850018,
280 0x3c02400d, 0x00621825, 0x0e001044, 0xaca3001c, 0x0e000d48, 0x02402021,
281 0x8fbf0020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008,
282 0x27bd0028, 0x27bdffe0, 0xafb00010, 0x27500100, 0xafbf0018, 0xafb10014,
283 0x9603000c, 0x240200c1, 0x5462001d, 0x8e040000, 0x3c029000, 0x8f440100,
284 0x34420001, 0x3c038000, 0x00821025, 0xaf420020, 0x8f420020, 0x00431024,
285 0x1440fffd, 0x00000000, 0x3c038000, 0x9362007d, 0x34630001, 0x3c058000,
286 0x00831825, 0x34420004, 0xa362007d, 0xaf430020, 0x8f4201f8, 0x00451024,
287 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4401c0, 0xa34201c4, 0xaf4301f8,
288 0x0a000622, 0x8fbf0018, 0x8f65004c, 0x24060001, 0x0e000db5, 0x2407049f,
289 0x3c020800, 0x8c430020, 0x9611000c, 0x1060001d, 0x8e100000, 0x0e001006,
290 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x00111400, 0xac820004,
291 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
292 0x8f840018, 0x240204a2, 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448,
293 0x24040001, 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018, 0x3c024019,
294 0x00621825, 0x0e001044, 0xaca3001c, 0x8fbf0018, 0x8fb10014, 0x8fb00010,
295 0x03e00008, 0x27bd0020, 0x27bdffb0, 0xafb1002c, 0x27510100, 0xafbf004c,
296 0xafbe0048, 0xafb70044, 0xafb60040, 0xafb5003c, 0xafb40038, 0xafb30034,
297 0xafb20030, 0xafb00028, 0x8e350000, 0x9634000c, 0x3c026000, 0x8c434448,
298 0x0000f021, 0xaf630170, 0x8f620040, 0x8e230014, 0x0000b821, 0x00431023,
299 0x044001ec, 0x0000b021, 0x32820010, 0x1040002e, 0x3c026000, 0x9363003f,
300 0x9222000e, 0x10430006, 0x2402000c, 0x9223000f, 0x10620003, 0x24020014,
301 0x14620025, 0x3c026000, 0x32820004, 0x10400007, 0x241e0001, 0x8f620050,
302 0x24420001, 0xaf620050, 0x8f630054, 0x24630001, 0xaf630054, 0x32830102,
303 0x24020002, 0x5462000d, 0x9222000f, 0x8f620040, 0x24420001, 0xaf620040,
304 0x8f630048, 0x8f620040, 0x24630001, 0x54620005, 0x9222000f, 0x8f620048,
305 0x24420001, 0xaf620048, 0x9222000f, 0xa362003f, 0x9223000f, 0x24020012,
306 0x14620007, 0x3c026000, 0x3c030800, 0x8c620074, 0x24420001, 0x0e000f6e,
307 0xac620074, 0x3c026000, 0x8c434448, 0x32820040, 0xaf630174, 0x32830020,
308 0xafa30010, 0x32830080, 0xafa30014, 0x32830001, 0xafa3001c, 0x32830008,
309 0xafa30020, 0x32830100, 0x104000bb, 0xafa30018, 0x8e260010, 0x8f630054,
310 0x24c2ffff, 0x00431023, 0x18400006, 0x00000000, 0x0000000d, 0x00000000,
311 0x24000128, 0x0a0006b2, 0x00009021, 0x8f62004c, 0x00c21023, 0x18400028,
312 0x00009021, 0x93650120, 0x93640121, 0x3c030800, 0x8c62008c, 0x308400ff,
313 0x24420001, 0x30a500ff, 0x00804021, 0x1485000b, 0xac62008c, 0x3c040800,
314 0x8c830090, 0x24630001, 0xac830090, 0x93620122, 0x30420001, 0x00021023,
315 0x30420005, 0x0a0006b2, 0x34520004, 0x27670100, 0x00041080, 0x00e21021,
316 0x8c430000, 0x00c31823, 0x04600004, 0x24820001, 0x30440007, 0x1485fff9,
317 0x00041080, 0x10880007, 0x3c030800, 0xa3640121, 0x8c620094, 0x24120005,
318 0x24420001, 0x0a0006b2, 0xac620094, 0x24120004, 0x32420001, 0x10400020,
319 0x3c020800, 0x8c430020, 0x8e300000, 0x1060001c, 0x8e330010, 0x0e001006,
320 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x24020001, 0xac820004,
321 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
322 0x8f820018, 0xac530014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001,
323 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018, 0x3c024010, 0x00621825,
324 0x0e001044, 0xaca3001c, 0x32420004, 0x10400060, 0x00003821, 0x3c029000,
325 0x8e260010, 0x34420001, 0x3c038000, 0x02a21025, 0xa360007c, 0xaf420020,
326 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620023, 0x30420080,
327 0x10400011, 0x00000000, 0x8f65005c, 0x8f63004c, 0x9764003c, 0x8f620064,
328 0x00a32823, 0x00852821, 0x00a2102b, 0x54400006, 0x3c023fff, 0x93620023,
329 0x3042007f, 0xa3620023, 0xaf660064, 0x3c023fff, 0x0a000702, 0x3442ffff,
330 0x8f62005c, 0x00c21023, 0x04400011, 0x00000000, 0x8f65005c, 0x8f630064,
331 0x9764003c, 0x3c023fff, 0x3442ffff, 0xaf660064, 0x00a32823, 0x00852821,
332 0x0045102b, 0x10400004, 0x00c51021, 0x3c053fff, 0x34a5ffff, 0x00c51021,
333 0xaf62005c, 0x24070001, 0xaf66004c, 0x8f620054, 0x14c20005, 0x00000000,
334 0x93620023, 0x30420040, 0x10400017, 0x24020001, 0x9762006a, 0x00022880,
335 0x50a00001, 0x24050001, 0x97630068, 0x93640081, 0x3c020800, 0x8c46004c,
336 0x00652821, 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021, 0x3c020800,
337 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021, 0x8f420074, 0x2403fffe,
338 0x00832824, 0x00a21021, 0xaf62000c, 0x3c028000, 0x34420001, 0x02a21025,
339 0xa3600081, 0xaf420020, 0x9363007e, 0x9362007a, 0x10620005, 0x00e0b021,
340 0x0e000f2a, 0x00000000, 0x00403821, 0x00e0b021, 0x8fa20010, 0x10400008,
341 0x00000000, 0x8e220018, 0xaf620018, 0x8e23001c, 0xaf63001c, 0x8e220020,
342 0x24160001, 0xaf620058, 0x13c00036, 0x32820004, 0x10400035, 0x8fa30014,
343 0x93620023, 0x30420040, 0x10400031, 0x3c020800, 0x8c430020, 0x1060001c,
344 0x8e300000, 0x0e001006, 0x00000000, 0x8f820018, 0xac500000, 0x8f830018,
345 0xac600004, 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c, 0x8f820018,
346 0xac400010, 0x8f830018, 0x24020587, 0xac620014, 0x8f850018, 0x3c026000,
347 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018,
348 0x3c024019, 0x00621825, 0x0e001044, 0xaca3001c, 0x3c029000, 0x34420001,
349 0x02a21025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
350 0x24020001, 0xaf62000c, 0x93630023, 0x3c028000, 0x34420001, 0x02a21025,
351 0x306300bf, 0xa3630023, 0xaf420020, 0x8fa30014, 0x10600012, 0x8fa3001c,
352 0x9362007c, 0x24420001, 0xa362007c, 0x9363007e, 0x9362007a, 0x1462000b,
353 0x8fa3001c, 0x9362007c, 0x3c030800, 0x8c640024, 0x0044102b, 0x14400005,
354 0x8fa3001c, 0x0e000f2a, 0x00000000, 0x02c2b025, 0x8fa3001c, 0x3062ffff,
355 0x10400003, 0x32820200, 0x0a000793, 0x24170004, 0x10400003, 0x00000000,
356 0x24170040, 0x24160001, 0x13c0005d, 0x32820002, 0x1040005c, 0x8fa20020,
357 0x9222000a, 0x30420020, 0x10400033, 0x3c100800, 0x93620023, 0x30420040,
358 0x1040002f, 0x8e020020, 0x1040001e, 0x3c029000, 0x0e001006, 0x00000000,
359 0x8f820018, 0xac550000, 0x8f840018, 0x3c02008d, 0xac820004, 0x8f830018,
360 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f840018,
361 0x240205bf, 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001,
362 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018, 0x3c024019, 0x00621825,
363 0x0e001044, 0xaca3001c, 0x3c029000, 0x34420001, 0x02a21025, 0xaf420020,
364 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93630023,
365 0x3c028000, 0x34420001, 0x02a21025, 0x306300bf, 0xa3630023, 0xaf420020,
366 0x8e020020, 0x10400023, 0x8fa20020, 0x0e001006, 0x00000000, 0x8f840018,
367 0x8e230000, 0xac830000, 0x9222000a, 0x8f830018, 0x00021600, 0xac620004,
368 0x8f840018, 0x8f620040, 0xac820008, 0x8f850018, 0x8f63004c, 0xaca3000c,
369 0x9362003f, 0x8f840018, 0x304200ff, 0xac820010, 0x8f830018, 0x3c026000,
370 0xac600014, 0x8f850018, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018,
371 0x9443466e, 0x8f850018, 0x3c02401a, 0x00621825, 0x0e001044, 0xaca3001c,
372 0x8fa20020, 0x1040000e, 0x8fa20018, 0x9222000a, 0xa3620082, 0x56e00005,
373 0x36f70008, 0x8fa30018, 0x10600004, 0x00000000, 0x36f70008, 0x0a000801,
374 0x24160001, 0x0e000de1, 0x02a02021, 0x8fa20018, 0x10400003, 0x00000000,
375 0x36f70010, 0x24160001, 0x12c00019, 0x3c029000, 0x34420001, 0x02a21025,
376 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000,
377 0x3c038000, 0x9362007d, 0x34630001, 0x3c048000, 0x02a31825, 0x02e21025,
378 0xa362007d, 0xaf430020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002,
379 0x3c031000, 0xaf5501c0, 0xa34201c4, 0xaf4301f8, 0x9363003f, 0x24020012,
380 0x14620004, 0x3c026000, 0x0e000f6e, 0x00000000, 0x3c026000, 0x8c434448,
381 0xaf630178, 0x8fbf004c, 0x8fbe0048, 0x8fb70044, 0x8fb60040, 0x8fb5003c,
382 0x8fb40038, 0x8fb30034, 0x8fb20030, 0x8fb1002c, 0x8fb00028, 0x03e00008,
383 0x27bd0050, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x8f500180, 0x97420184,
384 0x30420200, 0x14400015, 0x00000000, 0x8f430188, 0x3c02ff00, 0x00621824,
385 0x3c020200, 0x10620031, 0x0043102b, 0x14400007, 0x3c020300, 0x1060000b,
386 0x3c020100, 0x1062000d, 0x00000000, 0x0a0008b4, 0x00000000, 0x10620027,
387 0x3c020400, 0x1062003e, 0x02002021, 0x0a0008b4, 0x00000000, 0x0e000e1e,
388 0x02002021, 0x0a0008b6, 0x8fbf0014, 0x93620005, 0x30420020, 0x1440005e,
389 0x8fbf0014, 0x3c029000, 0x34420001, 0x02021025, 0xaf420020, 0x3c038000,
390 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620005, 0x3c038000,
391 0x34630001, 0x02031825, 0x34420020, 0xa3620005, 0xaf430020, 0x93620005,
392 0x30420020, 0x14400003, 0x02002021, 0x0000000d, 0x02002021, 0x0e000553,
393 0x24055854, 0x0a0008b6, 0x8fbf0014, 0x93620005, 0x30420001, 0x1040003f,
394 0x3c029000, 0x34420001, 0x02021025, 0xaf420020, 0x3c038000, 0x8f420020,
395 0x00431024, 0x1440fffd, 0x00000000, 0x93620005, 0x3c048000, 0x3c030800,
396 0x304200fe, 0xa3620005, 0x8c620020, 0x34840001, 0x02042025, 0xaf440020,
397 0x1040002d, 0x8fbf0014, 0x0a000894, 0x00000000, 0x00002821, 0x00003021,
398 0x0e000f78, 0x240706a4, 0x3c020800, 0x8c430020, 0x10600023, 0x8fbf0014,
399 0x0e001006, 0x00000000, 0x8f820018, 0xac500000, 0x93630082, 0x9362003f,
400 0x8f840018, 0x00031a00, 0x00431025, 0xac820004, 0x8f830018, 0xac600008,
401 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 0xac400014,
402 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018,
403 0x9443466e, 0x8f850018, 0x3c02400a, 0x00621825, 0x0e001044, 0xaca3001c,
404 0x0a0008b6, 0x8fbf0014, 0x0000000d, 0x8fbf0014, 0x8fb00010, 0x03e00008,
405 0x27bd0018, 0x27bdffe8, 0xafbf0010, 0x93420148, 0x2444ffff, 0x2c830005,
406 0x10600047, 0x3c020800, 0x24424598, 0x00041880, 0x00621821, 0x8c640000,
407 0x00800008, 0x00000000, 0x8f430144, 0x8f62000c, 0x14620006, 0x24020001,
408 0xaf62000c, 0x0e000909, 0x00000000, 0x0a000907, 0x8fbf0010, 0x8f62000c,
409 0x0a000900, 0x00000000, 0x97630010, 0x8f420144, 0x14430006, 0x24020001,
410 0xa7620010, 0x0e000eeb, 0x00000000, 0x0a000907, 0x8fbf0010, 0x97620010,
411 0x0a000900, 0x00000000, 0x97630012, 0x8f420144, 0x14430006, 0x24020001,
412 0xa7620012, 0x0e000f06, 0x00000000, 0x0a000907, 0x8fbf0010, 0x97620012,
413 0x0a000900, 0x00000000, 0x97630014, 0x8f420144, 0x14430006, 0x24020001,
414 0xa7620014, 0x0e000f21, 0x00000000, 0x0a000907, 0x8fbf0010, 0x97620014,
415 0x0a000900, 0x00000000, 0x97630016, 0x8f420144, 0x14430006, 0x24020001,
416 0xa7620016, 0x0e000f24, 0x00000000, 0x0a000907, 0x8fbf0010, 0x97620016,
417 0x14400006, 0x8fbf0010, 0x3c030800, 0x8c620070, 0x24420001, 0xac620070,
418 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafbf0010, 0x93620081,
419 0x3c030800, 0x8c640048, 0x0044102b, 0x14400028, 0x3c029000, 0x8f460140,
420 0x34420001, 0x3c038000, 0x00c21025, 0xaf420020, 0x8f420020, 0x00431024,
421 0x1440fffd, 0x3c048000, 0x34840001, 0x3c059000, 0x34a50001, 0x3c078000,
422 0x24020012, 0x24030080, 0x00c42025, 0x00c52825, 0xa362003f, 0xa3630082,
423 0xaf440020, 0xaf450020, 0x8f420020, 0x00471024, 0x1440fffd, 0x3c038000,
424 0x9362007d, 0x34630001, 0x3c048000, 0x00c31825, 0x34420020, 0xa362007d,
425 0xaf430020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002, 0x3c031000,
426 0x0a00096d, 0xaf4601c0, 0x93620081, 0x24420001, 0x0e000f2a, 0xa3620081,
427 0x9763006a, 0x00032880, 0x14a00002, 0x00403821, 0x24050001, 0x97630068,
428 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b,
429 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001,
430 0x00c02021, 0x8f420074, 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c,
431 0x10e0001a, 0x3c029000, 0x8f440140, 0x34420001, 0x3c038000, 0x00821025,
432 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000,
433 0x9362007d, 0x34630001, 0x3c058000, 0x00831825, 0x34420004, 0xa362007d,
434 0xaf430020, 0x8f4201f8, 0x00451024, 0x1440fffd, 0x24020002, 0x3c031000,
435 0xaf4401c0, 0xa34201c4, 0xaf4301f8, 0x8fbf0010, 0x03e00008, 0x27bd0018,
436 0x27bdffd8, 0xafb3001c, 0x27530100, 0xafbf0024, 0xafb40020, 0xafb20018,
437 0xafb10014, 0xafb00010, 0x96620008, 0x3c140800, 0x8f520100, 0x30420001,
438 0x104000cf, 0x00000000, 0x8e700018, 0x8f630054, 0x2602ffff, 0x00431023,
439 0x18400006, 0x00000000, 0x0000000d, 0x00000000, 0x24000128, 0x0a0009b6,
440 0x00008821, 0x8f62004c, 0x02021023, 0x18400028, 0x00008821, 0x93650120,
441 0x93640121, 0x3c030800, 0x8c62008c, 0x308400ff, 0x24420001, 0x30a500ff,
442 0x00803821, 0x1485000b, 0xac62008c, 0x3c040800, 0x8c830090, 0x24630001,
443 0xac830090, 0x93620122, 0x30420001, 0x00021023, 0x30420005, 0x0a0009b6,
444 0x34510004, 0x27660100, 0x00041080, 0x00c21021, 0x8c430000, 0x02031823,
445 0x04600004, 0x24820001, 0x30440007, 0x1485fff9, 0x00041080, 0x10870007,
446 0x3c030800, 0xa3640121, 0x8c620094, 0x24110005, 0x24420001, 0x0a0009b6,
447 0xac620094, 0x24110004, 0x32220001, 0x1040001e, 0x8e820020, 0x1040001d,
448 0x32220004, 0x0e001006, 0x00000000, 0x8f820018, 0xac520000, 0x8f840018,
449 0x24020001, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c,
450 0x8f830018, 0xac600010, 0x8f820018, 0xac500014, 0x8f850018, 0x3c026000,
451 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018,
452 0x3c024010, 0x00621825, 0x0e001044, 0xaca3001c, 0x32220004, 0x10400076,
453 0x00003821, 0x3c029000, 0x34420001, 0x3c038000, 0x02421025, 0xa360007c,
454 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620023,
455 0x30420080, 0x10400011, 0x00000000, 0x8f65005c, 0x8f63004c, 0x9764003c,
456 0x8f620064, 0x00a32823, 0x00852821, 0x00a2102b, 0x54400006, 0x3c023fff,
457 0x93620023, 0x3042007f, 0xa3620023, 0xaf700064, 0x3c023fff, 0x0a000a03,
458 0x3442ffff, 0x8f62005c, 0x02021023, 0x04400011, 0x00000000, 0x8f65005c,
459 0x8f630064, 0x9764003c, 0x3c023fff, 0x3442ffff, 0xaf700064, 0x00a32823,
460 0x00852821, 0x0045102b, 0x10400004, 0x02051021, 0x3c053fff, 0x34a5ffff,
461 0x02051021, 0xaf62005c, 0x24070001, 0xaf70004c, 0x8f620054, 0x16020005,
462 0x00000000, 0x93620023, 0x30420040, 0x10400017, 0x24020001, 0x9762006a,
463 0x00022880, 0x50a00001, 0x24050001, 0x97630068, 0x93640081, 0x3c020800,
464 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021,
465 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021, 0x8f420074,
466 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c, 0x3c028000, 0x34420001,
467 0x02421025, 0xa3600081, 0xaf420020, 0x9363007e, 0x9362007a, 0x10620004,
468 0x00000000, 0x0e000f2a, 0x00000000, 0x00403821, 0x10e00017, 0x3c029000,
469 0x34420001, 0x02421025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024,
470 0x1440fffd, 0x3c028000, 0x9363007d, 0x34420001, 0x3c048000, 0x02421025,
471 0xa363007d, 0xaf420020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002,
472 0x3c031000, 0xaf5201c0, 0xa34201c4, 0xaf4301f8, 0x9342010b, 0x8e830020,
473 0x27500100, 0x38420006, 0x10600029, 0x2c510001, 0x0e001006, 0x00000000,
474 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018, 0x96020008, 0xac820004,
475 0x8f830018, 0x8e020014, 0xac620008, 0x8f850018, 0x3c026000, 0x8c434448,
476 0xaca3000c, 0x8f840018, 0x96020012, 0xac820010, 0x8f850018, 0x8e030020,
477 0xaca30014, 0x9602000c, 0x9603000e, 0x8f840018, 0x00021400, 0x00431025,
478 0xac820018, 0x12200005, 0x3c020800, 0x9443466e, 0x8f840018, 0x0a000a78,
479 0x3c024013, 0x9443466e, 0x8f840018, 0x3c024014, 0x00621825, 0xac83001c,
480 0x0e001044, 0x24040001, 0x8e630014, 0x8f620040, 0x14430003, 0x00431023,
481 0x0a000a83, 0x00001021, 0x28420001, 0x10400034, 0x00000000, 0x8f620040,
482 0xaf630040, 0x9362003e, 0x30420001, 0x1440000b, 0x3c029000, 0x93620022,
483 0x24420001, 0xa3620022, 0x93630022, 0x3c020800, 0x8c440098, 0x0064182b,
484 0x1460001e, 0x3c020800, 0x3c029000, 0x34420001, 0x02421025, 0xaf420020,
485 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000,
486 0x9362007d, 0x34630001, 0x3c048000, 0x02431825, 0x34420001, 0xa362007d,
487 0xaf430020, 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002, 0x3c031000,
488 0xaf5201c0, 0xa34201c4, 0x24020001, 0xaf4301f8, 0xa7620012, 0x0a000ab6,
489 0xa3600022, 0x9743007a, 0x9444002a, 0x00641821, 0x3063fffe, 0xa7630012,
490 0x0e000b68, 0x00000000, 0x97420108, 0x8fbf0024, 0x8fb40020, 0x8fb3001c,
491 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x00021042, 0x30420001, 0x03e00008,
492 0x27bd0028, 0x27bdffe0, 0xafb20018, 0x3c120800, 0x8e420020, 0xafb00010,
493 0x27500100, 0xafbf001c, 0x10400046, 0xafb10014, 0x0e001006, 0x00000000,
494 0x8f840018, 0x8e020000, 0xac820000, 0x936300b1, 0x936200c5, 0x8f850018,
495 0x00031e00, 0x00021400, 0x34420100, 0x00621825, 0xaca30004, 0x8f840018,
496 0x8e02001c, 0xac820008, 0x8f830018, 0x8f620048, 0xac62000c, 0x8f840018,
497 0x96020012, 0xac820010, 0x8f830018, 0x8f620040, 0x24040001, 0xac620014,
498 0x8f850018, 0x3c026000, 0x8c434448, 0x3c020800, 0x24514660, 0xaca30018,
499 0x9623000e, 0x8f850018, 0x3c024016, 0x00621825, 0x0e001044, 0xaca3001c,
500 0x96030008, 0x30630010, 0x1060001c, 0x8e420020, 0x1040001a, 0x8e100000,
501 0x0e001006, 0x00000000, 0x8f820018, 0xac500000, 0x8f830018, 0xac600004,
502 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010,
503 0x8f830018, 0xac600014, 0x8f850018, 0x3c036000, 0x8c634448, 0x24040001,
504 0xaca30018, 0x9622000e, 0x8f850018, 0x3c034015, 0x00431025, 0x0e001044,
505 0xaca2001c, 0x00001021, 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
506 0x03e00008, 0x27bd0020, 0x27bdffe0, 0xafb20018, 0x3c120800, 0x8e420020,
507 0xafb00010, 0x27500100, 0xafbf001c, 0x10400041, 0xafb10014, 0x0e001006,
508 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018, 0x24020100,
509 0xac820004, 0x8f830018, 0x8e02001c, 0xac620008, 0x8f840018, 0x8e020018,
510 0xac82000c, 0x8f830018, 0x96020012, 0xac620010, 0x8f840018, 0x96020008,
511 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800,
512 0x24514660, 0xaca30018, 0x9623000e, 0x8f850018, 0x3c024017, 0x00621825,
513 0x0e001044, 0xaca3001c, 0x96030008, 0x30630010, 0x1060001c, 0x8e420020,
514 0x1040001a, 0x8e100000, 0x0e001006, 0x00000000, 0x8f820018, 0xac500000,
515 0x8f830018, 0xac600004, 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c,
516 0x8f820018, 0xac400010, 0x8f830018, 0xac600014, 0x8f850018, 0x3c036000,
517 0x8c634448, 0x24040001, 0xaca30018, 0x9622000e, 0x8f850018, 0x3c034015,
518 0x00431025, 0x0e001044, 0xaca2001c, 0x00001021, 0x8fbf001c, 0x8fb20018,
519 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0xafbf0010,
520 0x936200c4, 0x30420002, 0x10400019, 0x00000000, 0x936200c5, 0x936300b1,
521 0x00431023, 0x304400ff, 0x30830080, 0x10600004, 0x00000000, 0x0000000d,
522 0x00000000, 0x24000a6a, 0x93620004, 0x00441023, 0x304400ff, 0x30830080,
523 0x10600004, 0x2482ffff, 0x8f650024, 0x0a000b82, 0x00000000, 0x00022b00,
524 0x8f620024, 0x0045102b, 0x10400002, 0x00000000, 0x8f650024, 0x8f620048,
525 0x8f630040, 0x00431823, 0x0065202b, 0x10800004, 0x00000000, 0x8f620040,
526 0x00451021, 0xaf620048, 0x9762003c, 0x0062102b, 0x10400041, 0x8fbf0010,
527 0x10a0003f, 0x3c029000, 0x34420001, 0x3c040800, 0x8c830080, 0x8f450100,
528 0x3c068000, 0x24630001, 0x00a21025, 0xac830080, 0xaf420020, 0x8f420020,
529 0x00461024, 0x1440fffd, 0x3c038000, 0x9362007d, 0x34630001, 0x3c048000,
530 0x00a31825, 0x34420004, 0xa362007d, 0xaf430020, 0x8f4201f8, 0x00441024,
531 0x1440fffd, 0x24020002, 0x3c030800, 0xaf4501c0, 0xa34201c4, 0x8c640020,
532 0x3c021000, 0xaf4201f8, 0x1080001f, 0x8fbf0010, 0x0e001006, 0x00000000,
533 0x8f830018, 0x8f420100, 0xac620000, 0x8f840018, 0x8f620040, 0xac820004,
534 0x8f850018, 0x8f620048, 0xaca20008, 0x8f830018, 0xac60000c, 0x8f820018,
535 0xac400010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018, 0x8c434448,
536 0x3c020800, 0xac830018, 0x9443466e, 0x8f840018, 0x3c0240c2, 0x00621825,
537 0xac83001c, 0x0e001044, 0x24040001, 0x8fbf0010, 0x03e00008, 0x27bd0018,
538 0x3c020800, 0x24423958, 0xaf82000c, 0x03e00008, 0x00000000, 0x27bdffe8,
539 0xafb00010, 0x27500100, 0xafbf0014, 0x8e02001c, 0x14400003, 0x3c020800,
540 0x0000000d, 0x3c020800, 0x8c430020, 0x10600026, 0x00001021, 0x0e001006,
541 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018, 0x8e02001c,
542 0xac820004, 0x8f830018, 0xac600008, 0x8f840018, 0x8e020018, 0xac82000c,
543 0x8f850018, 0x96020012, 0xaca20010, 0x8f830018, 0x3c106000, 0xac600014,
544 0x8f840018, 0x8e024448, 0x3c030800, 0xac820018, 0x9462466e, 0x8f840018,
545 0x3c034012, 0x00431025, 0xac82001c, 0x0e001044, 0x24040001, 0x8e036800,
546 0x00001021, 0x3c040001, 0x00641825, 0xae036800, 0x0a000c0d, 0x8fbf0014,
547 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c020800, 0x97430078,
548 0x9444002e, 0x00001021, 0x00641821, 0x3063fffe, 0x03e00008, 0xa7630010,
549 0x27450100, 0x8f640048, 0x8ca30018, 0x00641023, 0x18400021, 0x00000000,
550 0xaf630048, 0x8f620040, 0x9763003c, 0x00821023, 0x0043102a, 0x1040001a,
551 0x3c029000, 0x8ca40000, 0x34420001, 0x3c038000, 0x00821025, 0xaf420020,
552 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000, 0x9362007d,
553 0x34630001, 0x3c058000, 0x00831825, 0x34420004, 0xa362007d, 0xaf430020,
554 0x8f4201f8, 0x00451024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4401c0,
555 0xa34201c4, 0xaf4301f8, 0x03e00008, 0x00001021, 0x8f420100, 0x34420001,
556 0xaf4200a4, 0x03e00008, 0x00001021, 0x27bdffe0, 0xafbf0018, 0xafb10014,
557 0xafb00010, 0x9362007e, 0x30d000ff, 0x16020029, 0x00808821, 0x93620080,
558 0x16020026, 0x00000000, 0x9362007f, 0x16020023, 0x00000000, 0x9362007a,
559 0x16020004, 0x00000000, 0x0000000d, 0x00000000, 0x24000771, 0x0e000f49,
560 0x00000000, 0x3c039000, 0x34630001, 0x3c048000, 0x02231825, 0xa370007a,
561 0xaf430020, 0x8f420020, 0x00441024, 0x1440fffd, 0x3c028000, 0x9363007d,
562 0x34420001, 0x3c048000, 0x02221025, 0xa363007d, 0xaf420020, 0x8f4201f8,
563 0x00441024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf5101c0, 0xa34201c4,
564 0xaf4301f8, 0x0a000c79, 0x8fbf0018, 0x0000000d, 0x00000000, 0x24000781,
565 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3c020800,
566 0x8c430020, 0x27bdffe8, 0xafb00010, 0x27500100, 0x10600024, 0xafbf0014,
567 0x0e001006, 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018,
568 0x8e020004, 0xac820004, 0x8f830018, 0x8e020018, 0xac620008, 0x8f840018,
569 0x8e03001c, 0xac83000c, 0x9602000c, 0x9203000a, 0x8f840018, 0x00021400,
570 0x00431025, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018,
571 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x9464466e, 0x8f850018,
572 0x00021400, 0x00441025, 0x24040001, 0x0e001044, 0xaca2001c, 0x8fbf0014,
573 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe8,
574 0xafb00010, 0x27500100, 0x10600020, 0xafbf0014, 0x0e001006, 0x00000000,
575 0x8f820018, 0xac400000, 0x8f830018, 0xac600004, 0x8f820018, 0xac400008,
576 0x8f830018, 0xac60000c, 0x9602000c, 0x9603000e, 0x8f840018, 0x00021400,
577 0x00431025, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018,
578 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x9464466e, 0x8f850018,
579 0x00021400, 0x00441025, 0x24040001, 0x0e001044, 0xaca2001c, 0x8fbf0014,
580 0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafb00010, 0x27500100,
581 0xafbf0014, 0x9602000c, 0x10400024, 0x00802821, 0x3c020800, 0x8c430020,
582 0x1060003a, 0x8fbf0014, 0x0e001006, 0x00000000, 0x8f840018, 0x8e030000,
583 0xac830000, 0x9602000c, 0x8f840018, 0x00021400, 0xac820004, 0x8f830018,
584 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018,
585 0xac400014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800,
586 0xaca30018, 0x9443466e, 0x8f850018, 0x3c02400b, 0x00621825, 0x0e001044,
587 0xaca3001c, 0x0a000d19, 0x8fbf0014, 0x93620005, 0x30420010, 0x14400015,
588 0x3c029000, 0x34420001, 0x00a21025, 0xaf420020, 0x3c038000, 0x8f420020,
589 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000, 0x93620005, 0x34630001,
590 0x00a02021, 0x00a31825, 0x24055852, 0x34420010, 0xa3620005, 0x0e000553,
591 0xaf430020, 0x0a000d19, 0x8fbf0014, 0x0000000d, 0x8fbf0014, 0x8fb00010,
592 0x03e00008, 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe8, 0xafb00010,
593 0x27500100, 0x10600022, 0xafbf0014, 0x0e001006, 0x00000000, 0x8f840018,
594 0x8e020004, 0xac820000, 0x9603000c, 0x9762002c, 0x8f840018, 0x00031c00,
595 0x00431025, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c,
596 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 0x8f850018, 0x3c026000,
597 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018,
598 0x3c02400e, 0x00621825, 0x0e001044, 0xaca3001c, 0x0e000d48, 0x8e040000,
599 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c038000, 0x8f420278,
600 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf440240, 0xa3420244,
601 0x03e00008, 0xaf430278, 0x3c020800, 0x8c430020, 0x27bdffe0, 0xafb10014,
602 0x00808821, 0xafb20018, 0x00c09021, 0xafb00010, 0x30b0ffff, 0x1060001c,
603 0xafbf001c, 0x0e001006, 0x00000000, 0x8f820018, 0xac510000, 0x8f840018,
604 0x00101400, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c,
605 0x8f830018, 0xac600010, 0x8f820018, 0xac520014, 0x8f840018, 0x3c026000,
606 0x8c434448, 0x3c020800, 0xac830018, 0x9443466e, 0x8f840018, 0x3c024019,
607 0x00621825, 0xac83001c, 0x0e001044, 0x24040001, 0x8fbf001c, 0x8fb20018,
608 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0x27450100,
609 0xafbf0010, 0x94a3000c, 0x240200c1, 0x14620029, 0x00803021, 0x3c029000,
610 0x34420001, 0x00c21025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024,
611 0x1440fffd, 0x3c028000, 0x34420001, 0x3c049000, 0x34840001, 0x3c058000,
612 0x24030012, 0x00c21025, 0x00c42025, 0xa363003f, 0xaf420020, 0xaf440020,
613 0x8f420020, 0x00451024, 0x1440fffd, 0x3c038000, 0x9362007d, 0x34630001,
614 0x3c048000, 0x00c31825, 0x34420020, 0xa362007d, 0xaf430020, 0x8f4201f8,
615 0x00441024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4601c0, 0xa34201c4,
616 0xaf4301f8, 0x0a000db3, 0x8fbf0010, 0x00c02021, 0x94a5000c, 0x24060001,
617 0x0e000f78, 0x240706d8, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x3c020800,
618 0x8c430020, 0x27bdffe0, 0xafb00010, 0x00808021, 0xafb20018, 0x00a09021,
619 0xafb10014, 0x30d100ff, 0x1060001c, 0xafbf001c, 0x0e001006, 0x00000000,
620 0x8f820018, 0xac500000, 0x8f840018, 0x24020001, 0xac820004, 0x8f830018,
621 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018,
622 0xac520014, 0x8f840018, 0x3c026000, 0x8c434448, 0x3c020800, 0xac830018,
623 0x9443466e, 0x8f840018, 0x3c024010, 0x00621825, 0xac83001c, 0x0e001044,
624 0x02202021, 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008,
625 0x27bd0020, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x93620005, 0x30420001,
626 0x10400033, 0x00808021, 0x3c029000, 0x34420001, 0x02021025, 0xaf420020,
627 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620005,
628 0x3c048000, 0x3c030800, 0x304200fe, 0xa3620005, 0x8c620020, 0x34840001,
629 0x02042025, 0xaf440020, 0x10400020, 0x8fbf0014, 0x0e001006, 0x00000000,
630 0x8f820018, 0xac500000, 0x93630082, 0x9362003f, 0x8f840018, 0x00031a00,
631 0x00431025, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c,
632 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 0x8f840018, 0x3c026000,
633 0x8c434448, 0x3c020800, 0xac830018, 0x9443466e, 0x8f840018, 0x3c02400a,
634 0x00621825, 0xac83001c, 0x0e001044, 0x24040001, 0x8fbf0014, 0x8fb00010,
635 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafbf0010, 0x8f420188, 0x00803021,
636 0x9364003f, 0x24030012, 0x00021402, 0x1483001c, 0x304500ff, 0x3c029000,
637 0x34420001, 0x3c038000, 0x00c21025, 0xa3650080, 0xa365007a, 0xaf420020,
638 0x8f420020, 0x00431024, 0x1440fffd, 0x3c028000, 0x9363007d, 0x34420001,
639 0x3c048000, 0x00c21025, 0xa363007d, 0xaf420020, 0x8f4201f8, 0x00441024,
640 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4601c0, 0xa34201c4, 0xaf4301f8,
641 0x0a000e54, 0x8fbf0010, 0x9362007e, 0x1445000e, 0x00000000, 0x93620080,
642 0x1045000b, 0x00000000, 0xa3650080, 0x8f820000, 0x93660080, 0x8f440180,
643 0x8f65004c, 0x8c430000, 0x0060f809, 0x00000000, 0x0a000e54, 0x8fbf0010,
644 0xa3650080, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x3c020800, 0x8c430020,
645 0x27bdffe0, 0xafb10014, 0x00808821, 0xafb20018, 0x00a09021, 0xafb00010,
646 0x30d000ff, 0x1060002f, 0xafbf001c, 0x0e001006, 0x00000000, 0x8f820018,
647 0xac510000, 0x8f830018, 0xac700004, 0x8f820018, 0xac520008, 0x8f830018,
648 0xac60000c, 0x8f820018, 0xac400010, 0x9763006a, 0x00032880, 0x50a00001,
649 0x24050001, 0x97630068, 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821,
650 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050,
651 0x00c4182b, 0x54600001, 0x00c02021, 0x8f830018, 0x2402fffe, 0x00822824,
652 0x3c026000, 0xac650014, 0x8f840018, 0x8c434448, 0x3c020800, 0xac830018,
653 0x9443466e, 0x8f840018, 0x3c024011, 0x00621825, 0xac83001c, 0x0e001044,
654 0x24040001, 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008,
655 0x27bd0020, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x8f440100, 0x27500100,
656 0x8f650050, 0x0e000c45, 0x9206001b, 0x3c020800, 0x8c430020, 0x1060001d,
657 0x8e100018, 0x0e001006, 0x00000000, 0x8f840018, 0x8f420100, 0xac820000,
658 0x8f830018, 0xac700004, 0x8f840018, 0x8f620050, 0xac820008, 0x8f830018,
659 0xac60000c, 0x8f820018, 0xac400010, 0x8f830018, 0x3c026000, 0xac600014,
660 0x8f850018, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x9443466e,
661 0x8f850018, 0x3c02401c, 0x00621825, 0x0e001044, 0xaca3001c, 0x8fbf0014,
662 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c029000, 0x8f460140, 0x34420001,
663 0x3c038000, 0x00c21025, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd,
664 0x3c048000, 0x34840001, 0x3c059000, 0x34a50001, 0x3c078000, 0x24020012,
665 0x24030080, 0x00c42025, 0x00c52825, 0xa362003f, 0xa3630082, 0xaf440020,
666 0xaf450020, 0x8f420020, 0x00471024, 0x1440fffd, 0x3c038000, 0x9362007d,
667 0x34630001, 0x3c048000, 0x00c31825, 0x34420020, 0xa362007d, 0xaf430020,
668 0x8f4201f8, 0x00441024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4601c0,
669 0xa34201c4, 0x03e00008, 0xaf4301f8, 0x8f430238, 0x3c020800, 0x04610013,
670 0x8c44009c, 0x2406fffe, 0x3c050800, 0x3c038000, 0x2484ffff, 0x14800009,
671 0x00000000, 0x97420078, 0x8ca3007c, 0x24420001, 0x00461024, 0x24630001,
672 0xa7620010, 0x03e00008, 0xaca3007c, 0x8f420238, 0x00431024, 0x1440fff3,
673 0x2484ffff, 0x8f420140, 0x3c031000, 0xaf420200, 0x03e00008, 0xaf430238,
674 0x3c029000, 0x8f440140, 0x34420001, 0x3c038000, 0x00821025, 0xaf420020,
675 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000, 0x9362007d,
676 0x34630001, 0x3c058000, 0x00831825, 0x34420001, 0xa362007d, 0xaf430020,
677 0x8f4201f8, 0x00451024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4401c0,
678 0xa34201c4, 0x03e00008, 0xaf4301f8, 0x0000000d, 0x03e00008, 0x00000000,
679 0x0000000d, 0x03e00008, 0x00000000, 0x24020001, 0x03e00008, 0xa7620010,
680 0x9362003f, 0x304400ff, 0x3883000e, 0x2c630001, 0x38820010, 0x2c420001,
681 0x00621825, 0x14600003, 0x24020012, 0x14820003, 0x00000000, 0x03e00008,
682 0x00001021, 0x9363007e, 0x9362007a, 0x14620006, 0x00000000, 0x9363007e,
683 0x24020001, 0x24630001, 0x03e00008, 0xa363007e, 0x9363007e, 0x93620080,
684 0x14620004, 0x24020001, 0xa362000b, 0x03e00008, 0x24020001, 0x03e00008,
685 0x00001021, 0x9362000b, 0x10400021, 0x00001021, 0xa360000b, 0x9362003f,
686 0x304400ff, 0x3883000e, 0x2c630001, 0x38820010, 0x2c420001, 0x00621825,
687 0x14600015, 0x00001821, 0x24020012, 0x10820012, 0x00000000, 0x9363007e,
688 0x9362007a, 0x14620007, 0x00000000, 0x9362007e, 0x24030001, 0x24420001,
689 0xa362007e, 0x03e00008, 0x00601021, 0x9363007e, 0x93620080, 0x14620004,
690 0x00001821, 0x24020001, 0xa362000b, 0x24030001, 0x03e00008, 0x00601021,
691 0x03e00008, 0x00000000, 0x24040001, 0xaf64000c, 0x8f6300dc, 0x8f6200cc,
692 0x50620001, 0xa7640010, 0xa7640012, 0xa7640014, 0x03e00008, 0xa7640016,
693 0x27bdffd8, 0xafb00010, 0x00808021, 0xafb3001c, 0x00c09821, 0xafbf0020,
694 0xafb20018, 0xafb10014, 0x93620023, 0x00e09021, 0x30420040, 0x10400020,
695 0x30b1ffff, 0x3c020800, 0x8c430020, 0x1060001c, 0x00000000, 0x0e001006,
696 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x3c02008d, 0xac820004,
697 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
698 0x8f820018, 0xac520014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001,
699 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018, 0x3c024019, 0x00621825,
700 0x0e001044, 0xaca3001c, 0x93620023, 0x30420020, 0x14400003, 0x3c020800,
701 0x52600020, 0x3c029000, 0x8c430020, 0x1060001d, 0x3c029000, 0x0e001006,
702 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x00111400, 0xac820004,
703 0x8f830018, 0xac720008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
704 0x8f820018, 0xac400014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001,
705 0x3c020800, 0xaca30018, 0x9443466e, 0x8f850018, 0x3c02401b, 0x00621825,
706 0x0e001044, 0xaca3001c, 0x3c029000, 0x34420001, 0x02021025, 0xaf420020,
707 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93630023,
708 0x3c028000, 0x34420001, 0x02021025, 0x8fbf0020, 0x8fb3001c, 0x8fb20018,
709 0x8fb10014, 0x8fb00010, 0x3063009f, 0xa3630023, 0xaf420020, 0x03e00008,
710 0x27bd0028, 0x3c020800, 0x8c430020, 0x27bdffe8, 0xafb00010, 0x27500100,
711 0x1060001d, 0xafbf0014, 0x0e001006, 0x00000000, 0x8f830018, 0x8e020004,
712 0xac620000, 0x8f840018, 0x8e020018, 0xac820004, 0x8f850018, 0x8e020000,
713 0xaca20008, 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010, 0x8f830018,
714 0xac600014, 0x8f820018, 0xac400018, 0x96030008, 0x3c020800, 0x9444466e,
715 0x8f850018, 0x00031c00, 0x00641825, 0x24040001, 0x0e001044, 0xaca3001c,
716 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c060800, 0x24c54660,
717 0x3c02000a, 0x03421821, 0x94640006, 0x94a2000a, 0x00441023, 0x00021400,
718 0x00021c03, 0x04610006, 0xa4a40006, 0x0000000d, 0x00000000, 0x2400005a,
719 0x0a00101b, 0x24020001, 0x8f820014, 0x0062102b, 0x14400002, 0x00001021,
720 0x24020001, 0x304200ff, 0x1040001c, 0x274a0400, 0x3c07000a, 0x3c020800,
721 0x24454660, 0x94a9000a, 0x8f880014, 0x03471021, 0x94430006, 0x00402021,
722 0xa4a30006, 0x94820006, 0xa4a20006, 0x01221023, 0x00021400, 0x00021403,
723 0x04410006, 0x0048102b, 0x0000000d, 0x00000000, 0x2400005a, 0x0a001036,
724 0x24020001, 0x14400002, 0x00001021, 0x24020001, 0x304200ff, 0x1440ffec,
725 0x03471021, 0x24c44660, 0x8c820010, 0xaf420038, 0x8c830014, 0x3c020005,
726 0xaf43003c, 0xaf420030, 0xaf800010, 0xaf8a0018, 0x03e00008, 0x00000000,
727 0x27bdffe0, 0x8f820010, 0x8f850018, 0x3c070800, 0x24e84660, 0xafbf001c,
728 0xafb20018, 0xafb10014, 0xafb00010, 0x9503000a, 0x8d060014, 0x00009021,
729 0x309000ff, 0x00e08821, 0x24420001, 0x24a50020, 0x24630001, 0xaf820010,
730 0xaf850018, 0xa503000a, 0x24c30020, 0x3c028000, 0x04c10007, 0xad030014,
731 0x00621024, 0x14400005, 0x26224660, 0x8d020010, 0x24420001, 0xad020010,
732 0x26224660, 0x9444000a, 0x94450018, 0x0010102b, 0x00a41826, 0x2c630001,
733 0x00621825, 0x1060001c, 0x3c030006, 0x8f820010, 0x24120001, 0x00021140,
734 0x00431025, 0xaf420030, 0x00000000, 0x00000000, 0x00000000, 0x27450400,
735 0x8f420000, 0x30420010, 0x1040fffd, 0x26224660, 0x9444000a, 0x94430018,
736 0xaf800010, 0xaf850018, 0x14830012, 0x26274660, 0x0e0010d2, 0x00000000,
737 0x1600000e, 0x26274660, 0x0e001006, 0x00000000, 0x0a00108f, 0x26274660,
738 0x00041c00, 0x00031c03, 0x00051400, 0x00021403, 0x00621823, 0x18600002,
739 0x3c026000, 0xac400808, 0x26274660, 0x94e2000e, 0x94e3000c, 0x24420001,
740 0xa4e2000e, 0x3042ffff, 0x50430001, 0xa4e0000e, 0x12000005, 0x3c02000a,
741 0x94e2000a, 0xa74200a2, 0x0a0010cc, 0x02401021, 0x03421821, 0x94640006,
742 0x94e2000a, 0x00441023, 0x00021400, 0x00021c03, 0x04610006, 0xa4e40006,
743 0x0000000d, 0x00000000, 0x2400005a, 0x0a0010ae, 0x24020001, 0x8f820014,
744 0x0062102b, 0x14400002, 0x00001021, 0x24020001, 0x304200ff, 0x1040001b,
745 0x3c020800, 0x3c06000a, 0x24454660, 0x94a8000a, 0x8f870014, 0x03461021,
746 0x94430006, 0x00402021, 0xa4a30006, 0x94820006, 0xa4a20006, 0x01021023,
747 0x00021400, 0x00021403, 0x04410006, 0x0047102b, 0x0000000d, 0x00000000,
748 0x2400005a, 0x0a0010c8, 0x24020001, 0x14400002, 0x00001021, 0x24020001,
749 0x304200ff, 0x1440ffec, 0x03461021, 0x02401021, 0x8fbf001c, 0x8fb20018,
750 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3c020800, 0x24454660,
751 0x94a3001a, 0x8ca40024, 0x00403021, 0x000318c0, 0x00832021, 0xaf44003c,
752 0x8ca20020, 0xaf420038, 0x3c020050, 0x34420008, 0xaf420030, 0x00000000,
753 0x00000000, 0x00000000, 0x8f420000, 0x30420020, 0x1040fffd, 0x00000000,
754 0x8f430400, 0x24c64660, 0xacc30010, 0x8f420404, 0x3c030020, 0xacc20014,
755 0xaf430030, 0x94c40018, 0x94c3001c, 0x94c2001a, 0x94c5001e, 0x00832021,
756 0x24420001, 0xa4c2001a, 0x3042ffff, 0x14450002, 0xa4c40018, 0xa4c0001a,
757 0x03e00008, 0x00000000, 0x8f820010, 0x3c030006, 0x00021140, 0x00431025,
758 0xaf420030, 0x00000000, 0x00000000, 0x00000000, 0x27430400, 0x8f420000,
759 0x30420010, 0x1040fffd, 0x00000000, 0xaf800010, 0xaf830018, 0x03e00008,
760 0x00000000, 0x27bdffe8, 0xafb00010, 0x3c100800, 0x26104660, 0x3c05000a,
761 0x02002021, 0x03452821, 0xafbf0014, 0x0e001128, 0x2406000a, 0x96020002,
762 0x9603001e, 0x3042000f, 0x24420003, 0x00431804, 0x24027fff, 0x0043102b,
763 0xaf830014, 0x10400004, 0x00000000, 0x0000000d, 0x00000000, 0x24000043,
764 0x0e0010d2, 0x00000000, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018,
765 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000,
766 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000, 0x0a001137, 0x00a01021,
767 0xac860000, 0x24840004, 0x00a01021, 0x1440fffc, 0x24a5ffff, 0x03e00008,
768 0x00000000, 0x3c036000, 0x8c642b7c, 0x3c036010, 0x8c6553fc, 0x00041582,
769 0x00042302, 0x308403ff, 0x00052d82, 0x00441026, 0x0002102b, 0x0005282b,
770 0x00451025, 0x1440000d, 0x3c020050, 0x34420004, 0xaf400038, 0xaf40003c,
771 0xaf420030, 0x00000000, 0x00000000, 0x8f420000, 0x30420020, 0x1040fffd,
772 0x3c020020, 0xaf420030, 0x0000000d, 0x03e00008, 0x00000000, 0x3c020050,
773 0x34420004, 0xaf440038, 0xaf45003c, 0xaf420030, 0x00000000, 0x00000000,
774 0x8f420000, 0x30420020, 0x1040fffd, 0x3c020020, 0xaf420030, 0x03e00008,
775 0x00000000, 0x00000000 };
776
777static u32 bnx2_COM_b06FwData[(0x0/4) + 1] = { 0x00000000 };
778static u32 bnx2_COM_b06FwRodata[(0x18/4) + 1] = {
779 0x08002318, 0x08002348, 0x08002378, 0x080023a8, 0x080023d8, 0x00000000,
780 0x00000000 };
781
782static u32 bnx2_COM_b06FwBss[(0x88/4) + 1] = { 0x00000000 };
783static u32 bnx2_COM_b06FwSbss[(0x1c/4) + 1] = { 0x00000000 };
784
785static int bnx2_RXP_b06FwReleaseMajor = 0x0;
786static int bnx2_RXP_b06FwReleaseMinor = 0x0;
787static int bnx2_RXP_b06FwReleaseFix = 0x0;
788static u32 bnx2_RXP_b06FwStartAddr = 0x08000060;
789static u32 bnx2_RXP_b06FwTextAddr = 0x08000000;
790static int bnx2_RXP_b06FwTextLen = 0x20b8;
791static u32 bnx2_RXP_b06FwDataAddr = 0x080020e0;
792static int bnx2_RXP_b06FwDataLen = 0x0;
793static u32 bnx2_RXP_b06FwRodataAddr = 0x00000000;
794static int bnx2_RXP_b06FwRodataLen = 0x0;
795static u32 bnx2_RXP_b06FwBssAddr = 0x08002100;
796static int bnx2_RXP_b06FwBssLen = 0x239c;
797static u32 bnx2_RXP_b06FwSbssAddr = 0x080020e0;
798static int bnx2_RXP_b06FwSbssLen = 0x14;
799
800static u32 bnx2_RXP_b06FwText[(0x20b8/4) + 1] = {
801 0x0a000018, 0x00000000, 0x00000000, 0x0000000d, 0x72787020, 0x302e362e,
802 0x39000000, 0x00060903, 0x00000000, 0x0000000d, 0x00000000, 0x00000000,
803 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
804 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
805 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800,
806 0x244220e0, 0x3c030800, 0x2463449c, 0xac400000, 0x0043202b, 0x1480fffd,
807 0x24420004, 0x3c1d0800, 0x37bd3ffc, 0x03a0f021, 0x3c100800, 0x26100060,
808 0x3c1c0800, 0x279c20e0, 0x0e000329, 0x00000000, 0x0000000d, 0x8f870008,
809 0x2ce20080, 0x10400018, 0x3c030800, 0x24633490, 0x8f460100, 0x00072140,
810 0x00831021, 0xac460000, 0x8f450104, 0x00641021, 0xac450004, 0x8f460108,
811 0xac460008, 0x8f45010c, 0xac45000c, 0x8f460114, 0xac460010, 0x8f450118,
812 0xac450014, 0x8f460124, 0xac460018, 0x8f450128, 0x00641821, 0x24e20001,
813 0xaf820008, 0xac65001c, 0x03e00008, 0x00000000, 0x00804021, 0x8f830000,
814 0x24070001, 0x3c020001, 0x00621024, 0x10400037, 0x00603021, 0x9742010e,
815 0x3c038000, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003,
816 0xa342018b, 0x8f840004, 0x24020080, 0x24030002, 0xaf420180, 0xa743018c,
817 0x10800005, 0xa745018e, 0x9743011c, 0x9742011e, 0x0a000069, 0x00021400,
818 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c,
819 0x24020003, 0x30838000, 0x1060000d, 0xa7420188, 0x93420116, 0x304200fc,
820 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600005, 0x00000000,
821 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c,
822 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6,
823 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x30c21000,
824 0x1040000f, 0x00000000, 0x9742010c, 0x3042fc00, 0x5440000b, 0x24070005,
825 0x3c021000, 0x00c21024, 0x10400007, 0x3c030dff, 0x3463ffff, 0x3c020e00,
826 0x00c21024, 0x0062182b, 0x54600001, 0x24070005, 0x8f82000c, 0x30434000,
827 0x10600016, 0x00404821, 0x3c020f00, 0x00c21024, 0x14400012, 0x00000000,
828 0x93420116, 0x34424000, 0x03421821, 0x94650002, 0x2ca21389, 0x1040000b,
829 0x3c020800, 0x24422100, 0x00051942, 0x00031880, 0x00621821, 0x30a5001f,
830 0x8c640000, 0x24020001, 0x00a21004, 0x00822024, 0x01044025, 0x11000037,
831 0x3c021000, 0x9742010e, 0x34e60002, 0x3c038000, 0x24420004, 0x3045ffff,
832 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x8f840004,
833 0x24020180, 0x24030002, 0xaf420180, 0xa743018c, 0x10800005, 0xa745018e,
834 0x9743011c, 0x9742011e, 0x0a0000cd, 0x00021400, 0x9743011e, 0x9742011c,
835 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c, 0x30828000, 0x1040000c,
836 0xa7460188, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000,
837 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf82000c,
838 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff,
839 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x03e00008,
840 0x00001021, 0x00c21024, 0x104000ba, 0x3c020800, 0x8c430030, 0x1060003e,
841 0x31224000, 0x1040003c, 0x3c030f00, 0x00c31824, 0x3c020100, 0x0043102b,
842 0x14400038, 0x3c030800, 0x9742010e, 0x34e60002, 0x3c038000, 0x24420004,
843 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b,
844 0x8f840004, 0x24020080, 0x24030002, 0xaf420180, 0xa743018c, 0x10800005,
845 0xa745018e, 0x9743011c, 0x9742011e, 0x0a000110, 0x00021400, 0x9743011e,
846 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c, 0x30828000,
847 0x1040000c, 0xa7460188, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
848 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024,
849 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
850 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8,
851 0x03e00008, 0x00001021, 0x3c030800, 0x8c620024, 0x30420008, 0x1040003d,
852 0x34e80002, 0x3c020f00, 0x00c21024, 0x5440003a, 0x3107ffff, 0x9742010c,
853 0x30420200, 0x50400036, 0x3107ffff, 0x9742010e, 0x30e6fffb, 0x3c038000,
854 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003,
855 0xa342018b, 0x8f840004, 0x24020180, 0x24030002, 0xaf420180, 0xa743018c,
856 0x10800005, 0xa745018e, 0x9743011c, 0x9742011e, 0x0a000153, 0x00021400,
857 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c,
858 0x30828000, 0x1040000c, 0xa7460188, 0x93420116, 0x304200fc, 0x005a1021,
859 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
860 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff,
861 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
862 0xaf4201b8, 0x3107ffff, 0x8f820000, 0x3c068000, 0x9743010e, 0x00021442,
863 0x30440780, 0x24630004, 0x3065ffff, 0x8f4201b8, 0x00461024, 0x1440fffd,
864 0x24020003, 0xa342018b, 0x8f830004, 0x24020002, 0xaf440180, 0xa742018c,
865 0x10600005, 0xa745018e, 0x9743011c, 0x9742011e, 0x0a000189, 0x00021400,
866 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c,
867 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021,
868 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
869 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff,
870 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
871 0xaf4201b8, 0x03e00008, 0x00001021, 0x8f424000, 0x30420100, 0x104000ef,
872 0x3c020800, 0x8c440024, 0x24030001, 0x14830036, 0x00404021, 0x9742010e,
873 0x34e50002, 0x3c038000, 0x24420004, 0x3044ffff, 0x8f4201b8, 0x00431024,
874 0x1440fffd, 0x24020003, 0xa342018b, 0x8f830004, 0x24020002, 0xaf400180,
875 0xa742018c, 0x10600005, 0xa744018e, 0x9743011c, 0x9742011e, 0x0a0001c6,
876 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8,
877 0x8f84000c, 0x30828000, 0x1040000c, 0xa7450188, 0x93420116, 0x304200fc,
878 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff,
879 0x34427fff, 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104,
880 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac,
881 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x30820001, 0x10400035,
882 0x30e90004, 0x9742010e, 0x30e6fffb, 0x3c038000, 0x24420004, 0x3044ffff,
883 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x8f830004,
884 0x24020002, 0xaf400180, 0xa742018c, 0x10600005, 0xa744018e, 0x9743011c,
885 0x9742011e, 0x0a0001fe, 0x00021400, 0x9743011e, 0x9742011c, 0x00021400,
886 0x00621825, 0xaf4301a8, 0x8f84000c, 0x30828000, 0x1040000c, 0xa7470188,
887 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff,
888 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf82000c, 0x9782000e,
889 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825,
890 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x30c7ffff, 0x8d020024,
891 0x30420004, 0x10400037, 0x8d020024, 0x9742010e, 0x30e6fffb, 0x3c038000,
892 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003,
893 0xa342018b, 0x8f840004, 0x24020100, 0x24030002, 0xaf420180, 0xa743018c,
894 0x10800005, 0xa745018e, 0x9743011c, 0x9742011e, 0x0a000237, 0x00021400,
895 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c,
896 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021,
897 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
898 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff,
899 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
900 0xaf4201b8, 0x30c7ffff, 0x8d020024, 0x30420008, 0x10400034, 0x00000000,
901 0x9742010e, 0x3c038000, 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024,
902 0x1440fffd, 0x24020003, 0xa342018b, 0x8f840004, 0x24020180, 0x24030002,
903 0xaf420180, 0xa743018c, 0x10800005, 0xa745018e, 0x9743011c, 0x9742011e,
904 0x0a00026f, 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825,
905 0xaf4301a8, 0x8f84000c, 0x30828000, 0x1040000c, 0xa7470188, 0x93420116,
906 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004,
907 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c,
908 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6,
909 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x15200046, 0x00001021, 0x3c038000,
910 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002, 0x24032000, 0xa342018b,
911 0xa7430188, 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x3c030800,
912 0x8c620024, 0x30420001, 0x10400035, 0x00001021, 0x9742010e, 0x34e50002,
913 0x3c038000, 0x24420004, 0x3044ffff, 0x8f4201b8, 0x00431024, 0x1440fffd,
914 0x24020003, 0xa342018b, 0x8f830004, 0x24020002, 0xaf400180, 0xa742018c,
915 0x10600005, 0xa744018e, 0x9743011c, 0x9742011e, 0x0a0002b5, 0x00021400,
916 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c,
917 0x30828000, 0x1040000c, 0xa7450188, 0x93420116, 0x304200fc, 0x005a1021,
918 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
919 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff,
920 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
921 0xaf4201b8, 0x00001021, 0x03e00008, 0x00000000, 0x27bdffe0, 0xafbf0018,
922 0xafb10014, 0xafb00010, 0x8f420140, 0xaf420020, 0x8f430148, 0x3c027000,
923 0x00621824, 0x3c024000, 0x1062000c, 0x0043102b, 0x14400006, 0x3c025000,
924 0x3c023000, 0x1062000b, 0x3c024000, 0x0a00031f, 0x00000000, 0x10620034,
925 0x3c024000, 0x0a00031f, 0x00000000, 0x0e00067c, 0x00000000, 0x0a00031f,
926 0x3c024000, 0x8f420148, 0x24030002, 0x3044ffff, 0x00021402, 0x305000ff,
927 0x1203000c, 0x27510180, 0x2a020003, 0x10400005, 0x24020003, 0x0600001d,
928 0x36053000, 0x0a00030a, 0x3c038000, 0x12020007, 0x00000000, 0x0a000317,
929 0x00000000, 0x0e000423, 0x00000000, 0x0a000308, 0x00402021, 0x0e000435,
930 0x00000000, 0x00402021, 0x36053000, 0x3c038000, 0x8f4201b8, 0x00431024,
931 0x1440fffd, 0x24020002, 0xa6250008, 0xa222000b, 0xa6240010, 0x8f420144,
932 0x3c031000, 0xae220024, 0xaf4301b8, 0x0a00031f, 0x3c024000, 0x0000000d,
933 0x00000000, 0x240001c3, 0x0a00031f, 0x3c024000, 0x0e0007f7, 0x00000000,
934 0x3c024000, 0xaf420178, 0x00000000, 0x8fbf0018, 0x8fb10014, 0x8fb00010,
935 0x03e00008, 0x27bd0020, 0x24020800, 0x03e00008, 0xaf4201b8, 0x27bdffe8,
936 0x3c04600c, 0xafbf0014, 0xafb00010, 0x8c825000, 0x3c1a8000, 0x2403ff7f,
937 0x3c106000, 0x00431024, 0x3442380c, 0x24030003, 0xac825000, 0x3c040008,
938 0xaf430008, 0x8e020808, 0x3c030800, 0xac600020, 0x3042fff0, 0x2c420001,
939 0xaf820004, 0x0e000819, 0x0344d825, 0x0e000781, 0x00000000, 0x3c020400,
940 0x3442000c, 0x3c03ffff, 0x34630806, 0xae021948, 0xae03194c, 0x8e021980,
941 0x34420200, 0xae021980, 0x8f500000, 0x32020003, 0x1040fffd, 0x32020001,
942 0x10400004, 0x32020002, 0x0e0003bd, 0x00000000, 0x32020002, 0x1040fff6,
943 0x00000000, 0x0e0002d4, 0x00000000, 0x0a00034a, 0x00000000, 0x27bdffe8,
944 0x3c04600c, 0xafbf0014, 0xafb00010, 0x8c825000, 0x3c1a8000, 0x2403ff7f,
945 0x3c106000, 0x00431024, 0x3442380c, 0x24030003, 0xac825000, 0x3c040008,
946 0xaf430008, 0x8e020808, 0x3c030800, 0xac600020, 0x3042fff0, 0x2c420001,
947 0xaf820004, 0x0e000819, 0x0344d825, 0x0e000781, 0x00000000, 0x3c020400,
948 0x3442000c, 0x3c03ffff, 0x34630806, 0xae021948, 0xae03194c, 0x8e021980,
949 0x8fbf0014, 0x34420200, 0xae021980, 0x8fb00010, 0x03e00008, 0x27bd0018,
950 0x30a5ffff, 0x30c6ffff, 0x30e7ffff, 0x3c038000, 0x8f4201b8, 0x00431024,
951 0x1440fffd, 0x24020003, 0xa342018b, 0x8f830004, 0xaf440180, 0xa745018c,
952 0x10600005, 0xa746018e, 0x9743011c, 0x9742011e, 0x0a000393, 0x00021400,
953 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f84000c,
954 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021,
955 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
956 0x00821024, 0xaf82000c, 0x9782000e, 0x9743010c, 0x8f440104, 0x3042bfff,
957 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
958 0xaf4201b8, 0x03e00008, 0x00000000, 0x3c038000, 0x8f4201b8, 0x00431024,
959 0x1440fffd, 0x24020002, 0x24032000, 0xa342018b, 0xa7430188, 0x3c021000,
960 0xaf4201b8, 0x03e00008, 0x00000000, 0x27bdffe8, 0xafbf0010, 0x8f460128,
961 0xaf460020, 0x8f420104, 0x8f450100, 0x24030800, 0x3c040010, 0xaf820000,
962 0x00441024, 0xaf85000c, 0xaf4301b8, 0x14400005, 0x3c02001f, 0x3c030800,
963 0x8c620020, 0x0a0003d5, 0x00002021, 0x3442ff00, 0x14c20009, 0x2402bfff,
964 0x3c030800, 0x8c620020, 0x24040001, 0x24420001, 0x0e00004c, 0xac620020,
965 0x0a0003e4, 0x00000000, 0x00a21024, 0x14400006, 0x00000000, 0xaf400048,
966 0x0e000448, 0xaf400040, 0x0a0003e4, 0x00000000, 0x0e000783, 0x00000000,
967 0x10400005, 0x3c024000, 0x8f430124, 0x3c026020, 0xac430014, 0x3c024000,
968 0xaf420138, 0x00000000, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe0,
969 0xafbf0018, 0xafb10014, 0xafb00010, 0x8f420148, 0x24030002, 0x3044ffff,
970 0x00021402, 0x305000ff, 0x1203000c, 0x27510180, 0x2a020003, 0x10400005,
971 0x24020003, 0x0600001d, 0x36053000, 0x0a00040e, 0x3c038000, 0x12020007,
972 0x00000000, 0x0a00041b, 0x00000000, 0x0e000423, 0x00000000, 0x0a00040c,
973 0x00402021, 0x0e000435, 0x00000000, 0x00402021, 0x36053000, 0x3c038000,
974 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002, 0xa6250008, 0xa222000b,
975 0xa6240010, 0x8f420144, 0x3c031000, 0xae220024, 0xaf4301b8, 0x0a00041f,
976 0x8fbf0018, 0x0000000d, 0x00000000, 0x240001c3, 0x8fbf0018, 0x8fb10014,
977 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3084ffff, 0x2c821389, 0x1040000d,
978 0x00001021, 0x3c030800, 0x24632100, 0x00042942, 0x00052880, 0x00a32821,
979 0x3086001f, 0x8ca40000, 0x24030001, 0x00c31804, 0x00832025, 0x03e00008,
980 0xaca40000, 0x03e00008, 0x24020091, 0x3084ffff, 0x2c821389, 0x1040000e,
981 0x00001021, 0x3c030800, 0x24632100, 0x00042942, 0x00052880, 0x00a32821,
982 0x3086001f, 0x24030001, 0x8ca40000, 0x00c31804, 0x00031827, 0x00832024,
983 0x03e00008, 0xaca40000, 0x03e00008, 0x24020091, 0x27bdffb0, 0x3c026000,
984 0xafbf0048, 0x8c434448, 0xaf630140, 0x93620005, 0x30420001, 0x14400005,
985 0x00000000, 0x0e0007ed, 0x00000000, 0x0a00067a, 0x8fbf0048, 0x93420116,
986 0x93430112, 0x8f430104, 0x3c040020, 0x34424000, 0x00641824, 0x1060000d,
987 0x03426021, 0x8f430128, 0x27420180, 0xac430000, 0x8f650040, 0x24040008,
988 0x240340c1, 0xa4430008, 0x24030002, 0xa043000b, 0x3c031000, 0x0a000563,
989 0xa044000a, 0x8f420104, 0x3c030040, 0x00431024, 0x10400007, 0x00000000,
990 0x8f430128, 0x27420180, 0xac430000, 0x8f650040, 0x0a00055c, 0x24040010,
991 0xaf400048, 0xaf400054, 0xaf400040, 0x8f630048, 0x8f620040, 0x00624823,
992 0x05210004, 0x00000000, 0x0000000d, 0x00000000, 0x24000132, 0x9742011a,
993 0x3046ffff, 0x10c00004, 0x8d880004, 0x01061021, 0x0a000487, 0x2445ffff,
994 0x01002821, 0x918a000d, 0xa7a00020, 0xafa00028, 0x9364003f, 0x3c026000,
995 0x8c434448, 0x308700ff, 0x31420004, 0x10400033, 0xaf630144, 0x24090012,
996 0x14e90006, 0x3c040800, 0x8c830028, 0x24020001, 0x24630001, 0x0a00054e,
997 0xac830028, 0x8f620044, 0x15020012, 0x97a20020, 0x27a60010, 0x27450180,
998 0x3442001a, 0xa7a20020, 0x8f630040, 0x3c048000, 0x24020020, 0xa3a70022,
999 0xa3a90023, 0xa3a2001a, 0xafa30028, 0x8f4201b8, 0x00441024, 0x1440fffd,
1000 0x00000000, 0x0a000533, 0x00000000, 0x8f620044, 0x01021023, 0x0440009e,
1001 0x24020001, 0x8f620048, 0x01021023, 0x0441009a, 0x24020001, 0x97a20020,
1002 0x27a60010, 0x34420001, 0xa7a20020, 0x8f630040, 0x27450180, 0x3c048000,
1003 0xafa30028, 0x8f4201b8, 0x00441024, 0x1440fffd, 0x00000000, 0x0a000533,
1004 0x00000000, 0x3c026000, 0x8c424448, 0xaf620148, 0x8f630040, 0x00685823,
1005 0x19600013, 0x00cb102a, 0x54400007, 0x314a00fe, 0x5566000c, 0x010b4021,
1006 0x31420001, 0x54400009, 0x010b4021, 0x314a00fe, 0x24020001, 0xa7a20020,
1007 0x8f630040, 0x00c05821, 0x00003021, 0x0a0004dd, 0xafa30028, 0x00cb1023,
1008 0x0a0004dd, 0x3046ffff, 0x00005821, 0x8f620048, 0x2442ffff, 0x00a21823,
1009 0x18600019, 0x0066102a, 0x14400013, 0x24020001, 0xa7a20020, 0x8f630040,
1010 0xafa30028, 0x8f620040, 0x55020005, 0x27a60010, 0x55200003, 0x27a60010,
1011 0x0a0004f6, 0x00c01821, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024,
1012 0x1440fffd, 0x00000000, 0x0a000533, 0x00000000, 0x8f650048, 0x00c31023,
1013 0x3046ffff, 0x314a00f6, 0x3c046000, 0x8c824448, 0x31430002, 0x1060001e,
1014 0xaf62014c, 0x8f620044, 0x1502000e, 0x97a20020, 0x27a60010, 0x34420200,
1015 0xa7a20020, 0x8f630040, 0x27450180, 0x3c048000, 0xafa30028, 0x8f4201b8,
1016 0x00441024, 0x1440fffd, 0x00000000, 0x0a000533, 0x00000000, 0x27a60010,
1017 0x34420001, 0xa7a20020, 0x8f630040, 0x27450180, 0x3c048000, 0xafa30028,
1018 0x8f4201b8, 0x00441024, 0x1440fffd, 0x00000000, 0x0a000533, 0x00000000,
1019 0x3c026000, 0x8c424448, 0x31430010, 0xaf620150, 0x54600003, 0x8d890008,
1020 0x0a00054e, 0x24020001, 0x8f630054, 0x2522ffff, 0x00431023, 0x1840002a,
1021 0x24020001, 0x27a60010, 0xa7a20020, 0x8f630040, 0x27450180, 0x3c048000,
1022 0xafa30028, 0x8f4201b8, 0x00441024, 0x1440fffd, 0x00000000, 0x8f420128,
1023 0xaca20000, 0x8cc30018, 0x240240c1, 0xa4a20008, 0xaca30018, 0x90c4000a,
1024 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x94c20010, 0xa4a20010, 0x90c30012,
1025 0xa0a30012, 0x90c20013, 0xa0a20013, 0x8cc30014, 0xaca30014, 0x8cc20024,
1026 0xaca20024, 0x8cc30028, 0xaca30028, 0x8cc4002c, 0x24020001, 0x3c031000,
1027 0xaca4002c, 0xaf4301b8, 0xaf400044, 0xaf400050, 0x0a00067a, 0x8fbf0048,
1028 0x3c026000, 0x8c424448, 0x31430020, 0x10600019, 0xaf620154, 0x8f430128,
1029 0x27420180, 0xac430000, 0x8f650040, 0x24040004, 0x240340c1, 0xa4430008,
1030 0x24030002, 0xa044000a, 0x24040008, 0xa043000b, 0x3c031000, 0xa4440010,
1031 0xa0400012, 0xa0400013, 0xac400014, 0xac400024, 0xac400028, 0xac40002c,
1032 0xac450018, 0x0e0007ed, 0xaf4301b8, 0x0a00067a, 0x8fbf0048, 0x8f430104,
1033 0x8c824448, 0x38e3000a, 0x2c630001, 0xaf620158, 0x38e2000c, 0x2c420001,
1034 0x00621825, 0x14600003, 0x2402000e, 0x14e2002a, 0x00000000, 0x50c00008,
1035 0x9584000e, 0x10c00004, 0xa7a60040, 0x01061021, 0x0a000583, 0x2445ffff,
1036 0x01002821, 0x9584000e, 0x93630035, 0x8f62004c, 0x00642004, 0x00892021,
1037 0x00821023, 0x1840001f, 0x3c026000, 0x8f620018, 0x01021023, 0x1c40000f,
1038 0x97a20020, 0x8f620018, 0x15020018, 0x3c026000, 0x8f62001c, 0x01221023,
1039 0x1c400008, 0x97a20020, 0x8f62001c, 0x15220011, 0x3c026000, 0x8f620058,
1040 0x00821023, 0x1840000c, 0x97a20020, 0xafa50028, 0xafa80034, 0xafa90038,
1041 0xafa4003c, 0x34420020, 0x0a0005a8, 0xa7a20020, 0x8f680040, 0x00003021,
1042 0x8f640058, 0x01002821, 0x3c026000, 0x8c434448, 0xaf63015c, 0x8f62004c,
1043 0x01221023, 0x18400009, 0x00000000, 0x8f620054, 0x01221023, 0x1c400005,
1044 0x97a20020, 0xafa50028, 0xafa90024, 0x0a0005c3, 0x34420040, 0x9742011a,
1045 0x1440000c, 0x24020014, 0x8f620058, 0x14820009, 0x24020014, 0x8f63004c,
1046 0x8f620054, 0x10620004, 0x97a20020, 0xafa50028, 0x34420080, 0xa7a20020,
1047 0x24020014, 0x10e2000a, 0x28e20015, 0x10400005, 0x2402000c, 0x10e20006,
1048 0x3c026000, 0x0a000600, 0x00000000, 0x24020016, 0x14e20031, 0x3c026000,
1049 0x8f620054, 0x24420001, 0x1522002d, 0x3c026000, 0x24020014, 0x10e2001e,
1050 0x28e20015, 0x10400005, 0x2402000c, 0x10e20008, 0x3c026000, 0x0a000600,
1051 0x00000000, 0x24020016, 0x10e2000c, 0x97a20020, 0x0a000600, 0x3c026000,
1052 0x97a30020, 0x2402000e, 0xafa50028, 0xa3a70022, 0xa3a20023, 0xafa90024,
1053 0x34630054, 0x0a0005ff, 0xa7a30020, 0x24030010, 0x24040002, 0xafa50028,
1054 0xa3a70022, 0xa3a30023, 0xa3a4001a, 0xafa90024, 0x0a0005fe, 0x3442005d,
1055 0x97a20020, 0x24030012, 0x24040002, 0xafa50028, 0xa3a70022, 0xa3a30023,
1056 0xa3a4001a, 0xafa90024, 0x3042fffe, 0x3442005c, 0xa7a20020, 0x3c026000,
1057 0x8c434448, 0x31420001, 0xaf630160, 0x1040002c, 0x2402000c, 0x10e20014,
1058 0x28e2000d, 0x10400005, 0x2402000a, 0x10e20008, 0x97a20020, 0x0a000631,
1059 0x3c026000, 0x2402000e, 0x10e20018, 0x3c026000, 0x0a000631, 0x00000000,
1060 0x24030008, 0x24040002, 0xafa50028, 0xa3a70022, 0xa3a30023, 0xa3a4001a,
1061 0x0a00062f, 0x34420013, 0x97a30020, 0x30620004, 0x1440000b, 0x97a20020,
1062 0x3462001b, 0xa7a20020, 0x24020016, 0x24030002, 0xafa50028, 0xa3a70022,
1063 0xa3a20023, 0x0a000630, 0xa3a3001a, 0x97a20020, 0x24030010, 0x24040002,
1064 0xafa50028, 0xa3a70022, 0xa3a30023, 0xa3a4001a, 0x3442001b, 0xa7a20020,
1065 0x3c026000, 0x8c434448, 0x31420009, 0x0002102b, 0x00021023, 0x30420007,
1066 0x34440003, 0xaf630164, 0x10c00016, 0x24030800, 0x8f820010, 0x27450180,
1067 0x24420001, 0xaf820010, 0x24020004, 0xaf4301b8, 0xa4a40008, 0xa0a2000b,
1068 0x93440120, 0x3c031000, 0xa4a6000e, 0xaca90024, 0xaca80028, 0x008b2021,
1069 0xa4a4000c, 0xaf4301b8, 0x97a20020, 0x00003021, 0x3042ffbf, 0x0a000650,
1070 0xa7a20020, 0x24060001, 0x3c026000, 0x8c434448, 0xaf630168, 0x97a20020,
1071 0x10400020, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd,
1072 0x00000000, 0x8f420128, 0xaca20000, 0x8fa30028, 0x240240c1, 0xa4a20008,
1073 0xaca30018, 0x93a4001a, 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x97a20020,
1074 0xa4a20010, 0x93a30022, 0xa0a30012, 0x93a20023, 0xa0a20013, 0x8fa30024,
1075 0xaca30014, 0x8fa20034, 0xaca20024, 0x8fa30038, 0xaca30028, 0x8fa2003c,
1076 0x3c031000, 0xaca2002c, 0xaf4301b8, 0x3c026000, 0x8c434448, 0x00c01021,
1077 0xaf63016c, 0x8fbf0048, 0x03e00008, 0x27bd0050, 0x8f460140, 0x8f470148,
1078 0x3c028000, 0x00e24024, 0x00072c02, 0x30a300ff, 0x2402000b, 0x1062008f,
1079 0x27440180, 0x2862000c, 0x10400011, 0x24020006, 0x1062005a, 0x28620007,
1080 0x10400007, 0x24020008, 0x10600024, 0x24020001, 0x10620037, 0x00000000,
1081 0x0a00077e, 0x00000000, 0x106200a9, 0x24020009, 0x106200bb, 0x00071c02,
1082 0x0a00077e, 0x00000000, 0x2402001b, 0x106200c7, 0x2862001c, 0x10400007,
1083 0x2402000e, 0x106200b1, 0x24020019, 0x106200c2, 0x00071c02, 0x0a00077e,
1084 0x00000000, 0x24020080, 0x10620060, 0x28620081, 0x10400005, 0x2402001c,
1085 0x10620094, 0x00071c02, 0x0a00077e, 0x00000000, 0x240200c2, 0x106200c5,
1086 0x00a01821, 0x0a00077e, 0x00000000, 0x00a01821, 0x3c058000, 0x8f4201b8,
1087 0x00451024, 0x1440fffd, 0x24020001, 0xa4830008, 0x24030002, 0xac860000,
1088 0xac800004, 0xa082000a, 0xa083000b, 0xa4870010, 0x8f430144, 0x3c021000,
1089 0xac800028, 0xac830024, 0x3c036000, 0xaf4201b8, 0x03e00008, 0xac600808,
1090 0x11000009, 0x00a01821, 0x3c020800, 0x24030002, 0xa0434490, 0x24424490,
1091 0xac460008, 0x8f430144, 0x03e00008, 0xac430004, 0x3c058000, 0x8f4201b8,
1092 0x00451024, 0x1440fffd, 0x24020002, 0xac800000, 0xac860004, 0xa4830008,
1093 0xa082000a, 0xa082000b, 0xa4870010, 0xac800024, 0x8f420144, 0x3c031000,
1094 0xac820028, 0x3c026000, 0xaf4301b8, 0x03e00008, 0xac400808, 0x00a01821,
1095 0x3c080800, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x00000000,
1096 0xac860000, 0x91024490, 0x00002821, 0x10400002, 0x25064490, 0x8cc50008,
1097 0xac850004, 0xa4830008, 0x91034490, 0x24020002, 0xa082000b, 0xa4870010,
1098 0x34630001, 0xa083000a, 0x8f420144, 0xac820024, 0x91034490, 0x10600002,
1099 0x00001021, 0x8cc20004, 0xac820028, 0x3c021000, 0xaf4201b8, 0x3c026000,
1100 0xa1004490, 0x03e00008, 0xac400808, 0x00a01821, 0x3c058000, 0x8f4201b8,
1101 0x00451024, 0x1440fffd, 0x24020002, 0xa082000b, 0xa4830008, 0xa4870010,
1102 0x8f420144, 0x3c031000, 0xa4820012, 0x03e00008, 0xaf4301b8, 0x30e2ffff,
1103 0x14400028, 0x00071c02, 0x93620005, 0x30420004, 0x14400020, 0x3c029000,
1104 0x34420001, 0x00c21025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024,
1105 0x1440fffd, 0x00000000, 0x93620005, 0x3c038000, 0x34630001, 0x00c31825,
1106 0x34420004, 0xa3620005, 0xaf430020, 0x93620005, 0x30420004, 0x14400003,
1107 0x3c038000, 0x0000000d, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd,
1108 0x24020005, 0x3c031000, 0xac860000, 0xa082000b, 0xaf4301b8, 0x0a00073d,
1109 0x00071c02, 0x0000000d, 0x03e00008, 0x00000000, 0x00071c02, 0x3c058000,
1110 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020001, 0xa4830008, 0x24030002,
1111 0xac860000, 0xac800004, 0xa082000a, 0xa083000b, 0xa4870010, 0x8f430144,
1112 0x3c021000, 0xac800028, 0xac830024, 0x03e00008, 0xaf4201b8, 0x00071c02,
1113 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020002, 0xac800000,
1114 0xac860004, 0xa4830008, 0xa082000a, 0xa082000b, 0xa4870010, 0xac800024,
1115 0x8f420144, 0x3c031000, 0xac820028, 0x03e00008, 0xaf4301b8, 0x00071c02,
1116 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020001, 0xa4830008,
1117 0x24030002, 0xa082000a, 0x3c021000, 0xac860000, 0xac800004, 0xa083000b,
1118 0xa4870010, 0xac800024, 0xac800028, 0x03e00008, 0xaf4201b8, 0x3c058000,
1119 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020002, 0xac860000, 0xac800004,
1120 0xa4830008, 0xa080000a, 0x0a000748, 0xa082000b, 0x0000000d, 0x03e00008,
1121 0x00000000, 0x03e00008, 0x00000000, 0x8f420100, 0x3042003e, 0x14400011,
1122 0x24020001, 0xaf400048, 0x8f420100, 0x304207c0, 0x10400005, 0x00000000,
1123 0xaf40004c, 0xaf400050, 0x03e00008, 0x24020001, 0xaf400054, 0xaf400040,
1124 0x8f420100, 0x30423800, 0x54400001, 0xaf400044, 0x24020001, 0x03e00008,
1125 0x00000000, 0x3c029000, 0x34420001, 0x00822025, 0xaf440020, 0x3c038000,
1126 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x03e00008, 0x00000000,
1127 0x3c028000, 0x34420001, 0x00822025, 0x03e00008, 0xaf440020, 0x8f430128,
1128 0x27420180, 0xac430000, 0x8f650040, 0x240340c1, 0xa4430008, 0x24030002,
1129 0xa044000a, 0x24040008, 0xa043000b, 0x3c031000, 0xa4440010, 0xa0400012,
1130 0xa0400013, 0xac400014, 0xac400024, 0xac400028, 0xac40002c, 0xac450018,
1131 0x03e00008, 0xaf4301b8, 0x24020001, 0xacc40000, 0x03e00008, 0xa4e50000,
1132 0x03e00008, 0x24020001, 0x24020001, 0xaf400044, 0x03e00008, 0xaf400050,
1133 0x00803021, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd,
1134 0x00000000, 0x8f420128, 0xaca20000, 0x8cc30018, 0x240240c1, 0xa4a20008,
1135 0xaca30018, 0x90c4000a, 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x94c20010,
1136 0xa4a20010, 0x90c30012, 0xa0a30012, 0x90c20013, 0xa0a20013, 0x8cc30014,
1137 0xaca30014, 0x8cc20024, 0xaca20024, 0x8cc30028, 0xaca30028, 0x8cc2002c,
1138 0x3c031000, 0xaca2002c, 0x24020001, 0xaf4301b8, 0xaf400044, 0x03e00008,
1139 0xaf400050, 0x27bdffe8, 0xafbf0010, 0x0e000326, 0x00000000, 0x00002021,
1140 0x0e00004c, 0xaf400180, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x8f460148,
1141 0x27450180, 0x3c038000, 0x00061402, 0x304700ff, 0x8f4201b8, 0x00431024,
1142 0x1440fffd, 0x00000000, 0x8f440140, 0x00061202, 0x304200ff, 0x00061c02,
1143 0xaca20004, 0x24020002, 0xa4a30008, 0x30c300ff, 0xa0a2000b, 0xaca30024,
1144 0x10e0000a, 0xaca40000, 0x28e20004, 0x14400005, 0x24020001, 0x24020005,
1145 0x54e20005, 0xa0a0000a, 0x24020001, 0x0a000816, 0xa0a2000a, 0xa0a0000a,
1146 0x3c021000, 0x03e00008, 0xaf4201b8, 0x03e00008, 0x00001021, 0x10c00007,
1147 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000, 0x14c0fffb,
1148 0x24840004, 0x03e00008, 0x00000000, 0x0a00082a, 0x00a01021, 0xac860000,
1149 0x24840004, 0x00a01021, 0x1440fffc, 0x24a5ffff, 0x03e00008, 0x00000000,
1150 0x00000000 };
1151
1152static u32 bnx2_RXP_b06FwData[(0x0/4) + 1] = { 0x00000000 };
1153static u32 bnx2_RXP_b06FwRodata[(0x0/4) + 1] = { 0x00000000 };
1154static u32 bnx2_RXP_b06FwBss[(0x239c/4) + 1] = { 0x00000000 };
1155static u32 bnx2_RXP_b06FwSbss[(0x14/4) + 1] = { 0x00000000 };
1156
1157static u32 bnx2_rv2p_proc1[] = {
1158 0x00000008, 0xac000001, 0x0000000c, 0x2f800001, 0x00000010, 0x213f0004,
1159 0x00000010, 0x20bf002c, 0x00000010, 0x203f0143, 0x00000018, 0x8000fffd,
1160 0x00000010, 0xb1b8b017, 0x0000000b, 0x2fdf0002, 0x00000000, 0x03d80000,
1161 0x00000000, 0x2c380000, 0x00000008, 0x2c800000, 0x00000008, 0x2d000000,
1162 0x00000010, 0x91d40000, 0x00000008, 0x2d800108, 0x00000008, 0x02000002,
1163 0x00000010, 0x91de0000, 0x0000000f, 0x42e0001c, 0x00000010, 0x91840a08,
1164 0x00000008, 0x2c8000b0, 0x00000008, 0x2d000008, 0x00000008, 0x2d800150,
1165 0x00000000, 0x00000000, 0x00000010, 0x91de0000, 0x00000010, 0x2c620002,
1166 0x00000018, 0x80000012, 0x0000000b, 0x2fdf0002, 0x0000000c, 0x1f800002,
1167 0x00000000, 0x2c070000, 0x00000018, 0x8000ffe6, 0x00000008, 0x02000002,
1168 0x0000000f, 0x42e0001c, 0x00000010, 0x91840a08, 0x00000008, 0x2c8000b0,
1169 0x00000008, 0x2d000008, 0x00000010, 0x91d40000, 0x00000008, 0x2d800108,
1170 0x00000000, 0x00000000, 0x00000010, 0x91de0000, 0x00000018, 0x80000004,
1171 0x0000000c, 0x1f800002, 0x00000000, 0x00000000, 0x00000018, 0x8000ffd9,
1172 0x0000000c, 0x29800002, 0x0000000c, 0x1f800002, 0x00000000, 0x2adf0000,
1173 0x00000008, 0x2a000005, 0x00000018, 0x8000ffd4, 0x00000008, 0x02240030,
1174 0x00000018, 0x00040000, 0x00000018, 0x80000015, 0x00000018, 0x80000017,
1175 0x00000018, 0x8000001b, 0x00000018, 0x8000004c, 0x00000018, 0x8000008c,
1176 0x00000018, 0x8000000f, 0x00000018, 0x8000000e, 0x00000018, 0x8000000d,
1177 0x00000018, 0x8000000c, 0x00000018, 0x800000c2, 0x00000018, 0x8000000a,
1178 0x00000018, 0x80000009, 0x00000018, 0x80000008, 0x00000018, 0x800000fd,
1179 0x00000018, 0x80000006, 0x00000018, 0x80000005, 0x00000018, 0x800000ff,
1180 0x00000018, 0x80000104, 0x00000018, 0x80000002, 0x00000018, 0x80000098,
1181 0x00000018, 0x80000000, 0x0000000c, 0x1f800001, 0x00000000, 0x00000000,
1182 0x00000018, 0x8000ffba, 0x00000010, 0x91d40000, 0x0000000c, 0x29800001,
1183 0x0000000c, 0x1f800001, 0x00000008, 0x2a000002, 0x00000018, 0x8000ffb5,
1184 0x00000010, 0xb1a0b012, 0x0000000b, 0x2fdf0002, 0x00000000, 0x2c200000,
1185 0x00000008, 0x2c800000, 0x00000008, 0x2d000000, 0x00000010, 0x91d40000,
1186 0x00000008, 0x2d80011c, 0x00000000, 0x00000000, 0x00000010, 0x91de0000,
1187 0x0000000f, 0x47600008, 0x0000000f, 0x060e0001, 0x00000010, 0x001f0000,
1188 0x00000000, 0x0f580000, 0x00000000, 0x0a640000, 0x00000000, 0x0ae50000,
1189 0x00000000, 0x0b660000, 0x00000000, 0x0d610000, 0x00000018, 0x80000013,
1190 0x0000000f, 0x47600008, 0x0000000b, 0x2fdf0002, 0x00000008, 0x2c800000,
1191 0x00000008, 0x2d000000, 0x00000010, 0x91d40000, 0x00000008, 0x2d80011c,
1192 0x0000000f, 0x060e0001, 0x00000010, 0x001f0000, 0x00000000, 0x0f580000,
1193 0x00000010, 0x91de0000, 0x00000000, 0x0a640000, 0x00000000, 0x0ae50000,
1194 0x00000000, 0x0b660000, 0x00000000, 0x0d610000, 0x00000000, 0x02620000,
1195 0x0000000b, 0x2fdf0002, 0x00000000, 0x309a0000, 0x00000000, 0x31040000,
1196 0x00000000, 0x0c961800, 0x00000009, 0x0c99ffff, 0x00000004, 0xcc993400,
1197 0x00000010, 0xb1963202, 0x00000008, 0x0f800000, 0x0000000c, 0x29800001,
1198 0x00000010, 0x00220002, 0x0000000c, 0x29520001, 0x0000000c, 0x29520000,
1199 0x00000008, 0x22000001, 0x0000000c, 0x1f800001, 0x00000000, 0x2adf0000,
1200 0x00000008, 0x2a000003, 0x00000018, 0x8000ff83, 0x00000010, 0xb1a0b01d,
1201 0x0000000b, 0x2fdf0002, 0x00000000, 0x2c200000, 0x00000008, 0x2c8000b0,
1202 0x00000008, 0x2d000008, 0x00000010, 0x91d40000, 0x00000008, 0x2d800150,
1203 0x00000000, 0x00000000, 0x00000010, 0x205f0000, 0x00000008, 0x2c800000,
1204 0x00000008, 0x2d000000, 0x00000008, 0x2d800108, 0x00000000, 0x00000000,
1205 0x00000010, 0x91de0000, 0x0000000f, 0x47600008, 0x00000000, 0x060e0000,
1206 0x00000010, 0x001f0000, 0x00000000, 0x0f580000, 0x00000010, 0x91de0000,
1207 0x00000000, 0x0a640000, 0x00000000, 0x0ae50000, 0x00000000, 0x0b670000,
1208 0x00000000, 0x0d620000, 0x00000000, 0x0ce71800, 0x00000009, 0x0c99ffff,
1209 0x00000004, 0xcc993400, 0x00000010, 0xb1963220, 0x00000008, 0x0f800000,
1210 0x00000018, 0x8000001e, 0x0000000f, 0x47600008, 0x0000000b, 0x2fdf0002,
1211 0x00000008, 0x2c8000b0, 0x00000008, 0x2d000008, 0x00000010, 0x91d40000,
1212 0x00000008, 0x2d80012c, 0x0000000f, 0x060e0001, 0x00000010, 0x001f0000,
1213 0x00000000, 0x0f580000, 0x00000010, 0x91de0000, 0x00000000, 0x0a640000,
1214 0x00000000, 0x0ae50000, 0x00000000, 0x0b670000, 0x00000000, 0x0d620000,
1215 0x00000000, 0x02630000, 0x0000000f, 0x47620010, 0x00000000, 0x0ce71800,
1216 0x0000000b, 0x2fdf0002, 0x00000000, 0x311a0000, 0x00000000, 0x31840000,
1217 0x0000000b, 0xc20000ff, 0x00000002, 0x42040000, 0x00000001, 0x31620800,
1218 0x0000000f, 0x020e0010, 0x00000002, 0x31620800, 0x00000009, 0x0c99ffff,
1219 0x00000004, 0xcc993400, 0x00000010, 0xb1963202, 0x00000008, 0x0f800000,
1220 0x0000000c, 0x29800001, 0x0000000c, 0x1f800001, 0x0000000c, 0x61420006,
1221 0x00000008, 0x22000008, 0x00000000, 0x2adf0000, 0x00000008, 0x2a000004,
1222 0x00000018, 0x8000ff42, 0x00000008, 0x2c8000b0, 0x00000008, 0x2d000008,
1223 0x00000010, 0x91a0b008, 0x00000010, 0x91d40000, 0x0000000c, 0x31620018,
1224 0x00000008, 0x2d800001, 0x00000000, 0x00000000, 0x00000010, 0x91de0000,
1225 0x00000008, 0xac000001, 0x00000018, 0x8000000e, 0x00000000, 0x0380b000,
1226 0x0000000b, 0x2fdf0002, 0x00000000, 0x2c004000, 0x00000010, 0x91d40000,
1227 0x00000008, 0x2d800101, 0x00000000, 0x00000000, 0x00000010, 0x91de0000,
1228 0x0000000c, 0x31620018, 0x00000008, 0x2d800001, 0x00000000, 0x00000000,
1229 0x00000010, 0x91de0000, 0x0000000b, 0x2fdf0002, 0x00000000, 0x2c000e00,
1230 0x0000000c, 0x29800001, 0x0000000c, 0x1f800001, 0x00000008, 0x2a000007,
1231 0x00000018, 0x8000ff27, 0x00000010, 0xb1a0b016, 0x0000000b, 0x2fdf0002,
1232 0x00000000, 0x03d80000, 0x00000000, 0x2c200000, 0x00000008, 0x2c8000b0,
1233 0x00000008, 0x2d000008, 0x00000010, 0x91d40000, 0x00000008, 0x2d800150,
1234 0x00000000, 0x00000000, 0x00000010, 0x205f0000, 0x00000008, 0x2c800000,
1235 0x00000008, 0x2d000000, 0x00000008, 0x2d800108, 0x00000008, 0x07000001,
1236 0x00000010, 0xb5de1c00, 0x00000010, 0x2c620002, 0x00000018, 0x8000000a,
1237 0x0000000b, 0x2fdf0002, 0x00000000, 0x2c070000, 0x0000000c, 0x1f800001,
1238 0x00000010, 0x91de0000, 0x00000018, 0x8000ff11, 0x00000008, 0x2c8000b0,
1239 0x00000008, 0x2d000008, 0x00000010, 0x91d40000, 0x00000008, 0x2d800108,
1240 0x0000000c, 0x29800001, 0x0000000c, 0x1f800001, 0x00000010, 0x91de0000,
1241 0x00000000, 0x2adf0000, 0x00000008, 0x2a00000a, 0x00000018, 0x8000ff07,
1242 0x00000000, 0x82265600, 0x0000000f, 0x47220008, 0x00000009, 0x070e000f,
1243 0x00000008, 0x070e0008, 0x00000008, 0x02800001, 0x00000007, 0x02851c00,
1244 0x00000008, 0x82850001, 0x00000000, 0x02840a00, 0x00000007, 0x42851c00,
1245 0x00000003, 0xc3aa5200, 0x00000000, 0x03b10e00, 0x00000010, 0x001f0000,
1246 0x0000000f, 0x0f280007, 0x00000007, 0x4b071c00, 0x00000000, 0x00000000,
1247 0x0000000f, 0x0a960003, 0x00000000, 0x0a955c00, 0x00000000, 0x4a005a00,
1248 0x00000000, 0x0c960a00, 0x00000009, 0x0c99ffff, 0x00000008, 0x0d00ffff,
1249 0x00000010, 0xb1963202, 0x00000008, 0x0f800005, 0x00000010, 0x00220020,
1250 0x00000000, 0x02a70000, 0x00000010, 0xb1850002, 0x00000008, 0x82850200,
1251 0x00000000, 0x02000000, 0x00000000, 0x03a60000, 0x00000018, 0x8000004e,
1252 0x00000000, 0x072b0000, 0x00000001, 0x878c1c00, 0x00000000, 0x870e1e00,
1253 0x00000000, 0x860c1e00, 0x00000000, 0x03061e00, 0x00000010, 0xb18e0003,
1254 0x00000018, 0x80000047, 0x00000018, 0x8000fffa, 0x00000010, 0x918c0003,
1255 0x00000010, 0xb1870002, 0x00000018, 0x80000043, 0x00000010, 0x91d40000,
1256 0x0000000c, 0x29800001, 0x00000000, 0x2a860000, 0x00000000, 0x230c0000,
1257 0x00000000, 0x2b070000, 0x00000010, 0xb187000e, 0x00000008, 0x2a000008,
1258 0x00000018, 0x8000003b, 0x00000010, 0x91d40000, 0x00000000, 0x28d18c00,
1259 0x00000000, 0x2a860000, 0x00000000, 0x230c0000, 0x00000000, 0x2b070000,
1260 0x00000018, 0x8000fff8, 0x00000010, 0x91d40000, 0x0000000c, 0x29800001,
1261 0x00000000, 0x2aab0000, 0x00000000, 0xa3265600, 0x00000000, 0x2b000000,
1262 0x0000000c, 0x1f800001, 0x00000008, 0x2a000008, 0x00000018, 0x8000fec8,
1263 0x00000010, 0x91d40000, 0x0000000c, 0x29800001, 0x0000000c, 0x1f800001,
1264 0x00000008, 0x2a000009, 0x00000018, 0x8000fec3, 0x00000010, 0x91d40000,
1265 0x0000000c, 0x29800001, 0x0000000c, 0x1f800001, 0x00000000, 0x29420000,
1266 0x00000008, 0x2a000002, 0x00000018, 0x8000febd, 0x00000018, 0x8000febc,
1267 0x00000010, 0xb1bcb016, 0x0000000b, 0x2fdf0002, 0x00000000, 0x03d80000,
1268 0x00000000, 0x2c3c0000, 0x00000008, 0x2c8000b0, 0x00000008, 0x2d000008,
1269 0x00000010, 0x91d40000, 0x00000008, 0x2d800150, 0x00000000, 0x00000000,
1270 0x00000010, 0x205f0000, 0x00000008, 0x2c800000, 0x00000008, 0x2d000000,
1271 0x00000008, 0x2d800108, 0x00000008, 0x07000001, 0x00000010, 0xb5de1c00,
1272 0x00000010, 0x2c620002, 0x00000018, 0x8000000a, 0x0000000b, 0x2fdf0002,
1273 0x00000000, 0x2c070000, 0x0000000c, 0x1f800000, 0x00000010, 0x91de0000,
1274 0x00000018, 0x8000fea6, 0x00000008, 0x2c8000b0, 0x00000008, 0x2d000008,
1275 0x00000010, 0x91d40000, 0x00000008, 0x2d800108, 0x0000000c, 0x29800000,
1276 0x0000000c, 0x1f800000, 0x00000010, 0x91de0000, 0x00000000, 0x2adf0000,
1277 0x00000008, 0x2a000006, 0x00000018, 0x8000fe9c, 0x00000008, 0x03050004,
1278 0x00000006, 0x83040c00, 0x00000008, 0x02850200, 0x00000000, 0x86050c00,
1279 0x00000001, 0x860c0e00, 0x00000008, 0x02040004, 0x00000000, 0x02041800,
1280 0x00000000, 0x83871800, 0x00000018, 0x00020000 };
1281
1282static u32 bnx2_rv2p_proc2[] = {
1283 0x00000000, 0x2a000000, 0x00000010, 0xb1d40000, 0x00000008, 0x02540003,
1284 0x00000018, 0x00040000, 0x00000018, 0x8000000a, 0x00000018, 0x8000000a,
1285 0x00000018, 0x8000000e, 0x00000018, 0x80000056, 0x00000018, 0x800001b9,
1286 0x00000018, 0x800001e1, 0x00000018, 0x8000019b, 0x00000018, 0x800001f9,
1287 0x00000018, 0x8000019f, 0x00000018, 0x800001a6, 0x00000018, 0x80000000,
1288 0x0000000c, 0x29800001, 0x00000000, 0x2a000000, 0x0000000c, 0x29800000,
1289 0x00000010, 0x20530000, 0x00000018, 0x8000ffee, 0x0000000c, 0x29800001,
1290 0x00000010, 0x91de0000, 0x00000010, 0x001f0000, 0x00000000, 0x2f80aa00,
1291 0x00000000, 0x2a000000, 0x00000000, 0x0d610000, 0x00000000, 0x03620000,
1292 0x00000000, 0x2c400000, 0x00000000, 0x02638c00, 0x00000000, 0x26460000,
1293 0x00000010, 0x00420002, 0x00000008, 0x02040012, 0x00000010, 0xb9060836,
1294 0x00000000, 0x0f580000, 0x00000000, 0x0a640000, 0x00000000, 0x0ae50000,
1295 0x00000000, 0x0b660000, 0x00000000, 0x0c000000, 0x00000000, 0x0b800000,
1296 0x00000010, 0x00420009, 0x00000008, 0x0cc60012, 0x00000008, 0x0f800003,
1297 0x00000000, 0x00000000, 0x00000010, 0x009f0000, 0x00000008, 0x27110012,
1298 0x00000000, 0x66900000, 0x00000008, 0xa31b0012, 0x00000018, 0x80000008,
1299 0x00000000, 0x0cc60000, 0x00000008, 0x0f800003, 0x00000000, 0x00000000,
1300 0x00000010, 0x009f0000, 0x00000000, 0x27110000, 0x00000000, 0x66900000,
1301 0x00000000, 0x231b0000, 0x00000010, 0xb197320e, 0x00000000, 0x25960000,
1302 0x00000000, 0x021b0000, 0x00000010, 0x001f0000, 0x00000008, 0x0f800003,
1303 0x0000000c, 0x29800000, 0x00000010, 0x20530000, 0x00000000, 0x22c50800,
1304 0x00000010, 0x009f0000, 0x00000000, 0x27002200, 0x00000000, 0x26802000,
1305 0x00000000, 0x231b0000, 0x0000000c, 0x69520001, 0x00000018, 0x8000fff3,
1306 0x00000010, 0x01130002, 0x00000010, 0xb1980003, 0x00000010, 0x001f0000,
1307 0x00000008, 0x0f800004, 0x00000008, 0x22000003, 0x00000008, 0x2c80000c,
1308 0x00000008, 0x2d00000c, 0x00000010, 0x009f0000, 0x00000000, 0x25960000,
1309 0x0000000c, 0x29800000, 0x00000000, 0x32140000, 0x00000000, 0x32950000,
1310 0x00000000, 0x33160000, 0x00000000, 0x31e32e00, 0x00000008, 0x2d800010,
1311 0x00000010, 0x20530000, 0x00000018, 0x8000ffac, 0x00000000, 0x23000000,
1312 0x00000000, 0x25e60000, 0x00000008, 0x2200000b, 0x0000000c, 0x69520000,
1313 0x0000000c, 0x29800000, 0x00000010, 0x20530000, 0x00000018, 0x8000ffa5,
1314 0x0000000c, 0x29800001, 0x00000010, 0x91de0000, 0x00000000, 0x2fd50000,
1315 0x00000010, 0x001f0000, 0x00000000, 0x02700000, 0x00000000, 0x0d620000,
1316 0x00000000, 0xbb630800, 0x00000000, 0x2a000000, 0x00000009, 0x076000ff,
1317 0x0000000f, 0x2c0e0007, 0x00000008, 0x2c800000, 0x00000008, 0x2d000064,
1318 0x00000008, 0x2d80011c, 0x00000009, 0x06420002, 0x0000000c, 0x61420001,
1319 0x00000000, 0x0f400000, 0x00000000, 0x02d08c00, 0x00000000, 0x23000000,
1320 0x00000004, 0x826da000, 0x00000000, 0x8304a000, 0x00000000, 0x22c50c00,
1321 0x00000000, 0x03760000, 0x00000004, 0x83860a00, 0x00000000, 0x83870c00,
1322 0x00000010, 0x91de0000, 0x00000000, 0x037c0000, 0x00000000, 0x837b0c00,
1323 0x00000001, 0x83060e00, 0x00000000, 0x83870c00, 0x00000000, 0x82850e00,
1324 0x00000010, 0xb1860016, 0x0000000f, 0x47610018, 0x00000000, 0x068e0000,
1325 0x0000000f, 0x47670010, 0x0000000f, 0x47e20010, 0x00000000, 0x870e1e00,
1326 0x00000010, 0xb70e1a10, 0x00000010, 0x0ce7000e, 0x00000008, 0x22000009,
1327 0x00000000, 0x286d0000, 0x0000000f, 0x65680010, 0x00000003, 0xf66c9400,
1328 0x00000010, 0xb972a003, 0x0000000c, 0x73e70019, 0x0000000c, 0x21420004,
1329 0x00000018, 0x8000023f, 0x00000000, 0x37ed0000, 0x0000000c, 0x73e7001a,
1330 0x00000010, 0x20530000, 0x00000008, 0x22000008, 0x0000000c, 0x61420004,
1331 0x00000000, 0x02f60000, 0x00000004, 0x82840a00, 0x00000010, 0xb1840a2b,
1332 0x00000010, 0x2d67000a, 0x00000010, 0xb96d0804, 0x00000004, 0xb6ed0a00,
1333 0x00000000, 0x37ed0000, 0x00000018, 0x80000029, 0x0000000c, 0x61420000,
1334 0x00000000, 0x37040000, 0x00000000, 0x37850000, 0x0000000c, 0x33e7001a,
1335 0x00000018, 0x80000024, 0x00000010, 0xb96d0809, 0x00000004, 0xb6ed0a00,
1336 0x00000000, 0x036d0000, 0x00000004, 0xb76e0c00, 0x00000010, 0x91ee0c1f,
1337 0x0000000c, 0x73e7001a, 0x00000004, 0xb6ef0c00, 0x00000000, 0x37ed0000,
1338 0x00000018, 0x8000001b, 0x0000000c, 0x61420000, 0x00000010, 0xb7ee0a05,
1339 0x00000010, 0xb96f0815, 0x00000003, 0xb76e0800, 0x00000004, 0xb7ef0a00,
1340 0x00000018, 0x80000015, 0x00000010, 0x0ce7000c, 0x00000008, 0x22000009,
1341 0x00000000, 0x286d0000, 0x0000000f, 0x65680010, 0x00000003, 0xf66c9400,
1342 0x00000010, 0xb972a003, 0x0000000c, 0x73e70019, 0x0000000c, 0x21420004,
1343 0x00000018, 0x80000215, 0x00000010, 0x20530000, 0x00000008, 0x22000008,
1344 0x0000000c, 0x61420004, 0x00000000, 0x37040000, 0x00000000, 0x37850000,
1345 0x00000000, 0x036d0000, 0x00000003, 0xb8f10c00, 0x00000018, 0x80000004,
1346 0x00000000, 0x02840000, 0x00000002, 0x21421800, 0x0000000c, 0x61420000,
1347 0x00000000, 0x286d0000, 0x0000000f, 0x65ed0010, 0x00000009, 0x266dffff,
1348 0x00000000, 0x23000000, 0x00000010, 0xb1840a3d, 0x00000010, 0x01420002,
1349 0x00000004, 0xb8f10a00, 0x00000003, 0x83760a00, 0x00000010, 0xb8040c39,
1350 0x00000010, 0xb7e6080a, 0x00000000, 0x0a640000, 0x00000000, 0x0ae50000,
1351 0x00000009, 0x0c68ffff, 0x00000009, 0x0b67ffff, 0x00000000, 0x0be60000,
1352 0x00000000, 0x0c840000, 0x00000010, 0xb197320c, 0x00000008, 0x0f800002,
1353 0x00000018, 0x8000000a, 0x00000000, 0x0a6a0000, 0x00000000, 0x0aeb0000,
1354 0x00000000, 0x0c000000, 0x00000009, 0x0b6cffff, 0x00000000, 0x0be90000,
1355 0x00000000, 0x0c840000, 0x00000010, 0xb1973203, 0x00000008, 0x0f800002,
1356 0x00000018, 0x80000001, 0x00000010, 0x001f0000, 0x00000000, 0x0c860000,
1357 0x00000000, 0x06980000, 0x00000008, 0x0f800003, 0x00000000, 0x00000000,
1358 0x00000010, 0x009f0000, 0x00000010, 0xb1973210, 0x00000000, 0x231b0000,
1359 0x00000000, 0x02043600, 0x00000003, 0x8384a000, 0x0000000f, 0x65870010,
1360 0x00000009, 0x2607ffff, 0x00000000, 0x27111a00, 0x00000000, 0x66900000,
1361 0x0000000c, 0x29000000, 0x00000018, 0x800001de, 0x00000000, 0x06980000,
1362 0x00000010, 0x20530000, 0x00000000, 0x22c58c00, 0x00000010, 0x001f0000,
1363 0x00000008, 0x0f800003, 0x00000018, 0x8000fff0, 0x00000000, 0x02043600,
1364 0x00000000, 0x231b0000, 0x00000003, 0x8384a000, 0x0000000f, 0x65870010,
1365 0x00000009, 0x2607ffff, 0x00000000, 0x27111a00, 0x00000000, 0x66900000,
1366 0x0000000c, 0x29000000, 0x00000010, 0x91840a02, 0x00000002, 0x21421800,
1367 0x00000000, 0x32140000, 0x00000000, 0x32950000, 0x00000005, 0x73e72c00,
1368 0x00000005, 0x74683000, 0x00000000, 0x33170000, 0x00000018, 0x80000138,
1369 0x00000010, 0x91c60004, 0x00000008, 0x07000004, 0x00000010, 0xb1c41c02,
1370 0x00000010, 0x91840a04, 0x00000018, 0x800001c3, 0x00000010, 0x20530000,
1371 0x00000000, 0x22c58c00, 0x00000010, 0xb1840a8e, 0x0000000c, 0x21420006,
1372 0x00000010, 0x0ce7001a, 0x0000000f, 0x43680010, 0x00000000, 0x03f30c00,
1373 0x00000010, 0x91870850, 0x0000000f, 0x46ec0010, 0x00000010, 0xb68d0c4e,
1374 0x00000000, 0x838d0c00, 0x00000000, 0xa3050800, 0x00000001, 0xa3460e00,
1375 0x00000000, 0x02048c00, 0x00000010, 0x91840a02, 0x00000002, 0x21421800,
1376 0x00000010, 0x001f0000, 0x00000008, 0x22000008, 0x00000003, 0x8384a000,
1377 0x0000000f, 0x65870010, 0x00000009, 0x2607ffff, 0x00000000, 0x27750c00,
1378 0x00000000, 0x66f40000, 0x0000000c, 0x29000000, 0x00000018, 0x800001aa,
1379 0x00000000, 0x03068c00, 0x00000003, 0xf4680c00, 0x00000010, 0x20530000,
1380 0x00000000, 0x22c58c00, 0x00000018, 0x8000ffe5, 0x00000000, 0x39760000,
1381 0x00000000, 0x39840000, 0x0000000c, 0x33e70019, 0x00000010, 0x001f0000,
1382 0x00000000, 0x031e0000, 0x00000000, 0x0760fe00, 0x0000000f, 0x0f0e0007,
1383 0x00000000, 0x83850800, 0x00000000, 0x0a7d0000, 0x00000000, 0x0afe0000,
1384 0x00000000, 0x0b7f0000, 0x00000000, 0x0d7a0000, 0x00000000, 0x0c000000,
1385 0x00000000, 0x0bfc0000, 0x00000000, 0x0c970e00, 0x00000008, 0x0f800003,
1386 0x0000000f, 0x47670010, 0x00000008, 0x070e0001, 0x0000000b, 0xc38000ff,
1387 0x00000002, 0x43870000, 0x00000001, 0x33e70e00, 0x0000000f, 0x038e0010,
1388 0x00000002, 0x33e70e00, 0x00000000, 0x28f30000, 0x00000010, 0x009f0000,
1389 0x00000000, 0x02043600, 0x00000010, 0x91840a02, 0x00000002, 0x21421800,
1390 0x00000008, 0x22000006, 0x00000000, 0x231b0000, 0x00000000, 0x23ff0000,
1391 0x00000000, 0x241b0000, 0x00000003, 0x8384a000, 0x0000000f, 0x65870010,
1392 0x00000009, 0x2607ffff, 0x00000000, 0x27110000, 0x00000000, 0x26900000,
1393 0x0000000c, 0x29000000, 0x00000018, 0x8000017e, 0x00000003, 0xf4683600,
1394 0x00000000, 0x3a100000, 0x00000000, 0x3a910000, 0x00000003, 0xf66c2400,
1395 0x00000010, 0x001f0000, 0x00000010, 0xb1923604, 0x00000008, 0x0f800004,
1396 0x00000000, 0x00000000, 0x00000010, 0x009f0000, 0x00000000, 0x3e170000,
1397 0x00000000, 0x3e940000, 0x00000000, 0x3f150000, 0x00000000, 0x3f960000,
1398 0x00000010, 0x001f0000, 0x00000000, 0x0f060000, 0x00000010, 0x20530000,
1399 0x00000000, 0x22c53600, 0x00000018, 0x8000ffac, 0x00000010, 0x001f0000,
1400 0x00000000, 0x031e0000, 0x00000000, 0x83850800, 0x00000009, 0x076000ff,
1401 0x0000000f, 0x0f0e0007, 0x00000000, 0x0c000000, 0x00000000, 0x0a7d0000,
1402 0x00000000, 0x0afe0000, 0x00000000, 0x0b7f0000, 0x00000000, 0x0d7a0000,
1403 0x00000000, 0x0bfc0000, 0x00000000, 0x0c970e00, 0x00000008, 0x0f800003,
1404 0x0000000f, 0x47670010, 0x00000008, 0x070e0001, 0x0000000b, 0xc38000ff,
1405 0x00000002, 0x43870000, 0x00000001, 0x33e70e00, 0x0000000f, 0x038e0010,
1406 0x00000002, 0x33e70e00, 0x00000000, 0x39840000, 0x00000003, 0xb9720800,
1407 0x00000000, 0x28f30000, 0x0000000f, 0x65680010, 0x00000010, 0x009f0000,
1408 0x00000000, 0x02043600, 0x00000010, 0x91840a02, 0x00000002, 0x21421800,
1409 0x00000008, 0x22000007, 0x00000000, 0x231b0000, 0x00000000, 0x23ff0000,
1410 0x00000000, 0x241b0000, 0x00000003, 0x8384a000, 0x0000000f, 0x65870010,
1411 0x00000009, 0x2607ffff, 0x00000000, 0x27110000, 0x00000000, 0x26900000,
1412 0x0000000c, 0x29000000, 0x00000018, 0x80000145, 0x00000003, 0xf4683600,
1413 0x00000000, 0x3a100000, 0x00000000, 0x3a910000, 0x00000003, 0xf66c2400,
1414 0x00000010, 0x001f0000, 0x00000010, 0xb1923604, 0x00000008, 0x0f800004,
1415 0x00000000, 0x00000000, 0x00000010, 0x009f0000, 0x00000000, 0x3e170000,
1416 0x00000000, 0x3e940000, 0x00000000, 0x3f150000, 0x00000000, 0x3f960000,
1417 0x00000010, 0x001f0000, 0x00000000, 0x0f060000, 0x00000010, 0x20530000,
1418 0x00000000, 0x22c53600, 0x00000018, 0x8000ff73, 0x00000010, 0x0ce70005,
1419 0x00000008, 0x2c80000c, 0x00000008, 0x2d000070, 0x00000008, 0x2d800010,
1420 0x00000000, 0x00000000, 0x00000010, 0x205f0000, 0x00000018, 0x8000011d,
1421 0x00000000, 0x2c1e0000, 0x00000008, 0x2c8000b8, 0x00000008, 0x2d000010,
1422 0x00000008, 0x2d800048, 0x00000000, 0x00000000, 0x00000010, 0x91de0000,
1423 0x00000018, 0x8000fe5d, 0x0000000c, 0x29800001, 0x00000000, 0x2a000000,
1424 0x00000010, 0x001f0000, 0x00000000, 0x0f008000, 0x00000008, 0x0f800007,
1425 0x00000018, 0x80000006, 0x0000000c, 0x29800001, 0x00000000, 0x2a000000,
1426 0x00000010, 0x001f0000, 0x0000000f, 0x0f470007, 0x00000008, 0x0f800008,
1427 0x00000018, 0x80000119, 0x00000010, 0x20530000, 0x00000018, 0x8000fe4f,
1428 0x0000000c, 0x29800001, 0x00000010, 0x91de0000, 0x00000000, 0x2fd50000,
1429 0x00000000, 0x2a000000, 0x00000009, 0x0261ffff, 0x0000000d, 0x70e10001,
1430 0x00000018, 0x80000101, 0x00000000, 0x2c400000, 0x00000008, 0x2c8000c4,
1431 0x00000008, 0x2d00001c, 0x00000008, 0x2d800001, 0x00000005, 0x70e10800,
1432 0x00000010, 0x91de0000, 0x00000018, 0x8000fe41, 0x0000000c, 0x29800001,
1433 0x00000010, 0x91de0000, 0x00000000, 0x2fd50000, 0x00000010, 0x001f0000,
1434 0x00000000, 0x02700000, 0x00000000, 0x0d620000, 0x00000000, 0xbb630800,
1435 0x00000000, 0x2a000000, 0x00000000, 0x0f400000, 0x00000000, 0x2c400000,
1436 0x0000000c, 0x73e7001b, 0x00000010, 0x0ce7000e, 0x00000000, 0x286d0000,
1437 0x0000000f, 0x65ed0010, 0x00000009, 0x266dffff, 0x00000018, 0x80000069,
1438 0x00000008, 0x02000004, 0x00000010, 0x91c40803, 0x00000018, 0x800000f6,
1439 0x00000010, 0x20530000, 0x00000018, 0x800000e5, 0x00000008, 0x2c8000b8,
1440 0x00000008, 0x2d000010, 0x00000008, 0x2d800048, 0x00000018, 0x80000005,
1441 0x00000008, 0x2c8000c4, 0x00000008, 0x2d00001c, 0x00000008, 0x2d800001,
1442 0x00000000, 0x00000000, 0x00000010, 0x205f0000, 0x00000008, 0x2c800048,
1443 0x00000008, 0x2d000068, 0x00000008, 0x2d800104, 0x00000000, 0x00000000,
1444 0x00000010, 0x91de0000, 0x00000000, 0x27f60000, 0x00000010, 0xb87a9e04,
1445 0x00000008, 0x2200000d, 0x00000018, 0x800000e2, 0x00000010, 0x20530000,
1446 0x00000018, 0x8000fe18, 0x0000000c, 0x29800001, 0x00000010, 0x91de0000,
1447 0x00000000, 0x2fd50000, 0x00000010, 0x001f0000, 0x00000000, 0x02700000,
1448 0x00000000, 0x0d620000, 0x00000000, 0xbb630800, 0x00000000, 0x2a000000,
1449 0x00000010, 0x0e670011, 0x00000000, 0x286d0000, 0x0000000f, 0x65ed0010,
1450 0x00000009, 0x266dffff, 0x00000004, 0xb8f1a000, 0x00000000, 0x0f400000,
1451 0x0000000c, 0x73e7001c, 0x00000018, 0x80000040, 0x00000008, 0x02000004,
1452 0x00000010, 0x91c40802, 0x00000018, 0x800000cd, 0x00000000, 0x2c1e0000,
1453 0x00000008, 0x2c8000b8, 0x00000008, 0x2d000010, 0x00000008, 0x2d800048,
1454 0x00000010, 0x20530000, 0x00000010, 0x91de0000, 0x00000018, 0x8000fdfe,
1455 0x0000000c, 0x29800001, 0x00000000, 0x03550000, 0x00000000, 0x06460000,
1456 0x00000000, 0x03d60000, 0x00000000, 0x2a000000, 0x0000000f, 0x0f480007,
1457 0x00000010, 0xb18c0027, 0x0000000f, 0x47420008, 0x00000009, 0x070e000f,
1458 0x00000008, 0x070e0008, 0x00000010, 0x001f0000, 0x00000008, 0x09000001,
1459 0x00000007, 0x09121c00, 0x00000003, 0xcbca9200, 0x00000000, 0x0b97a200,
1460 0x00000007, 0x4b171c00, 0x0000000f, 0x0a960003, 0x00000000, 0x0a959c00,
1461 0x00000000, 0x4a009a00, 0x00000008, 0x82120001, 0x00000001, 0x0c170800,
1462 0x00000000, 0x02180000, 0x00000000, 0x0c971800, 0x00000008, 0x0d00ffff,
1463 0x00000008, 0x0f800006, 0x0000000c, 0x29000000, 0x00000008, 0x22000001,
1464 0x00000000, 0x22c50c00, 0x00000010, 0x009f0000, 0x00000010, 0xb197320b,
1465 0x00000000, 0x231b0000, 0x00000000, 0x27110800, 0x00000000, 0x66900000,
1466 0x00000018, 0x800000a4, 0x00000000, 0x02180000, 0x00000010, 0x20530000,
1467 0x00000000, 0x22c53600, 0x00000010, 0x001f0000, 0x00000008, 0x0f800006,
1468 0x00000018, 0x8000fff5, 0x00000010, 0x91870002, 0x00000008, 0x2200000a,
1469 0x00000000, 0x231b0000, 0x00000000, 0x27110800, 0x00000000, 0x66900000,
1470 0x00000018, 0x80000098, 0x00000008, 0x0200000a, 0x00000010, 0x91c40804,
1471 0x00000010, 0x02c20003, 0x00000010, 0x001f0000, 0x00000008, 0x0f800008,
1472 0x00000010, 0x20530000, 0x00000018, 0x8000fdc9, 0x00000000, 0x06820000,
1473 0x00000010, 0x001f0000, 0x00000010, 0x0ce70028, 0x00000000, 0x03720000,
1474 0x00000000, 0xa8760c00, 0x00000000, 0x0cf60000, 0x00000010, 0xb8723224,
1475 0x00000000, 0x03440000, 0x00000008, 0x22000010, 0x00000000, 0x03ca0000,
1476 0x0000000f, 0x65680010, 0x00000000, 0x0bcf0000, 0x00000000, 0x27f20000,
1477 0x00000010, 0xb7ef3203, 0x0000000c, 0x21420004, 0x0000000c, 0x73e70019,
1478 0x00000000, 0x07520000, 0x00000000, 0x29000000, 0x00000018, 0x8000007e,
1479 0x00000004, 0xb9723200, 0x00000010, 0x20530000, 0x00000000, 0x22060000,
1480 0x0000000c, 0x61420004, 0x00000000, 0x25070000, 0x00000000, 0x27970000,
1481 0x00000000, 0x290e0000, 0x00000010, 0x0ce70010, 0x00000010, 0xb873320f,
1482 0x0000000f, 0x436c0010, 0x00000000, 0x03f30c00, 0x00000000, 0x03f30000,
1483 0x00000000, 0x83990e00, 0x00000001, 0x83860e00, 0x00000000, 0x83060e00,
1484 0x00000003, 0xf66c0c00, 0x00000000, 0x39f30e00, 0x00000000, 0x3af50e00,
1485 0x00000000, 0x7a740000, 0x0000000f, 0x43680010, 0x00000001, 0x83860e00,
1486 0x00000000, 0x83060e00, 0x00000003, 0xf4680c00, 0x00000000, 0x286d0000,
1487 0x00000000, 0x03690000, 0x00000010, 0xb1f60c54, 0x00000000, 0x0a6a0000,
1488 0x00000000, 0x0aeb0000, 0x00000009, 0x0b6cffff, 0x00000000, 0x0c000000,
1489 0x00000000, 0x0be90000, 0x00000003, 0x8cf6a000, 0x0000000c, 0x09800002,
1490 0x00000010, 0x009f0000, 0x00000010, 0xb8173209, 0x00000000, 0x35140000,
1491 0x00000000, 0x35950000, 0x00000005, 0x766c2c00, 0x00000000, 0x34970000,
1492 0x00000004, 0xb8f12e00, 0x00000010, 0x001f0000, 0x00000008, 0x0f800004,
1493 0x00000018, 0x8000fff7, 0x00000000, 0x03e90000, 0x00000010, 0xb8f6a01a,
1494 0x00000010, 0x20130019, 0x00000010, 0xb1f10e18, 0x00000000, 0x83973200,
1495 0x00000000, 0x38700e00, 0x00000000, 0xbb760e00, 0x00000000, 0x37d00000,
1496 0x0000000c, 0x73e7001a, 0x00000003, 0xb8f1a000, 0x00000000, 0x32140000,
1497 0x00000000, 0x32950000, 0x00000005, 0x73e72c00, 0x00000000, 0x33190000,
1498 0x00000005, 0x74680000, 0x00000010, 0x0ce7000d, 0x00000008, 0x22000009,
1499 0x00000000, 0x07520000, 0x00000000, 0x29000000, 0x0000000c, 0x73e70019,
1500 0x0000000f, 0x65680010, 0x0000000c, 0x21420004, 0x00000018, 0x8000003c,
1501 0x00000010, 0x20530000, 0x0000000c, 0x61420004, 0x00000000, 0x290e0000,
1502 0x00000018, 0x80000002, 0x00000010, 0x91973206, 0x00000000, 0x35140000,
1503 0x00000000, 0x35950000, 0x00000005, 0x766c2c00, 0x00000000, 0x34990000,
1504 0x00000004, 0xb8f13200, 0x00000000, 0x83690c00, 0x00000010, 0xb1860013,
1505 0x00000000, 0x28e90000, 0x00000008, 0x22000004, 0x00000000, 0x23ec0000,
1506 0x00000000, 0x03690000, 0x00000010, 0xb8660c07, 0x00000009, 0x036cffff,
1507 0x00000000, 0x326a0000, 0x00000000, 0x32eb0000, 0x00000005, 0x73e70c00,
1508 0x00000000, 0x33690000, 0x00000005, 0x74680000, 0x0000000c, 0x73e7001c,
1509 0x00000000, 0x03690000, 0x00000010, 0xb1f60c12, 0x00000010, 0xb1d00c11,
1510 0x0000000c, 0x21420005, 0x0000000c, 0x33e7001c, 0x00000018, 0x8000000e,
1511 0x00000010, 0x2e67000d, 0x00000000, 0x03690000, 0x00000010, 0xb1f60c0b,
1512 0x00000010, 0xb1d00c0a, 0x00000000, 0x03440000, 0x00000008, 0x2200000c,
1513 0x00000000, 0x07520000, 0x00000000, 0x29000000, 0x00000018, 0x80000015,
1514 0x0000000c, 0x33e7001c, 0x00000010, 0x20530000, 0x00000000, 0x22060000,
1515 0x00000000, 0x290e0000, 0x00000018, 0x000d0000, 0x00000000, 0x06820000,
1516 0x00000010, 0x2de7000d, 0x00000010, 0x0ce7000c, 0x00000000, 0x27f20000,
1517 0x00000010, 0xb96d9e0a, 0x00000000, 0xa86d9e00, 0x00000009, 0x0361ffff,
1518 0x00000010, 0xb7500c07, 0x00000008, 0x2200000f, 0x0000000f, 0x65680010,
1519 0x00000000, 0x29000000, 0x00000018, 0x80000004, 0x0000000c, 0x33e7001b,
1520 0x00000010, 0x20530000, 0x00000018, 0x000d0000, 0x00000000, 0x2b820000,
1521 0x00000010, 0x20d2002f, 0x00000010, 0x0052002e, 0x00000009, 0x054e0007,
1522 0x00000010, 0xb18a002c, 0x00000000, 0x050a8c00, 0x00000008, 0x850a0008,
1523 0x00000010, 0x918a0029, 0x00000003, 0xc5008800, 0x00000008, 0xa3460001,
1524 0x00000010, 0xb1c60007, 0x00000008, 0x22000001, 0x0000000c, 0x29800000,
1525 0x00000010, 0x20530000, 0x00000000, 0x274e8c00, 0x00000000, 0x66cd0000,
1526 0x00000000, 0x22c58c00, 0x00000008, 0x22000014, 0x00000003, 0x22c58e00,
1527 0x00000003, 0x23c58e00, 0x00000003, 0x22c58e00, 0x00000003, 0x26cd9e00,
1528 0x00000003, 0x27cd9e00, 0x00000003, 0x26cd9e00, 0x00000003, 0x274ea000,
1529 0x00000003, 0x284ea000, 0x00000003, 0x274ea000, 0x0000000c, 0x69520000,
1530 0x0000000c, 0x29800000, 0x00000010, 0x20530000, 0x00000003, 0x22c58e00,
1531 0x00000003, 0x23c58e00, 0x00000003, 0x22c58e00, 0x00000003, 0x26cd9e00,
1532 0x00000003, 0x27cd9e00, 0x00000003, 0x26cd9e00, 0x00000003, 0x274ea000,
1533 0x00000003, 0x284ea000, 0x00000003, 0x274ea000, 0x00000000, 0xa2c58c00,
1534 0x00000000, 0xa74e8c00, 0x00000000, 0xe6cd0000, 0x0000000f, 0x620a0010,
1535 0x00000008, 0x23460001, 0x0000000c, 0x29800000, 0x00000010, 0x20530000,
1536 0x0000000c, 0x29520000, 0x00000018, 0x80000002, 0x0000000c, 0x29800000,
1537 0x00000018, 0x00570000 };
1538
1539static int bnx2_TPAT_b06FwReleaseMajor = 0x0;
1540static int bnx2_TPAT_b06FwReleaseMinor = 0x0;
1541static int bnx2_TPAT_b06FwReleaseFix = 0x0;
1542static u32 bnx2_TPAT_b06FwStartAddr = 0x08000858;
1543static u32 bnx2_TPAT_b06FwTextAddr = 0x08000800;
1544static int bnx2_TPAT_b06FwTextLen = 0x1314;
1545static u32 bnx2_TPAT_b06FwDataAddr = 0x08001b40;
1546static int bnx2_TPAT_b06FwDataLen = 0x0;
1547static u32 bnx2_TPAT_b06FwRodataAddr = 0x00000000;
1548static int bnx2_TPAT_b06FwRodataLen = 0x0;
1549static u32 bnx2_TPAT_b06FwBssAddr = 0x08001b90;
1550static int bnx2_TPAT_b06FwBssLen = 0x80;
1551static u32 bnx2_TPAT_b06FwSbssAddr = 0x08001b40;
1552static int bnx2_TPAT_b06FwSbssLen = 0x48;
1553
1554static u32 bnx2_TPAT_b06FwText[(0x1314/4) + 1] = {
1555 0x0a000216, 0x00000000, 0x00000000, 0x0000000d, 0x74706174, 0x20302e36,
1556 0x2e390000, 0x00060901, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1557 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1558 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000003,
1559 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800, 0x24421b40, 0x3c030800,
1560 0x24631c10, 0xac400000, 0x0043202b, 0x1480fffd, 0x24420004, 0x3c1d0800,
1561 0x37bd3ffc, 0x03a0f021, 0x3c100800, 0x26100858, 0x3c1c0800, 0x279c1b40,
1562 0x0e00051f, 0x00000000, 0x0000000d, 0x8f820024, 0x27bdffe8, 0xafbf0014,
1563 0x10400004, 0xafb00010, 0x0000000d, 0x00000000, 0x2400015f, 0x8f82001c,
1564 0x8c450008, 0x24030800, 0xaf430178, 0x97430104, 0x3c020008, 0xaf420140,
1565 0x8f820034, 0x30420001, 0x10400006, 0x3070ffff, 0x24020002, 0x2603fffe,
1566 0xa7420146, 0x0a000246, 0xa7430148, 0xa7400146, 0x8f850034, 0x30a20020,
1567 0x0002102b, 0x00021023, 0x30460009, 0x30a30c00, 0x24020400, 0x14620002,
1568 0x34c40001, 0x34c40005, 0xa744014a, 0x3c020800, 0x8c440820, 0x3c030048,
1569 0x24020002, 0x00832025, 0x30a30006, 0x1062000d, 0x2c620003, 0x50400005,
1570 0x24020004, 0x10600012, 0x3c020001, 0x0a000271, 0x00000000, 0x10620007,
1571 0x24020006, 0x1462000f, 0x3c020111, 0x0a000269, 0x00821025, 0x0a000268,
1572 0x3c020101, 0x3c020011, 0x00821025, 0x24030001, 0xaf421000, 0xaf830030,
1573 0x0a000271, 0x00000000, 0x00821025, 0xaf421000, 0xaf800030, 0x00000000,
1574 0x00000000, 0x00000000, 0x00000000, 0x8f830030, 0x1060003f, 0x3c048000,
1575 0x8f421000, 0x00441024, 0x1040fffd, 0x00000000, 0x10600039, 0x00000000,
1576 0x8f421000, 0x3c030020, 0x00431024, 0x10400034, 0x00000000, 0x97421014,
1577 0x14400031, 0x00000000, 0x97421008, 0x8f84001c, 0x24420006, 0x00024082,
1578 0x00081880, 0x00643821, 0x8ce50000, 0x30430003, 0x30420001, 0x10400004,
1579 0x00000000, 0x0000000d, 0x0a0002b0, 0x00081080, 0x5460000f, 0x30a5ffff,
1580 0x3c06ffff, 0x00a62824, 0x0005182b, 0x00a61026, 0x0002102b, 0x00621824,
1581 0x10600004, 0x00000000, 0x0000000d, 0x00000000, 0x240001fc, 0x8ce20000,
1582 0x0a0002af, 0x00462825, 0x0005182b, 0x38a2ffff, 0x0002102b, 0x00621824,
1583 0x10600004, 0x00000000, 0x0000000d, 0x00000000, 0x24000206, 0x8ce20000,
1584 0x3445ffff, 0x00081080, 0x00441021, 0x3c030800, 0xac450000, 0x8c620840,
1585 0x24420001, 0xac620840, 0x8f820008, 0x10400003, 0x00000000, 0x0e000660,
1586 0x00000000, 0x8f840028, 0x02002821, 0x24820008, 0x30421fff, 0x24434000,
1587 0x0343d821, 0x30a30007, 0xaf840018, 0xaf820028, 0xaf420084, 0x10600002,
1588 0x24a20007, 0x3045fff8, 0x8f820044, 0x8f840004, 0x00451821, 0xaf82002c,
1589 0x0064102b, 0xaf830044, 0x14400002, 0x00641023, 0xaf820044, 0x8f840044,
1590 0x34028000, 0x8fbf0014, 0x8fb00010, 0x00821021, 0x03421821, 0x3c021000,
1591 0xaf83001c, 0xaf440080, 0xaf420178, 0x03e00008, 0x27bd0018, 0x8f820024,
1592 0x27bdffe8, 0xafbf0014, 0x10400004, 0xafb00010, 0x0000000d, 0x00000000,
1593 0x24000249, 0x8f85001c, 0x24020001, 0xaf820024, 0x8ca70008, 0xa3800023,
1594 0x8f620004, 0x3c100800, 0x26041b90, 0x00021402, 0xa3820010, 0x304600ff,
1595 0x24c60005, 0x0e00064a, 0x00063082, 0x8f640004, 0x8f430108, 0x3c021000,
1596 0x00621824, 0xa7840020, 0x10600008, 0x00000000, 0x97420104, 0x93830023,
1597 0x2442ffec, 0x34630002, 0xa3830023, 0x0a000304, 0x3045ffff, 0x97420104,
1598 0x2442fff0, 0x3045ffff, 0x8f620004, 0x3042ffff, 0x2c420013, 0x14400004,
1599 0x00000000, 0x93820023, 0x34420001, 0xa3820023, 0x93830023, 0x24020001,
1600 0x10620009, 0x28620002, 0x14400014, 0x24020002, 0x10620012, 0x24020003,
1601 0x1062000a, 0x00000000, 0x0a000325, 0x00000000, 0x8f82001c, 0x8c43000c,
1602 0x3c04ffff, 0x00641824, 0x00651825, 0x0a000325, 0xac43000c, 0x8f82001c,
1603 0x8c430010, 0x3c04ffff, 0x00641824, 0x00651825, 0xac430010, 0x8f620004,
1604 0x3042ffff, 0x24420002, 0x00021083, 0xa3820038, 0x304500ff, 0x8f82001c,
1605 0x3c04ffff, 0x00052880, 0x00a22821, 0x8ca70000, 0x97820020, 0x97430104,
1606 0x00e42024, 0x24420002, 0x00621823, 0x00833825, 0xaca70000, 0x93840038,
1607 0x26061b90, 0x00041080, 0x00461021, 0x90430000, 0x3063000f, 0x00832021,
1608 0xa3840022, 0x308200ff, 0x3c04fff6, 0x24420003, 0x00021080, 0x00461021,
1609 0x8c450000, 0x93830022, 0x8f82001c, 0x3484ffff, 0x00a43824, 0x00031880,
1610 0x00621821, 0xaf850000, 0xac67000c, 0x93820022, 0x93830022, 0x8f84001c,
1611 0x24420003, 0x00021080, 0x00461021, 0x24630004, 0x00031880, 0xac470000,
1612 0x93820022, 0x00661821, 0x94670002, 0x00021080, 0x00441021, 0xac670000,
1613 0x24030010, 0xac470010, 0xa7430140, 0x24030002, 0xa7400142, 0xa7400144,
1614 0xa7430146, 0x97420104, 0x8f840034, 0x24030001, 0x2442fffe, 0x30840006,
1615 0xa7420148, 0x24020002, 0xa743014a, 0x1082000d, 0x2c820003, 0x10400005,
1616 0x24020004, 0x10800011, 0x3c020009, 0x0a000383, 0x00000000, 0x10820007,
1617 0x24020006, 0x1482000d, 0x3c020119, 0x0a00037d, 0x24030001, 0x0a00037c,
1618 0x3c020109, 0x3c020019, 0x24030001, 0xaf421000, 0xaf830030, 0x0a000383,
1619 0x00000000, 0xaf421000, 0xaf800030, 0x00000000, 0x00000000, 0x00000000,
1620 0x00000000, 0x93820010, 0x24030008, 0x8f840030, 0x24420002, 0x30420007,
1621 0x00621823, 0x30630007, 0xaf83000c, 0x10800005, 0x3c038000, 0x8f421000,
1622 0x00431024, 0x1040fffd, 0x00000000, 0x8f820028, 0xaf820018, 0x24420010,
1623 0x30421fff, 0xaf820028, 0xaf420084, 0x97430104, 0x24424000, 0x0342d821,
1624 0x3063ffff, 0x30620007, 0x10400002, 0x24620007, 0x3043fff8, 0x8f820044,
1625 0x8f840004, 0x00431821, 0xaf82002c, 0x0064102b, 0xaf830044, 0x14400002,
1626 0x00641023, 0xaf820044, 0x8f840044, 0x34028000, 0x8fbf0014, 0x8fb00010,
1627 0x00821021, 0x03421821, 0x3c021000, 0xaf83001c, 0xaf440080, 0xaf420178,
1628 0x03e00008, 0x27bd0018, 0x8f820024, 0x27bdffe8, 0xafbf0014, 0x14400004,
1629 0xafb00010, 0x0000000d, 0x00000000, 0x240002db, 0x8f620004, 0x04410009,
1630 0x3c050800, 0x93820022, 0x8f830000, 0x24a41b90, 0xaf800024, 0x24420003,
1631 0x00021080, 0x00441021, 0xac430000, 0x93820038, 0x24a51b90, 0x93860010,
1632 0x3c040001, 0x27700008, 0x24420001, 0x00021080, 0x00451021, 0x8c430000,
1633 0x24c60005, 0x00063082, 0x00641821, 0x02002021, 0x0e00064a, 0xac430000,
1634 0x93840022, 0x3c057fff, 0x8f620004, 0x00042080, 0x00902021, 0x8c830004,
1635 0x34a5ffff, 0x00451024, 0x00621821, 0xac830004, 0x93850038, 0x3c07ffff,
1636 0x93840010, 0x00052880, 0x00b02821, 0x8ca30000, 0x97420104, 0x97860020,
1637 0x00671824, 0x00441021, 0x00461023, 0x3042ffff, 0x00621825, 0xaca30000,
1638 0x93830023, 0x24020001, 0x10620009, 0x28620002, 0x1440001a, 0x24020002,
1639 0x10620018, 0x24020003, 0x1062000d, 0x00000000, 0x0a000411, 0x00000000,
1640 0x93820010, 0x97430104, 0x8e04000c, 0x00621821, 0x2463fff2, 0x3063ffff,
1641 0x00872024, 0x00832025, 0x0a000411, 0xae04000c, 0x93820010, 0x97430104,
1642 0x8e040010, 0x00621821, 0x2463ffee, 0x3063ffff, 0x00872024, 0x00832025,
1643 0xae040010, 0x9783000e, 0x8f840034, 0x2402000a, 0xa7420140, 0xa7430142,
1644 0x93820010, 0xa7420144, 0xa7400146, 0x97430104, 0x30840006, 0x24020001,
1645 0xa7430148, 0xa742014a, 0x24020002, 0x1082000d, 0x2c820003, 0x10400005,
1646 0x24020004, 0x10800011, 0x3c020041, 0x0a000437, 0x00000000, 0x10820007,
1647 0x24020006, 0x1482000d, 0x3c020151, 0x0a000431, 0x24030001, 0x0a000430,
1648 0x3c020141, 0x3c020051, 0x24030001, 0xaf421000, 0xaf830030, 0x0a000437,
1649 0x00000000, 0xaf421000, 0xaf800030, 0x00000000, 0x00000000, 0x00000000,
1650 0x00000000, 0x8f820030, 0x93840010, 0x8f850028, 0x10400005, 0x3c038000,
1651 0x8f421000, 0x00431024, 0x1040fffd, 0x00000000, 0x2483000a, 0x30620007,
1652 0x10400002, 0x24620007, 0x304303f8, 0x00a31021, 0x30421fff, 0xaf850018,
1653 0xaf820028, 0xaf420084, 0x97430104, 0x24424000, 0x0342d821, 0x3063ffff,
1654 0x30620007, 0x10400002, 0x24620007, 0x3043fff8, 0x8f820044, 0x8f840004,
1655 0x00431821, 0xaf82002c, 0x0064102b, 0xaf830044, 0x14400002, 0x00641023,
1656 0xaf820044, 0x8f840044, 0x34028000, 0x8fbf0014, 0x8fb00010, 0x00821021,
1657 0x03421821, 0x3c021000, 0xaf83001c, 0xaf440080, 0xaf420178, 0x03e00008,
1658 0x27bd0018, 0x3c026000, 0x8c444448, 0x3c030800, 0xac64082c, 0x8f620000,
1659 0x97430104, 0x3c048000, 0x3046ffff, 0x3067ffff, 0x8f420178, 0x00441024,
1660 0x1440fffd, 0x2402000a, 0x30c30007, 0xa7420140, 0x24020008, 0x00431023,
1661 0x30420007, 0x24c3fffe, 0xa7420142, 0xa7430144, 0xa7400146, 0xa7470148,
1662 0x8f420108, 0x3c036000, 0x8f850034, 0x30420020, 0x0002102b, 0x00021023,
1663 0x30420009, 0x34420001, 0xa742014a, 0x8c644448, 0x3c020800, 0x30a50006,
1664 0xac440830, 0x24020002, 0x10a2000d, 0x2ca20003, 0x10400005, 0x24020004,
1665 0x10a00011, 0x3c020041, 0x0a0004a8, 0x00000000, 0x10a20007, 0x24020006,
1666 0x14a2000d, 0x3c020151, 0x0a0004a2, 0x24030001, 0x0a0004a1, 0x3c020141,
1667 0x3c020051, 0x24030001, 0xaf421000, 0xaf830030, 0x0a0004a8, 0x00000000,
1668 0xaf421000, 0xaf800030, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1669 0x8f820030, 0x24c30008, 0x10400006, 0x30e6ffff, 0x3c048000, 0x8f421000,
1670 0x00441024, 0x1040fffd, 0x00000000, 0x3c026000, 0x8c444448, 0x3065ffff,
1671 0x3c020800, 0x30a30007, 0x10600003, 0xac440834, 0x24a20007, 0x3045fff8,
1672 0x8f840028, 0x00851021, 0x30421fff, 0x24434000, 0x0343d821, 0x30c30007,
1673 0xaf840018, 0xaf820028, 0xaf420084, 0x10600002, 0x24c20007, 0x3046fff8,
1674 0x8f820044, 0x8f840004, 0x00461821, 0xaf82002c, 0x0064102b, 0xaf830044,
1675 0x14400002, 0x00641023, 0xaf820044, 0x8f840044, 0x34028000, 0x3c030800,
1676 0x8c650844, 0x00821021, 0x03421821, 0xaf83001c, 0xaf440080, 0x10a00006,
1677 0x2402000e, 0x93830043, 0x14620004, 0x3c021000, 0x2402043f, 0xa7420148,
1678 0x3c021000, 0x3c036000, 0xaf420178, 0x8c644448, 0x3c020800, 0x03e00008,
1679 0xac440838, 0x8f820034, 0x30424000, 0x10400005, 0x24020800, 0x0000000d,
1680 0x00000000, 0x24000405, 0x24020800, 0xaf420178, 0x97440104, 0x3c030008,
1681 0xaf430140, 0x8f820034, 0x30420001, 0x10400006, 0x3085ffff, 0x24020002,
1682 0x24a3fffe, 0xa7420146, 0x0a0004ff, 0xa7430148, 0xa7400146, 0x8f840028,
1683 0x2402000d, 0xa742014a, 0x24830008, 0x30631fff, 0x24624000, 0x0342d821,
1684 0x30a20007, 0xaf840018, 0xaf830028, 0xaf430084, 0x10400002, 0x24a20007,
1685 0x3045fff8, 0x8f820044, 0x8f840004, 0x00451821, 0xaf82002c, 0x0064102b,
1686 0xaf830044, 0x14400002, 0x00641023, 0xaf820044, 0x8f840044, 0x34028000,
1687 0x00821021, 0x03421821, 0x3c021000, 0xaf83001c, 0xaf440080, 0x03e00008,
1688 0xaf420178, 0x27bdffe8, 0x3c046008, 0xafbf0014, 0xafb00010, 0x8c825000,
1689 0x3c1a8000, 0x2403ff7f, 0x375b4000, 0x00431024, 0x3442380c, 0xac825000,
1690 0x8f430008, 0x3c100800, 0x37428000, 0x34630001, 0xaf430008, 0xaf82001c,
1691 0x3c02601c, 0xaf800028, 0xaf400080, 0xaf400084, 0x8c450008, 0x3c036000,
1692 0x8c620808, 0x3c040800, 0x3c030080, 0xac830820, 0x3042fff0, 0x38420010,
1693 0x2c420001, 0xaf850004, 0xaf820008, 0x0e00062f, 0x00000000, 0x8f420000,
1694 0x30420001, 0x1040fffb, 0x00000000, 0x8f440108, 0x30822000, 0xaf840034,
1695 0x10400004, 0x8e02083c, 0x24420001, 0x0a00059d, 0xae02083c, 0x30820200,
1696 0x10400027, 0x00000000, 0x97420104, 0x1040001c, 0x30824000, 0x14400005,
1697 0x00000000, 0x0e00022d, 0x00000000, 0x0a000592, 0x00000000, 0x8f620008,
1698 0x8f630000, 0x24020030, 0x00031e02, 0x306300f0, 0x10620007, 0x28620031,
1699 0x14400031, 0x24020040, 0x10620007, 0x00000000, 0x0a000592, 0x00000000,
1700 0x0e0002dd, 0x00000000, 0x0a000592, 0x00000000, 0x0e0003b8, 0x00000000,
1701 0x0a000592, 0x00000000, 0x30820040, 0x1440002d, 0x00000000, 0x0000000d,
1702 0x00000000, 0x240004a6, 0x0a00059d, 0x00000000, 0x8f430100, 0x24020d00,
1703 0x1462000f, 0x30820006, 0x97420104, 0x10400005, 0x30820040, 0x0e0004e9,
1704 0x00000000, 0x0a000592, 0x00000000, 0x1440001b, 0x00000000, 0x0000000d,
1705 0x00000000, 0x240004b8, 0x0a00059d, 0x00000000, 0x1040000e, 0x30821000,
1706 0x10400005, 0x00000000, 0x0e00065d, 0x00000000, 0x0a000592, 0x00000000,
1707 0x0e00046b, 0x00000000, 0x8f820040, 0x24420001, 0xaf820040, 0x0a00059d,
1708 0x00000000, 0x30820040, 0x14400004, 0x00000000, 0x0000000d, 0x00000000,
1709 0x240004cf, 0x8f420138, 0x3c034000, 0x00431025, 0xaf420138, 0x0a00053f,
1710 0x00000000, 0x3c046008, 0x8c835000, 0x3c1a8000, 0x2402ff7f, 0x375b4000,
1711 0x00621824, 0x3463380c, 0xac835000, 0x8f420008, 0x3c056000, 0x3c03601c,
1712 0x34420001, 0xaf420008, 0x37428000, 0xaf800028, 0xaf82001c, 0xaf400080,
1713 0xaf400084, 0x8c660008, 0x8ca20808, 0x3c040800, 0x3c030080, 0xac830820,
1714 0x3042fff0, 0x38420010, 0x2c420001, 0xaf860004, 0xaf820008, 0x03e00008,
1715 0x00000000, 0x3084ffff, 0x30820007, 0x10400002, 0x24820007, 0x3044fff8,
1716 0x8f820028, 0x00441821, 0x30631fff, 0x24644000, 0x0344d821, 0xaf820018,
1717 0xaf830028, 0x03e00008, 0xaf430084, 0x3084ffff, 0x30820007, 0x10400002,
1718 0x24820007, 0x3044fff8, 0x8f820044, 0x8f830004, 0x00442021, 0xaf82002c,
1719 0x0083102b, 0xaf840044, 0x14400002, 0x00831023, 0xaf820044, 0x8f820044,
1720 0x34038000, 0x00431821, 0x03432021, 0xaf84001c, 0x03e00008, 0xaf420080,
1721 0x8f830034, 0x24020002, 0x30630006, 0x1062000d, 0x2c620003, 0x50400005,
1722 0x24020004, 0x10600012, 0x3c020001, 0x0a000601, 0x00000000, 0x10620007,
1723 0x24020006, 0x1462000f, 0x3c020111, 0x0a0005f9, 0x00821025, 0x0a0005f8,
1724 0x3c020101, 0x3c020011, 0x00821025, 0x24030001, 0xaf421000, 0xaf830030,
1725 0x0a000601, 0x00000000, 0x00821025, 0xaf421000, 0xaf800030, 0x00000000,
1726 0x00000000, 0x00000000, 0x03e00008, 0x00000000, 0x8f820030, 0x10400005,
1727 0x3c038000, 0x8f421000, 0x00431024, 0x1040fffd, 0x00000000, 0x03e00008,
1728 0x00000000, 0x8f820034, 0x27bdffe8, 0x30424000, 0x14400005, 0xafbf0010,
1729 0x0e00022d, 0x00000000, 0x0a00062d, 0x8fbf0010, 0x8f620008, 0x8f630000,
1730 0x24020030, 0x00031e02, 0x306300f0, 0x10620008, 0x28620031, 0x1440000d,
1731 0x8fbf0010, 0x24020040, 0x10620007, 0x00000000, 0x0a00062d, 0x00000000,
1732 0x0e0002dd, 0x00000000, 0x0a00062d, 0x8fbf0010, 0x0e0003b8, 0x00000000,
1733 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x8f84003c, 0x1080000f, 0x3c026000,
1734 0x8c430c3c, 0x30630fff, 0xaf830014, 0x14600011, 0x3082000f, 0x10400005,
1735 0x308200f0, 0x10400003, 0x30820f00, 0x14400006, 0x00000000, 0x0000000d,
1736 0x00000000, 0x2400050e, 0x03e00008, 0x00000000, 0x0000000d, 0x00000000,
1737 0x24000513, 0x03e00008, 0x00000000, 0xaf83003c, 0x03e00008, 0x00000000,
1738 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000,
1739 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000, 0x0a000659, 0x00a01021,
1740 0xac860000, 0x24840004, 0x00a01021, 0x1440fffc, 0x24a5ffff, 0x03e00008,
1741 0x00000000, 0x0000000d, 0x03e00008, 0x00000000, 0x3c040800, 0x8c82084c,
1742 0x54400007, 0xac80084c, 0x8f820034, 0x24030400, 0x30420c00, 0x1443005b,
1743 0x00000000, 0xac80084c, 0x0000000d, 0x00000000, 0x2400003c, 0x3c026000,
1744 0x8c444448, 0x3c030800, 0xac640850, 0x24000043, 0x97420104, 0x3045ffff,
1745 0x000530c2, 0x24a2007f, 0x000239c2, 0x2400004e, 0x3c046020, 0x24030020,
1746 0xac830000, 0x8c820000, 0x30420020, 0x10400005, 0x3c036020, 0x8c620000,
1747 0x30420020, 0x1440fffd, 0x00000000, 0x3c026020, 0x8c430010, 0x24040001,
1748 0x0087102b, 0x30ea007f, 0x24abfffe, 0x10400010, 0x00034240, 0x3c056020,
1749 0x24090020, 0xaca90000, 0x8ca20000, 0x30420020, 0x10400006, 0x24840001,
1750 0x3c036020, 0x8c620000, 0x30420020, 0x1440fffd, 0x00000000, 0x0087102b,
1751 0x1440fff4, 0x00000000, 0x8f85001c, 0x3c026020, 0x8c430010, 0x3c046020,
1752 0x34848000, 0x006a1825, 0x01034025, 0x2400006b, 0x10c0000b, 0x00000000,
1753 0x8ca30000, 0x24a50004, 0x8ca20000, 0x24a50004, 0x24c6ffff, 0xac820000,
1754 0x24840004, 0xac830000, 0x14c0fff7, 0x24840004, 0x24000077, 0x3c020007,
1755 0x34427700, 0x3c036000, 0xac6223c8, 0xac6b23cc, 0xac6823e4, 0x24000086,
1756 0x3c046000, 0x3c038000, 0x8c8223f8, 0x00431024, 0x1440fffd, 0x3c021000,
1757 0x3c056000, 0x24030019, 0xaca223f8, 0xa743014a, 0x8ca44448, 0x3c020800,
1758 0xac440854, 0x03e00008, 0x00000000, 0x00000000 };
1759
1760static u32 bnx2_TPAT_b06FwData[(0x0/4) + 1] = { 0x00000000 };
1761static u32 bnx2_TPAT_b06FwRodata[(0x0/4) + 1] = { 0x00000000 };
1762static u32 bnx2_TPAT_b06FwBss[(0x80/4) + 1] = { 0x00000000 };
1763static u32 bnx2_TPAT_b06FwSbss[(0x48/4) + 1] = { 0x00000000 };
1764
1765static int bnx2_TXP_b06FwReleaseMajor = 0x0;
1766static int bnx2_TXP_b06FwReleaseMinor = 0x0;
1767static int bnx2_TXP_b06FwReleaseFix = 0x0;
1768static u32 bnx2_TXP_b06FwStartAddr = 0x08002090;
1769static u32 bnx2_TXP_b06FwTextAddr = 0x08000000;
1770static int bnx2_TXP_b06FwTextLen = 0x3ffc;
1771static u32 bnx2_TXP_b06FwDataAddr = 0x08004020;
1772static int bnx2_TXP_b06FwDataLen = 0x0;
1773static u32 bnx2_TXP_b06FwRodataAddr = 0x00000000;
1774static int bnx2_TXP_b06FwRodataLen = 0x0;
1775static u32 bnx2_TXP_b06FwBssAddr = 0x08004060;
1776static int bnx2_TXP_b06FwBssLen = 0x194;
1777static u32 bnx2_TXP_b06FwSbssAddr = 0x08004020;
1778static int bnx2_TXP_b06FwSbssLen = 0x34;
1779static u32 bnx2_TXP_b06FwText[(0x3ffc/4) + 1] = {
1780 0x0a000824, 0x00000000, 0x00000000, 0x0000000d, 0x74787020, 0x302e362e,
1781 0x39000000, 0x00060900, 0x0000000a, 0x000003e8, 0x0000ea60, 0x00000000,
1782 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1783 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1784 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1785 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1786 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1787 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1788 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1789 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1790 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1791 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1792 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1793 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1794 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1795 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1796 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1797 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1798 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1799 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1800 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1801 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1802 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1803 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1804 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1805 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1806 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1807 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1808 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1809 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1810 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1811 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1812 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1813 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1814 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1815 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1816 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1817 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1818 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1819 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1820 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1821 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1822 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1823 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1824 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1825 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1826 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1827 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1828 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1829 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1830 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1831 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1832 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1833 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1834 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1835 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1836 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1837 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1838 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1839 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1840 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1841 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1842 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1843 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1844 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1845 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1846 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1847 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1848 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1849 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1850 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1851 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1852 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1853 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1854 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1855 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1856 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1857 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1858 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1859 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1860 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1861 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1862 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1863 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1864 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1865 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1866 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1867 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1868 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1869 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1870 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1871 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1872 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1873 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1874 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1875 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1876 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1877 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1878 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1879 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1880 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1881 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1882 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1883 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1884 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1885 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1886 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1887 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1888 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1889 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1890 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1891 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1892 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1893 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1894 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1895 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1896 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1897 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1898 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1899 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1900 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1901 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1902 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1903 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1904 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1905 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1906 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1907 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1908 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1909 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1910 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1911 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1912 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1913 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1914 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1915 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1916 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1917 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1918 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1919 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1920 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1921 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1922 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1923 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1924 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1925 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1926 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1927 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1928 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1929 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1930 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1931 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1932 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1933 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1934 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1935 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1936 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1937 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1938 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1939 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1940 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1941 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1942 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1943 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1944 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1945 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1946 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1947 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1948 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1949 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1950 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1951 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1952 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1953 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1954 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1955 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1956 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1957 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1958 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1959 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1960 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1961 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1962 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1963 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1964 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1965 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1966 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1967 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1968 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1969 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1970 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1971 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1972 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1973 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1974 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1975 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1976 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1977 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1978 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1979 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1980 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1981 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1982 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1983 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1984 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1985 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1986 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1987 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1988 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1989 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1990 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1991 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1992 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1993 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1994 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1995 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1996 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1997 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1998 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1999 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2000 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2001 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2002 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2003 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2004 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2005 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2006 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2007 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2008 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2009 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2010 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2011 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2012 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2013 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2014 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2015 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2016 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2017 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2018 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2019 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2020 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2021 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2022 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2023 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2024 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2025 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2026 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2027 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2028 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2029 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2030 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2031 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2032 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2033 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2034 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2035 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2036 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2037 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2038 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2039 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2040 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2041 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2042 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2043 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2044 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2045 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2046 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2047 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2048 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2049 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2050 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2051 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2052 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2053 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2054 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2055 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2056 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2057 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2058 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2059 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2060 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2061 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2062 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2063 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2064 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2065 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2066 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2067 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2068 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2069 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2070 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2071 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2072 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2073 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2074 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2075 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2076 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2077 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2078 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2079 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2080 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2081 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2082 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2083 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2084 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2085 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2086 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2087 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2088 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2089 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2090 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2091 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2092 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2093 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2094 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2095 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2096 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2097 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2098 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2099 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2100 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2101 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2102 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2103 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2104 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2105 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2106 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2107 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2108 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2109 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2110 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2111 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2112 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2113 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2114 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2115 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2116 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2117 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2118 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2119 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2120 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2121 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2122 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2123 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2124 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2125 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2126 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2127 0x00000000, 0x00000000, 0x00000000, 0x10000003, 0x00000000, 0x0000000d,
2128 0x0000000d, 0x3c020800, 0x24424020, 0x3c030800, 0x246341f4, 0xac400000,
2129 0x0043202b, 0x1480fffd, 0x24420004, 0x3c1d0800, 0x37bd7ffc, 0x03a0f021,
2130 0x3c100800, 0x26102090, 0x3c1c0800, 0x279c4020, 0x0e000a0e, 0x00000000,
2131 0x0000000d, 0x8f840014, 0x27bdffe8, 0xafb00010, 0x8f460104, 0x8f830008,
2132 0x8c8500ac, 0xaf430080, 0x948200a8, 0xa7420e10, 0x948300aa, 0xa7430e12,
2133 0x8c8200ac, 0xaf420e18, 0x97430e10, 0xa7430e14, 0x97420e12, 0xa7420e16,
2134 0x8f430e18, 0x00005021, 0x00c53023, 0x10c001a3, 0xaf430e1c, 0x240f0800,
2135 0x3c0e1000, 0x2419fff8, 0x24100010, 0x3c188100, 0x93620008, 0x10400009,
2136 0x00000000, 0x97620010, 0x00c2102b, 0x14400005, 0x00000000, 0x97620010,
2137 0x3042ffff, 0x0a000862, 0xaf420e00, 0xaf460e00, 0x8f420000, 0x30420008,
2138 0x1040fffd, 0x00000000, 0x97420e08, 0x8f450e04, 0x3044ffff, 0x30820001,
2139 0x14400005, 0x00000000, 0x14a00005, 0x3083a040, 0x0a0009e6, 0x00000000,
2140 0x0000000d, 0x3083a040, 0x24020040, 0x14620049, 0x3082a000, 0x8f87000c,
2141 0x30880036, 0x30890008, 0xaf4f0178, 0x00e01821, 0x9742008a, 0x00431023,
2142 0x2442ffff, 0x30421fff, 0x2c420008, 0x1440fffa, 0x00000000, 0x8f830018,
2143 0x00a05021, 0x00c53023, 0x24e24000, 0x03422821, 0x306b00ff, 0x24630001,
2144 0xaf830018, 0x93840012, 0x000b1400, 0x3c030100, 0x00431025, 0xaca20000,
2145 0x8f820018, 0x30840007, 0x00042240, 0x34870001, 0x00e83825, 0x1120000f,
2146 0xaca20004, 0x97430e0a, 0x8f84000c, 0x00ee3825, 0x2402000e, 0x00781825,
2147 0xaf430160, 0x25430006, 0x24840008, 0x30841fff, 0xa742015a, 0xa7430158,
2148 0xaf84000c, 0x0a0008a9, 0x00000000, 0x8f83000c, 0x25420002, 0xa7420158,
2149 0x24630008, 0x30631fff, 0xaf83000c, 0x54c0000c, 0x8f420e14, 0x97420e10,
2150 0x97430e12, 0x8f840014, 0x00021400, 0x00621825, 0xac8300a8, 0x8f850014,
2151 0x8f420e18, 0x34e70040, 0xaca200ac, 0x8f420e14, 0x8f430e1c, 0xaf420144,
2152 0xaf430148, 0xa34b0152, 0xaf470154, 0x0a0009f1, 0xaf4e0178, 0x10400128,
2153 0x00000000, 0x97620010, 0x00a2102b, 0x10400003, 0x30820040, 0x10400122,
2154 0x00000000, 0xafa60008, 0xa7840010, 0xaf850004, 0x93620008, 0x1440005e,
2155 0x27ac0008, 0xaf60000c, 0x97820010, 0x30424000, 0x10400002, 0x2403000e,
2156 0x24030016, 0xa363000a, 0x24034007, 0xaf630014, 0x93820012, 0x8f630014,
2157 0x30420007, 0x00021240, 0x00621825, 0xaf630014, 0x97820010, 0x8f630014,
2158 0x30420010, 0x00621825, 0xaf630014, 0x97820010, 0x30420008, 0x5040000e,
2159 0x00002821, 0x8f620014, 0x004e1025, 0xaf620014, 0x97430e0a, 0x2402000e,
2160 0x00781825, 0xaf630004, 0xa3620002, 0x9363000a, 0x3405fffc, 0x24630004,
2161 0x0a0008f2, 0xa363000a, 0xaf600004, 0xa3600002, 0x97820010, 0x9363000a,
2162 0x30421f00, 0x00021182, 0x24420028, 0x00621821, 0xa3630009, 0x97420e0c,
2163 0xa7620010, 0x93630009, 0x24020008, 0x24630002, 0x30630007, 0x00431023,
2164 0x30420007, 0xa362000b, 0x93640009, 0x97620010, 0x8f890004, 0x97830010,
2165 0x00441021, 0x00a21021, 0x30630040, 0x10600006, 0x3045ffff, 0x15250005,
2166 0x0125102b, 0x3c068000, 0x0a000925, 0x00005821, 0x0125102b, 0x144000c8,
2167 0x00005021, 0x97420e14, 0xa7420e10, 0x97430e16, 0xa7430e12, 0x8f420e1c,
2168 0xaf420e18, 0xaf450e00, 0x8f420000, 0x30420008, 0x1040fffd, 0x00000000,
2169 0x97420e08, 0x00a04821, 0xa7820010, 0x8f430e04, 0x00003021, 0x240b0001,
2170 0xaf830004, 0x97620010, 0x0a000936, 0x304dffff, 0x8f890004, 0x97820010,
2171 0x30420040, 0x10400004, 0x01206821, 0x3c068000, 0x0a000936, 0x00005821,
2172 0x97630010, 0x8f820004, 0x144300a7, 0x00005021, 0x00003021, 0x240b0001,
2173 0x8d820000, 0x00491023, 0x1440000d, 0xad820000, 0x8f620014, 0x34420040,
2174 0xaf620014, 0x97430e10, 0x97420e12, 0x8f840014, 0x00031c00, 0x00431025,
2175 0xac8200a8, 0x8f830014, 0x8f420e18, 0xac6200ac, 0x93620008, 0x1440003f,
2176 0x00000000, 0x25260002, 0x8f84000c, 0x9743008a, 0x3063ffff, 0xafa30000,
2177 0x8fa20000, 0x00441023, 0x2442ffff, 0x30421fff, 0x2c420010, 0x1440fff7,
2178 0x00000000, 0x8f82000c, 0x8f830018, 0x00021082, 0x00021080, 0x24424000,
2179 0x03422821, 0x00605021, 0x24630001, 0x314200ff, 0x00021400, 0xaf830018,
2180 0x3c033200, 0x00431025, 0xaca20000, 0x93630009, 0x9362000a, 0x00031c00,
2181 0x00431025, 0xaca20004, 0x8f830018, 0xaca30008, 0x97820010, 0x30420008,
2182 0x10400002, 0x00c04021, 0x25280006, 0x97430e14, 0x93640002, 0x8f450e1c,
2183 0x8f660004, 0x8f670014, 0xaf4f0178, 0x3063ffff, 0xa7430144, 0x97420e16,
2184 0xa7420146, 0xaf450148, 0xa34a0152, 0x8f82000c, 0x308400ff, 0xa744015a,
2185 0xaf460160, 0xa7480158, 0xaf470154, 0xaf4e0178, 0x00501021, 0x30421fff,
2186 0xaf82000c, 0x0a0009c5, 0x8d820000, 0x93620009, 0x9363000b, 0x8f85000c,
2187 0x2463000a, 0x00435021, 0x25440007, 0x00992024, 0x9743008a, 0x3063ffff,
2188 0xafa30000, 0x8fa20000, 0x00451023, 0x2442ffff, 0x30421fff, 0x0044102b,
2189 0x1440fff7, 0x00000000, 0x8f82000c, 0x8f840018, 0x00021082, 0x00021080,
2190 0x24424000, 0x03422821, 0x00804021, 0x24840001, 0xaf840018, 0x93630009,
2191 0x310200ff, 0x00022400, 0x3c024100, 0x24630002, 0x00621825, 0x00832025,
2192 0xaca40000, 0x8f62000c, 0x00461025, 0xaca20004, 0x97430e14, 0x93640002,
2193 0x8f450e1c, 0x8f660004, 0x8f670014, 0xaf4f0178, 0x3063ffff, 0xa7430144,
2194 0x97420e16, 0x308400ff, 0xa7420146, 0xaf450148, 0xa3480152, 0x8f83000c,
2195 0x25420007, 0x00591024, 0xa744015a, 0xaf460160, 0xa7490158, 0xaf470154,
2196 0xaf4e0178, 0x00621821, 0x30631fff, 0xaf83000c, 0x8d820000, 0x14400005,
2197 0x00000000, 0x8f620014, 0x2403ffbf, 0x00431024, 0xaf620014, 0x8f62000c,
2198 0x004d1021, 0xaf62000c, 0x93630008, 0x14600008, 0x00000000, 0x11600006,
2199 0x00000000, 0x8f630014, 0x3c02efff, 0x3442fffe, 0x00621824, 0xaf630014,
2200 0xa36b0008, 0x01205021, 0x15400016, 0x8fa60008, 0x97420e14, 0x97430e16,
2201 0x8f850014, 0x00021400, 0x00621825, 0xaca300a8, 0x8f840014, 0x8f420e1c,
2202 0x0a0009f3, 0xac8200ac, 0x97420e14, 0x97430e16, 0x8f840014, 0x00021400,
2203 0x00621825, 0xac8300a8, 0x8f850014, 0x8f420e1c, 0x00005021, 0x0a0009f3,
2204 0xaca200ac, 0x14c0fe64, 0x00000000, 0x55400018, 0x8fb00010, 0x3c038000,
2205 0x8f420178, 0x00431024, 0x1440fffd, 0x00000000, 0x97430e14, 0x8f440e1c,
2206 0x24020800, 0xaf420178, 0x3063ffff, 0xa7430144, 0x97420e16, 0x3c031000,
2207 0xa7420146, 0x24020240, 0xaf440148, 0xa3400152, 0xa740015a, 0xaf400160,
2208 0xa7400158, 0xaf420154, 0xaf430178, 0x8fb00010, 0x03e00008, 0x27bd0018,
2209 0x27bdffd8, 0x3c1a8000, 0x3c0420ff, 0x3484fffd, 0x3c020008, 0x03421821,
2210 0xafbf0020, 0xafb3001c, 0xafb20018, 0xafb10014, 0xafb00010, 0xaf830014,
2211 0xaf440e00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2212 0x3c0200ff, 0x3442fffd, 0x3c046004, 0xaf420e00, 0x8c835000, 0x24130d00,
2213 0x3c120800, 0x3c114000, 0x2402ff7f, 0x00621824, 0x3463380c, 0x24020009,
2214 0xac835000, 0xaf420008, 0xaf800018, 0xaf80000c, 0x0e000fa1, 0x00000000,
2215 0x0e000a96, 0x00000000, 0x3c020800, 0x24504080, 0x8f420000, 0x30420001,
2216 0x1040fffd, 0x00000000, 0x8f440100, 0xaf840008, 0xaf440020, 0x93430108,
2217 0xa3830012, 0x93820012, 0x30420001, 0x10400008, 0x00000000, 0x93820012,
2218 0x30420006, 0x00021100, 0x0e00083b, 0x0050d821, 0x0a000a52, 0x00000000,
2219 0x14930005, 0x00000000, 0x0e00083b, 0x265b4100, 0x0a000a52, 0x00000000,
2220 0x0e000ba3, 0x00000000, 0xaf510138, 0x0a000a36, 0x00000000, 0x27bdfff8,
2221 0x3084ffff, 0x24820007, 0x3044fff8, 0x8f85000c, 0x9743008a, 0x3063ffff,
2222 0xafa30000, 0x8fa20000, 0x00451023, 0x2442ffff, 0x30421fff, 0x0044102b,
2223 0x1440fff7, 0x00000000, 0x8f82000c, 0x00021082, 0x00021080, 0x24424000,
2224 0x03421021, 0x03e00008, 0x27bd0008, 0x3084ffff, 0x8f82000c, 0x24840007,
2225 0x3084fff8, 0x00441021, 0x30421fff, 0xaf82000c, 0x03e00008, 0x00000000,
2226 0x27bdffe8, 0x3c1a8000, 0x3c0420ff, 0x3484fffd, 0x3c020008, 0x03421821,
2227 0xafbf0010, 0xaf830014, 0xaf440e00, 0x00000000, 0x00000000, 0x00000000,
2228 0x00000000, 0x00000000, 0x3c0200ff, 0x3442fffd, 0x3c046004, 0xaf420e00,
2229 0x8c825000, 0x2403ff7f, 0x00431024, 0x3442380c, 0x24030009, 0xac825000,
2230 0xaf430008, 0xaf800018, 0xaf80000c, 0x0e000fa1, 0x00000000, 0x0e000a96,
2231 0x00000000, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0x3c02000a,
2232 0x03421821, 0x3c040800, 0x24844120, 0x24050018, 0xafbf0010, 0xaf830024,
2233 0x0e000fad, 0x00003021, 0x3c050800, 0x3c020800, 0x24423d60, 0xaca24180,
2234 0x24a54180, 0x3c020800, 0x24423e18, 0x3c030800, 0x24633e2c, 0x3c040800,
2235 0xaca20004, 0x3c020800, 0x24423d68, 0xaca30008, 0xac824190, 0x24844190,
2236 0x3c020800, 0x24423da4, 0x3c070800, 0x24e73de4, 0x3c060800, 0x24c63e40,
2237 0x3c050800, 0x24a52b28, 0x3c030800, 0xac820004, 0x3c020800, 0x24423e48,
2238 0xac870008, 0xac86000c, 0xac850010, 0xac6241b0, 0x246341b0, 0x8fbf0010,
2239 0x3c020800, 0x24423e60, 0xac620004, 0xac670008, 0xac66000c, 0xac650010,
2240 0x03e00008, 0x27bd0018, 0x27bdffc8, 0x3c020800, 0x24424120, 0xafbf0030,
2241 0xafb3002c, 0xafb20028, 0xafb10024, 0xafb00020, 0x90470021, 0x8c510008,
2242 0x8c45001c, 0x8f900020, 0x3c060800, 0x3c038000, 0x8f420178, 0x00431024,
2243 0x1440fffd, 0x8cc2414c, 0x24c3414c, 0x2473ffd4, 0xaf420144, 0x8e620030,
2244 0x30b22000, 0xaf420148, 0x3c021000, 0xaf50014c, 0xa3470152, 0xa7510158,
2245 0xaf450154, 0xaf420178, 0x12400004, 0x3c030800, 0x8c620030, 0x24420001,
2246 0xac620030, 0x93420109, 0x9344010a, 0x00111c00, 0xafa30018, 0x00071a00,
2247 0xafa50014, 0x8cc5414c, 0x00021600, 0x00042400, 0x00441025, 0x00431025,
2248 0xafa20010, 0x8f440100, 0x8e660030, 0x0e000fe1, 0x02003821, 0x1640000e,
2249 0x8fbf0030, 0x8f820000, 0x8e630030, 0x8c44017c, 0x02031823, 0x00711823,
2250 0x00641823, 0x2c630002, 0x14600006, 0x8fb3002c, 0x0000000d, 0x00000000,
2251 0x240000ca, 0x8fbf0030, 0x8fb3002c, 0x8fb20028, 0x8fb10024, 0x8fb00020,
2252 0x03e00008, 0x27bd0038, 0x974309da, 0x00804021, 0xad030000, 0x8f4209dc,
2253 0xad020004, 0x8f4309e0, 0xad030008, 0x934409d9, 0x24020001, 0x30840003,
2254 0x1082001f, 0x30a900ff, 0x28820002, 0x10400005, 0x24020002, 0x10800009,
2255 0x3c0a0800, 0x0a000b64, 0x93420934, 0x1082000b, 0x24020003, 0x10820026,
2256 0x3c0a0800, 0x0a000b64, 0x93420934, 0x974209e4, 0x00021400, 0x34420800,
2257 0xad02000c, 0x0a000b63, 0x25080010, 0x974209e4, 0x00021400, 0x34428100,
2258 0xad02000c, 0x974309e8, 0x3c0a0800, 0x00031c00, 0x34630800, 0xad030010,
2259 0x0a000b63, 0x25080014, 0x974409e4, 0x3c050800, 0x24a24120, 0x94430018,
2260 0x94460010, 0x9447000c, 0x00a05021, 0x24020800, 0xad000010, 0xad020014,
2261 0x00042400, 0x00661821, 0x00671823, 0x2463fff2, 0x00832025, 0xad04000c,
2262 0x0a000b63, 0x25080018, 0x974209e4, 0x3c050800, 0x00021400, 0x34428100,
2263 0xad02000c, 0x974409e8, 0x24a24120, 0x94430018, 0x94460010, 0x9447000c,
2264 0x00a05021, 0x24020800, 0xad000014, 0xad020018, 0x00042400, 0x00661821,
2265 0x00671823, 0x2463ffee, 0x00832025, 0xad040010, 0x2508001c, 0x93420934,
2266 0x93450921, 0x3c074000, 0x25444120, 0x94830014, 0x94860010, 0x00021082,
2267 0x00021600, 0x00052c00, 0x00a72825, 0x00451025, 0x00661821, 0x00431025,
2268 0xad020000, 0x97830028, 0x974209ea, 0x00621821, 0x00031c00, 0xad030004,
2269 0x97820028, 0x24420001, 0x30427fff, 0xa7820028, 0x93430920, 0x3c020006,
2270 0x00031e00, 0x00621825, 0xad030008, 0x8f42092c, 0xad02000c, 0x8f430930,
2271 0xad030010, 0x8f440938, 0x25080014, 0xad040000, 0x8f820020, 0x11200004,
2272 0xad020004, 0x8f420940, 0x0a000b8d, 0x2442ffff, 0x8f420940, 0xad020008,
2273 0x8f440948, 0x8f420940, 0x93430936, 0x00822823, 0x00652806, 0x3402ffff,
2274 0x0045102b, 0x54400001, 0x3405ffff, 0x93420937, 0x25444120, 0x90830020,
2275 0xad000010, 0x00021700, 0x34630010, 0x00031c00, 0x00431025, 0x00451025,
2276 0xad02000c, 0x03e00008, 0x25020014, 0x27bdffb0, 0x3c020008, 0x03421821,
2277 0xafbf004c, 0xafbe0048, 0xafb70044, 0xafb60040, 0xafb5003c, 0xafb40038,
2278 0xafb30034, 0xafb20030, 0xafb1002c, 0xafb00028, 0xaf830000, 0x24020040,
2279 0xaf420814, 0xaf400810, 0x8f420944, 0x8f430950, 0x8f440954, 0x8f45095c,
2280 0xaf820030, 0xaf830020, 0xaf84001c, 0xaf85002c, 0x93430900, 0x24020020,
2281 0x10620005, 0x24020030, 0x10620022, 0x3c030800, 0x0a000bf1, 0x8c62002c,
2282 0x24020088, 0xaf420818, 0x3c020800, 0x24424180, 0xafa20020, 0x93430109,
2283 0x3c020800, 0x10600009, 0x24574190, 0x3c026000, 0x24030100, 0xac43081c,
2284 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000, 0x2400031d, 0x9342010a,
2285 0x30420080, 0x1440001c, 0x00000000, 0x3c026000, 0x24030100, 0xac43081c,
2286 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000, 0x24000324, 0x0a000bf4,
2287 0x00000000, 0x93430109, 0x3063007f, 0x00031140, 0x000318c0, 0x00431021,
2288 0x24430088, 0xaf430818, 0x0000000d, 0x3c020800, 0x244241d0, 0x3c030800,
2289 0x247741e0, 0x0a000bf4, 0xafa20020, 0x24420001, 0x0a000f4c, 0xac62002c,
2290 0x8f840000, 0x8f850020, 0x24020800, 0xaf420178, 0x8f4209a4, 0x8c83017c,
2291 0x00a21023, 0x00431023, 0x2c420002, 0x14400004, 0x00000000, 0x0000000d,
2292 0x00000000, 0x24000349, 0x8f420104, 0x8f430988, 0x00431023, 0x58400005,
2293 0x8f4209a0, 0x0000000d, 0x00000000, 0x2400034d, 0x8f4209a0, 0x3c100800,
2294 0xae02414c, 0x8f4309a4, 0x2604414c, 0x2491ffd4, 0xae230030, 0x8f420104,
2295 0xae250024, 0x00431023, 0xac82ffd4, 0x8fa30020, 0x8c620000, 0x0040f809,
2296 0x0200b021, 0x00409021, 0x32440010, 0x32420002, 0x10400007, 0xafa40024,
2297 0x8e22001c, 0x32500040, 0x2403ffbf, 0x00431024, 0x0a000f13, 0xae22001c,
2298 0x32420020, 0x10400002, 0x3c020800, 0x245741b0, 0x32420001, 0x14400007,
2299 0x00000000, 0x8f820008, 0xaf420080, 0x8ec3414c, 0xaf430e10, 0x8e220030,
2300 0xaf420e18, 0x9343010b, 0x93420905, 0x30420008, 0x1040003c, 0x307400ff,
2301 0x8f820000, 0x8c430074, 0x0460000a, 0x00000000, 0x3c026000, 0x24030100,
2302 0xac43081c, 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000, 0x24000384,
2303 0x8f820000, 0x9044007b, 0x9343010a, 0x14830027, 0x32500040, 0x24072000,
2304 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x8ec2414c,
2305 0x26c4414c, 0x2484ffd4, 0xaf420144, 0x8c820030, 0x3c030100, 0xaf420148,
2306 0x24020047, 0xaf43014c, 0x00001821, 0xa3420152, 0x3c021000, 0xa7430158,
2307 0xaf470154, 0xaf420178, 0x8ec5414c, 0x8d230030, 0x8c860030, 0x24630001,
2308 0xad230030, 0x93420109, 0x9343010a, 0xafa70014, 0xafa00018, 0x00021600,
2309 0x00031c00, 0x00431025, 0x34424700, 0xafa20010, 0x8f440100, 0x0e000fe1,
2310 0x3c070100, 0x3c030800, 0x24624120, 0x0a000d01, 0x8c43001c, 0x32820002,
2311 0x10400047, 0x3c039000, 0x34630001, 0x8f820008, 0x32500040, 0x3c048000,
2312 0x00431025, 0xaf420020, 0x8f420020, 0x00441024, 0x1440fffd, 0x00000000,
2313 0x8f830000, 0x90620005, 0x3c058000, 0x34420008, 0xa0620005, 0x8f860000,
2314 0x34a50001, 0x8f840008, 0x8cc20074, 0x3c038000, 0x00852025, 0x00431025,
2315 0xacc20074, 0xaf440020, 0x90c3007b, 0x9342010a, 0x14620028, 0x3c040800,
2316 0x24072000, 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd,
2317 0x8ec2414c, 0x26c4414c, 0x2484ffd4, 0xaf420144, 0x8c820030, 0x3c030100,
2318 0xaf420148, 0x24020046, 0xaf43014c, 0x00001821, 0xa3420152, 0x3c021000,
2319 0xa7430158, 0xaf470154, 0xaf420178, 0x8ec5414c, 0x8d230030, 0x8c860030,
2320 0x24630001, 0xad230030, 0x93420109, 0x9343010a, 0xafa70014, 0xafa00018,
2321 0x00021600, 0x00031c00, 0x00431025, 0x34424600, 0xafa20010, 0x8f440100,
2322 0x0e000fe1, 0x3c070100, 0x3c040800, 0x24824120, 0x0a000d01, 0x8c43001c,
2323 0x93420108, 0x30420010, 0x50400050, 0x9343093f, 0x8f860000, 0x90c3007f,
2324 0x90c2007e, 0x90c40080, 0x306800ff, 0x00021600, 0x00081c00, 0x00431025,
2325 0x00042200, 0x90c3007a, 0x90c5000a, 0x00441025, 0x11050028, 0x00623825,
2326 0xa0c8000a, 0x24086000, 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024,
2327 0x1440fffd, 0x8ec2414c, 0x26c4414c, 0x2484ffd4, 0xaf420144, 0x8c820030,
2328 0x00001821, 0xaf420148, 0x24020052, 0xaf47014c, 0xa3420152, 0x3c021000,
2329 0xa7430158, 0xaf480154, 0xaf420178, 0x8ec5414c, 0x8d230030, 0x8c860030,
2330 0x24630001, 0xad230030, 0x93420109, 0x9343010a, 0xafa80014, 0xafa00018,
2331 0x00021600, 0x00031c00, 0x00431025, 0x34425200, 0xafa20010, 0x0e000fe1,
2332 0x8f440100, 0x0a000cfb, 0x00000000, 0x3c026000, 0x24030100, 0xac43081c,
2333 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000, 0x240003cd, 0x16800009,
2334 0x3c040800, 0x3c030800, 0x24624120, 0x8c43001c, 0x32500040, 0x2404ffbf,
2335 0x00641824, 0x0a000f13, 0xac43001c, 0x8c824120, 0x10400005, 0x3c030800,
2336 0x8c620034, 0xac804120, 0x24420001, 0xac620034, 0x9343093f, 0x24020012,
2337 0x1462000f, 0x329e0038, 0x17c0000c, 0x3c030800, 0x8f830000, 0x8c62004c,
2338 0xac62005c, 0x3c020800, 0x24444120, 0x8c82001c, 0x32500040, 0x2403ffbf,
2339 0x00431024, 0x0a000f13, 0xac82001c, 0xac604120, 0x97420908, 0x000211c0,
2340 0xaf420024, 0x97420908, 0x3c030080, 0x34630003, 0x000211c0, 0xaf42080c,
2341 0xaf43081c, 0x974209ec, 0x8f4309a4, 0xa7820028, 0x3c020800, 0x24444120,
2342 0xac830028, 0x93420937, 0x93430934, 0x00021080, 0x00621821, 0xa4830014,
2343 0x934209d8, 0x00621821, 0xa4830016, 0x934209d8, 0x93430934, 0x00809821,
2344 0x00431021, 0x24420010, 0xa4820012, 0x0000a821, 0x24020006, 0x13c00003,
2345 0xae62001c, 0x0a000d82, 0x24120008, 0x8f420958, 0x8f830020, 0x8f84002c,
2346 0x00431023, 0x00832023, 0x04800003, 0xae620004, 0x04410003, 0x0082102b,
2347 0x0a000d4e, 0xae600004, 0x54400001, 0xae640004, 0x8ee20000, 0x0040f809,
2348 0x00000000, 0x00409021, 0x32420001, 0x5440001e, 0x8ee20004, 0x8e630008,
2349 0x1060002b, 0x3c02c000, 0x00621025, 0xaf420e00, 0x8f420000, 0x30420008,
2350 0x1040fffd, 0x00000000, 0x97420e08, 0xa7820010, 0x8f430e04, 0x8e620008,
2351 0xaf830004, 0x8f840004, 0x0044102b, 0x1040000b, 0x24150001, 0x24020100,
2352 0x3c016000, 0xac22081c, 0x3c020001, 0x3c016000, 0xac22081c, 0x0000000d,
2353 0x00000000, 0x24000449, 0x24150001, 0x8ee20004, 0x0040f809, 0x00000000,
2354 0x02429025, 0x32420002, 0x5040001d, 0x8f470940, 0x12a00006, 0x8ec2414c,
2355 0x8f830000, 0xac6200a8, 0x8f840000, 0x8e620030, 0xac8200ac, 0x32420004,
2356 0x50400013, 0x8f470940, 0x3c020800, 0x3283007d, 0x106000fe, 0x245741b0,
2357 0x32820001, 0x50400006, 0x36520002, 0x8f830030, 0x8f420940, 0x106200f7,
2358 0x00000000, 0x36520002, 0x24020008, 0xa660000c, 0xa662000e, 0xae600008,
2359 0xa2600020, 0x8f470940, 0x3c030800, 0x24684120, 0x8d020028, 0x8d050008,
2360 0x9504000c, 0x9506000a, 0x95030022, 0x00451021, 0x00862021, 0x00641821,
2361 0xaf870030, 0xad020028, 0x32820030, 0x10400006, 0xa5030010, 0x91020020,
2362 0x32910040, 0x34420004, 0x0a000dd4, 0xa1020020, 0x93420923, 0x30420040,
2363 0x10400029, 0x32910040, 0x8f830000, 0x8f840020, 0x8c620084, 0x00441023,
2364 0x0442000a, 0x3c039000, 0x95020010, 0x8c630084, 0x00821021, 0x00621823,
2365 0x1c600004, 0x3c039000, 0x91020020, 0x34420001, 0xa1020020, 0x34630001,
2366 0x8f820008, 0x32910040, 0x3c048000, 0x00431025, 0xaf420020, 0x8f420020,
2367 0x00441024, 0x1440fffd, 0x00000000, 0x8f840000, 0x9083003f, 0x2402000a,
2368 0x10620005, 0x2402000c, 0x9083003f, 0x24020008, 0x14620002, 0x24020014,
2369 0xa082003f, 0x8f830008, 0x3c028000, 0x34420001, 0x00621825, 0xaf430020,
2370 0x3c040800, 0x24904120, 0x9602000c, 0x96030016, 0x9604000e, 0x00431021,
2371 0x00442021, 0x24840002, 0x3084ffff, 0x0e000a55, 0xa6020018, 0x8f850018,
2372 0x00a01821, 0xa2030021, 0x8ee60008, 0x00402021, 0x24a50001, 0xaf850018,
2373 0x00c0f809, 0x00000000, 0x00402021, 0x0e000b12, 0x02202821, 0x8ee3000c,
2374 0x0060f809, 0x00402021, 0x96040018, 0x9602000e, 0x00822021, 0x24840002,
2375 0x0e000a6b, 0x3084ffff, 0x3c030800, 0x8c624120, 0x8e030008, 0x3c040800,
2376 0x00431023, 0x14400012, 0xac824120, 0x54600006, 0x8e02001c, 0x3243004a,
2377 0x24020002, 0x14620005, 0x00000000, 0x8e02001c, 0x34420040, 0x0a000e0b,
2378 0xae02001c, 0x52a00006, 0x36520002, 0x8e02002c, 0xaf420e10, 0x8e030030,
2379 0xaf430e18, 0x36520002, 0x52a00008, 0x96670010, 0x8f830000, 0x8f420e10,
2380 0xac6200a8, 0x8f840000, 0x8f420e18, 0xac8200ac, 0x96670010, 0x92680020,
2381 0x24020040, 0xaf420814, 0x8f830020, 0x8f82001c, 0x00671821, 0x00621023,
2382 0xaf830020, 0x58400005, 0x8f42095c, 0x8f820000, 0xaf83001c, 0xac430054,
2383 0x8f42095c, 0x31030008, 0xaf82002c, 0x1060001a, 0x00000000, 0x8f840000,
2384 0x90820120, 0x90830121, 0x304600ff, 0x00c31823, 0x30630007, 0x24020007,
2385 0x1062000e, 0x00000000, 0x90820122, 0x304200fe, 0xa0820122, 0x8f850000,
2386 0x00061880, 0x8f840020, 0x24a20100, 0x00431021, 0x24c30001, 0x30630007,
2387 0xac440000, 0x0a000e40, 0xa0a30120, 0x90820122, 0x34420001, 0xa0820122,
2388 0x14e00003, 0x31020001, 0x10400031, 0x32510002, 0x8f820000, 0x8c43000c,
2389 0x30630001, 0x1060002c, 0x32510002, 0x3c029000, 0x8f830008, 0x34420001,
2390 0x3c048000, 0x00621825, 0xaf430020, 0x8f420020, 0x00441024, 0x1440fffd,
2391 0x00000000, 0x8f870000, 0x8ce2000c, 0x30420001, 0x10400018, 0x00000000,
2392 0x94e2006a, 0x00022880, 0x50a00001, 0x24050001, 0x94e30068, 0x90e40081,
2393 0x3c020800, 0x8c460024, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001,
2394 0x00a03021, 0x3c020800, 0x8c440028, 0x00c4182b, 0x54600001, 0x00c02021,
2395 0x8f430074, 0x2402fffe, 0x00822824, 0x00a31821, 0xace3000c, 0x8f830008,
2396 0x3c028000, 0x34420001, 0x00621825, 0xaf430020, 0x8f830020, 0x3c020800,
2397 0x24504120, 0xae030024, 0x8ee20010, 0x0040f809, 0x00000000, 0x12a00005,
2398 0x00000000, 0x8f420e10, 0xae02002c, 0x8f430e18, 0xae030030, 0x1220feba,
2399 0x0000a821, 0x8f870024, 0x97860028, 0x8f830000, 0x8f820030, 0x8f840020,
2400 0x8f85001c, 0x32500040, 0xa4e6002c, 0xac620044, 0x32420008, 0xac640050,
2401 0xac650054, 0x1040007a, 0x32820020, 0x10400027, 0x32910010, 0x24072000,
2402 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x8ec2414c,
2403 0x26c4414c, 0x2484ffd4, 0xaf420144, 0x8c820030, 0x3c030400, 0xaf420148,
2404 0x24020041, 0xaf43014c, 0x00001821, 0xa3420152, 0x3c021000, 0xa7430158,
2405 0xaf470154, 0xaf420178, 0x8ec5414c, 0x8d230030, 0x8c860030, 0x24630001,
2406 0xad230030, 0x93420109, 0x9343010a, 0xafa70014, 0xafa00018, 0x00021600,
2407 0x00031c00, 0x00431025, 0x34424100, 0xafa20010, 0x8f440100, 0x0e000fe1,
2408 0x3c070400, 0x12200028, 0x24072000, 0x3c090800, 0x3c038000, 0x8f420178,
2409 0x00431024, 0x1440fffd, 0x8ec2414c, 0x26c4414c, 0x2484ffd4, 0xaf420144,
2410 0x8c820030, 0x3c030300, 0xaf420148, 0x2402004e, 0xaf43014c, 0x00001821,
2411 0xa3420152, 0x3c021000, 0xa7430158, 0xaf470154, 0xaf420178, 0x8ec5414c,
2412 0x8d230030, 0x8c860030, 0x24630001, 0xad230030, 0x93420109, 0x9343010a,
2413 0xafa70014, 0xafa00018, 0x00021600, 0x00031c00, 0x00431025, 0x34424e00,
2414 0xafa20010, 0x8f440100, 0x0e000fe1, 0x3c070300, 0x0a000f0b, 0x8fa30024,
2415 0x32820008, 0x10400026, 0x3c090800, 0x24072000, 0x3c038000, 0x8f420178,
2416 0x00431024, 0x1440fffd, 0x8ec2414c, 0x26c4414c, 0x2484ffd4, 0xaf420144,
2417 0x8c820030, 0x3c030200, 0xaf420148, 0x2402004b, 0xaf43014c, 0x00001821,
2418 0xa3420152, 0x3c021000, 0xa7430158, 0xaf470154, 0xaf420178, 0x8ec5414c,
2419 0x8d230030, 0x8c860030, 0x24630001, 0xad230030, 0x93420109, 0x9343010a,
2420 0xafa70014, 0xafa00018, 0x00021600, 0x00031c00, 0x00431025, 0x34424b00,
2421 0xafa20010, 0x8f440100, 0x0e000fe1, 0x3c070200, 0x8fa30024, 0x14600004,
2422 0x8fa40020, 0x32420010, 0x10400004, 0x00000000, 0x8c820004, 0x0040f809,
2423 0x00000000, 0x12000006, 0x8fa30020, 0x8c620008, 0x0040f809, 0x00000000,
2424 0x0a000f4d, 0x8fbf004c, 0x3c030800, 0x8c62413c, 0x30420040, 0x1440002f,
2425 0x8fbf004c, 0x24040040, 0x8f910020, 0x3c038000, 0x8f420178, 0x00431024,
2426 0x1440fffd, 0x8ec2414c, 0x26d0414c, 0x2610ffd4, 0xaf420144, 0x8e020030,
2427 0x00001821, 0xaf420148, 0x24020049, 0xaf51014c, 0xa3420152, 0x3c021000,
2428 0xa7430158, 0xaf440154, 0xaf420178, 0x8ec5414c, 0x8e060030, 0x93420109,
2429 0x9343010a, 0xafa40014, 0xafa00018, 0x00021600, 0x00031c00, 0x00431025,
2430 0x34424900, 0xafa20010, 0x8f440100, 0x0e000fe1, 0x02203821, 0x8f830000,
2431 0x8e020030, 0x8c64017c, 0x02221023, 0x00441023, 0x2c420002, 0x14400005,
2432 0x8fbf004c, 0x0000000d, 0x00000000, 0x240000ca, 0x8fbf004c, 0x8fbe0048,
2433 0x8fb70044, 0x8fb60040, 0x8fb5003c, 0x8fb40038, 0x8fb30034, 0x8fb20030,
2434 0x8fb1002c, 0x8fb00028, 0x03e00008, 0x27bd0050, 0x03e00008, 0x00001021,
2435 0x3c030800, 0x24654120, 0x8ca40004, 0x8c634120, 0x0064102b, 0x54400001,
2436 0x00602021, 0x9743093c, 0x0083102b, 0x54400001, 0x00801821, 0x00001021,
2437 0xaca30008, 0x03e00008, 0xa4a00022, 0x8f850004, 0x97840010, 0x3c030800,
2438 0x24634120, 0x24020008, 0xa462000e, 0x8f820004, 0xa460000c, 0x000420c2,
2439 0x30840008, 0x2c420001, 0x00021023, 0x30420006, 0xac650008, 0x03e00008,
2440 0xa0640020, 0x3c020800, 0x24424120, 0x90450021, 0x94430018, 0x3c021100,
2441 0xac800004, 0x00052c00, 0x24630002, 0x00621825, 0x00a32825, 0x24820008,
2442 0x03e00008, 0xac850000, 0x0000000d, 0x00000000, 0x2400016f, 0x03e00008,
2443 0x00000000, 0x0000000d, 0x00000000, 0x2400017b, 0x03e00008, 0x00000000,
2444 0x03e00008, 0x00000000, 0x3c020800, 0x24424120, 0xac400008, 0xa4400022,
2445 0x03e00008, 0x24020001, 0x3c020800, 0x24424120, 0x24030008, 0xac400008,
2446 0xa440000c, 0xa443000e, 0xa0400020, 0x03e00008, 0x24020004, 0x03e00008,
2447 0x00001021, 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004,
2448 0xac820000, 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000, 0x0a000fb2,
2449 0x00a01021, 0xac860000, 0x24840004, 0x00a01021, 0x1440fffc, 0x24a5ffff,
2450 0x03e00008, 0x00000000, 0x3c0a0800, 0x8d490068, 0x3c050800, 0x24a51090,
2451 0x00093140, 0x00c51021, 0xac440000, 0x8f440e04, 0x00a61021, 0xac440004,
2452 0x97430e08, 0x97420e0c, 0x00a62021, 0x00031c00, 0x00431025, 0xac820008,
2453 0x8f430e10, 0x00801021, 0xac43000c, 0x8f440e14, 0xac440010, 0x8f430e18,
2454 0x3c0800ff, 0xac430014, 0x8f470e1c, 0x3508ffff, 0x25290001, 0xac470018,
2455 0x3c070800, 0x8ce3006c, 0x9344010a, 0x3c026000, 0x24630001, 0xace3006c,
2456 0x8c434448, 0x3129007f, 0x00a62821, 0xad490068, 0x00042600, 0x00681824,
2457 0x00832025, 0x03e00008, 0xaca4001c, 0x8fac0010, 0x8fad0014, 0x8fae0018,
2458 0x3c0b0800, 0x8d6a0060, 0x3c080800, 0x25080078, 0x000a4940, 0x01281021,
2459 0x01091821, 0xac440000, 0x00601021, 0xac650004, 0xac460008, 0xac67000c,
2460 0xac4c0010, 0xac6d0014, 0x3c036000, 0xac4e0018, 0x8c654448, 0x3c040800,
2461 0x8c820064, 0x254a0001, 0x314a007f, 0x01094021, 0xad6a0060, 0x24420001,
2462 0xac820064, 0x03e00008, 0xad05001c, 0x00000000 };
2463
2464static u32 bnx2_TXP_b06FwData[(0x0/4) + 1] = { 0x00000000 };
2465static u32 bnx2_TXP_b06FwRodata[(0x0/4) + 1] = { 0x00000000 };
2466static u32 bnx2_TXP_b06FwBss[(0x194/4) + 1] = { 0x00000000 };
2467static u32 bnx2_TXP_b06FwSbss[(0x34/4) + 1] = { 0x00000000 };
2468
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 770e28f98fd5..269a5e407349 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3037,7 +3037,7 @@ static void bond_activebackup_arp_mon(struct net_device *bond_dev)
3037 bond_set_slave_inactive_flags(bond->current_arp_slave); 3037 bond_set_slave_inactive_flags(bond->current_arp_slave);
3038 3038
3039 /* search for next candidate */ 3039 /* search for next candidate */
3040 bond_for_each_slave_from(bond, slave, i, bond->current_arp_slave) { 3040 bond_for_each_slave_from(bond, slave, i, bond->current_arp_slave->next) {
3041 if (IS_UP(slave->dev)) { 3041 if (IS_UP(slave->dev)) {
3042 slave->link = BOND_LINK_BACK; 3042 slave->link = BOND_LINK_BACK;
3043 bond_set_slave_active_flags(slave); 3043 bond_set_slave_active_flags(slave);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 1b68dd5a49b6..4a47df5a9ff9 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -155,9 +155,9 @@
155 155
156#define DRV_NAME "e100" 156#define DRV_NAME "e100"
157#define DRV_EXT "-NAPI" 157#define DRV_EXT "-NAPI"
158#define DRV_VERSION "3.3.6-k2"DRV_EXT 158#define DRV_VERSION "3.4.8-k2"DRV_EXT
159#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" 159#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver"
160#define DRV_COPYRIGHT "Copyright(c) 1999-2004 Intel Corporation" 160#define DRV_COPYRIGHT "Copyright(c) 1999-2005 Intel Corporation"
161#define PFX DRV_NAME ": " 161#define PFX DRV_NAME ": "
162 162
163#define E100_WATCHDOG_PERIOD (2 * HZ) 163#define E100_WATCHDOG_PERIOD (2 * HZ)
@@ -210,11 +210,17 @@ static struct pci_device_id e100_id_table[] = {
210 INTEL_8255X_ETHERNET_DEVICE(0x1069, 6), 210 INTEL_8255X_ETHERNET_DEVICE(0x1069, 6),
211 INTEL_8255X_ETHERNET_DEVICE(0x106A, 6), 211 INTEL_8255X_ETHERNET_DEVICE(0x106A, 6),
212 INTEL_8255X_ETHERNET_DEVICE(0x106B, 6), 212 INTEL_8255X_ETHERNET_DEVICE(0x106B, 6),
213 INTEL_8255X_ETHERNET_DEVICE(0x1091, 7),
214 INTEL_8255X_ETHERNET_DEVICE(0x1092, 7),
215 INTEL_8255X_ETHERNET_DEVICE(0x1093, 7),
216 INTEL_8255X_ETHERNET_DEVICE(0x1094, 7),
217 INTEL_8255X_ETHERNET_DEVICE(0x1095, 7),
213 INTEL_8255X_ETHERNET_DEVICE(0x1209, 0), 218 INTEL_8255X_ETHERNET_DEVICE(0x1209, 0),
214 INTEL_8255X_ETHERNET_DEVICE(0x1229, 0), 219 INTEL_8255X_ETHERNET_DEVICE(0x1229, 0),
215 INTEL_8255X_ETHERNET_DEVICE(0x2449, 2), 220 INTEL_8255X_ETHERNET_DEVICE(0x2449, 2),
216 INTEL_8255X_ETHERNET_DEVICE(0x2459, 2), 221 INTEL_8255X_ETHERNET_DEVICE(0x2459, 2),
217 INTEL_8255X_ETHERNET_DEVICE(0x245D, 2), 222 INTEL_8255X_ETHERNET_DEVICE(0x245D, 2),
223 INTEL_8255X_ETHERNET_DEVICE(0x27DC, 7),
218 { 0, } 224 { 0, }
219}; 225};
220MODULE_DEVICE_TABLE(pci, e100_id_table); 226MODULE_DEVICE_TABLE(pci, e100_id_table);
@@ -269,6 +275,12 @@ enum scb_status {
269 rus_mask = 0x3C, 275 rus_mask = 0x3C,
270}; 276};
271 277
278enum ru_state {
279 RU_SUSPENDED = 0,
280 RU_RUNNING = 1,
281 RU_UNINITIALIZED = -1,
282};
283
272enum scb_stat_ack { 284enum scb_stat_ack {
273 stat_ack_not_ours = 0x00, 285 stat_ack_not_ours = 0x00,
274 stat_ack_sw_gen = 0x04, 286 stat_ack_sw_gen = 0x04,
@@ -510,7 +522,7 @@ struct nic {
510 struct rx *rx_to_use; 522 struct rx *rx_to_use;
511 struct rx *rx_to_clean; 523 struct rx *rx_to_clean;
512 struct rfd blank_rfd; 524 struct rfd blank_rfd;
513 int ru_running; 525 enum ru_state ru_running;
514 526
515 spinlock_t cb_lock ____cacheline_aligned; 527 spinlock_t cb_lock ____cacheline_aligned;
516 spinlock_t cmd_lock; 528 spinlock_t cmd_lock;
@@ -539,6 +551,7 @@ struct nic {
539 struct timer_list watchdog; 551 struct timer_list watchdog;
540 struct timer_list blink_timer; 552 struct timer_list blink_timer;
541 struct mii_if_info mii; 553 struct mii_if_info mii;
554 struct work_struct tx_timeout_task;
542 enum loopback loopback; 555 enum loopback loopback;
543 556
544 struct mem *mem; 557 struct mem *mem;
@@ -770,7 +783,7 @@ static int e100_eeprom_save(struct nic *nic, u16 start, u16 count)
770 return 0; 783 return 0;
771} 784}
772 785
773#define E100_WAIT_SCB_TIMEOUT 40 786#define E100_WAIT_SCB_TIMEOUT 20000 /* we might have to wait 100ms!!! */
774static inline int e100_exec_cmd(struct nic *nic, u8 cmd, dma_addr_t dma_addr) 787static inline int e100_exec_cmd(struct nic *nic, u8 cmd, dma_addr_t dma_addr)
775{ 788{
776 unsigned long flags; 789 unsigned long flags;
@@ -840,6 +853,10 @@ static inline int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
840 * because the controller is too busy, so 853 * because the controller is too busy, so
841 * let's just queue the command and try again 854 * let's just queue the command and try again
842 * when another command is scheduled. */ 855 * when another command is scheduled. */
856 if(err == -ENOSPC) {
857 //request a reset
858 schedule_work(&nic->tx_timeout_task);
859 }
843 break; 860 break;
844 } else { 861 } else {
845 nic->cuc_cmd = cuc_resume; 862 nic->cuc_cmd = cuc_resume;
@@ -884,7 +901,7 @@ static void mdio_write(struct net_device *netdev, int addr, int reg, int data)
884 901
885static void e100_get_defaults(struct nic *nic) 902static void e100_get_defaults(struct nic *nic)
886{ 903{
887 struct param_range rfds = { .min = 64, .max = 256, .count = 64 }; 904 struct param_range rfds = { .min = 16, .max = 256, .count = 64 };
888 struct param_range cbs = { .min = 64, .max = 256, .count = 64 }; 905 struct param_range cbs = { .min = 64, .max = 256, .count = 64 };
889 906
890 pci_read_config_byte(nic->pdev, PCI_REVISION_ID, &nic->rev_id); 907 pci_read_config_byte(nic->pdev, PCI_REVISION_ID, &nic->rev_id);
@@ -899,8 +916,9 @@ static void e100_get_defaults(struct nic *nic)
899 /* Quadwords to DMA into FIFO before starting frame transmit */ 916 /* Quadwords to DMA into FIFO before starting frame transmit */
900 nic->tx_threshold = 0xE0; 917 nic->tx_threshold = 0xE0;
901 918
902 nic->tx_command = cpu_to_le16(cb_tx | cb_i | cb_tx_sf | 919 /* no interrupt for every tx completion, delay = 256us if not 557*/
903 ((nic->mac >= mac_82558_D101_A4) ? cb_cid : 0)); 920 nic->tx_command = cpu_to_le16(cb_tx | cb_tx_sf |
921 ((nic->mac >= mac_82558_D101_A4) ? cb_cid : cb_i));
904 922
905 /* Template for a freshly allocated RFD */ 923 /* Template for a freshly allocated RFD */
906 nic->blank_rfd.command = cpu_to_le16(cb_el); 924 nic->blank_rfd.command = cpu_to_le16(cb_el);
@@ -964,7 +982,8 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
964 if(nic->flags & multicast_all) 982 if(nic->flags & multicast_all)
965 config->multicast_all = 0x1; /* 1=accept, 0=no */ 983 config->multicast_all = 0x1; /* 1=accept, 0=no */
966 984
967 if(!(nic->flags & wol_magic)) 985 /* disable WoL when up */
986 if(netif_running(nic->netdev) || !(nic->flags & wol_magic))
968 config->magic_packet_disable = 0x1; /* 1=off, 0=on */ 987 config->magic_packet_disable = 0x1; /* 1=off, 0=on */
969 988
970 if(nic->mac >= mac_82558_D101_A4) { 989 if(nic->mac >= mac_82558_D101_A4) {
@@ -1203,7 +1222,9 @@ static void e100_update_stats(struct nic *nic)
1203 } 1222 }
1204 } 1223 }
1205 1224
1206 e100_exec_cmd(nic, cuc_dump_reset, 0); 1225
1226 if(e100_exec_cmd(nic, cuc_dump_reset, 0))
1227 DPRINTK(TX_ERR, DEBUG, "exec cuc_dump_reset failed\n");
1207} 1228}
1208 1229
1209static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex) 1230static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex)
@@ -1279,12 +1300,15 @@ static inline void e100_xmit_prepare(struct nic *nic, struct cb *cb,
1279 struct sk_buff *skb) 1300 struct sk_buff *skb)
1280{ 1301{
1281 cb->command = nic->tx_command; 1302 cb->command = nic->tx_command;
1303 /* interrupt every 16 packets regardless of delay */
1304 if((nic->cbs_avail & ~15) == nic->cbs_avail) cb->command |= cb_i;
1282 cb->u.tcb.tbd_array = cb->dma_addr + offsetof(struct cb, u.tcb.tbd); 1305 cb->u.tcb.tbd_array = cb->dma_addr + offsetof(struct cb, u.tcb.tbd);
1283 cb->u.tcb.tcb_byte_count = 0; 1306 cb->u.tcb.tcb_byte_count = 0;
1284 cb->u.tcb.threshold = nic->tx_threshold; 1307 cb->u.tcb.threshold = nic->tx_threshold;
1285 cb->u.tcb.tbd_count = 1; 1308 cb->u.tcb.tbd_count = 1;
1286 cb->u.tcb.tbd.buf_addr = cpu_to_le32(pci_map_single(nic->pdev, 1309 cb->u.tcb.tbd.buf_addr = cpu_to_le32(pci_map_single(nic->pdev,
1287 skb->data, skb->len, PCI_DMA_TODEVICE)); 1310 skb->data, skb->len, PCI_DMA_TODEVICE));
1311 // check for mapping failure?
1288 cb->u.tcb.tbd.size = cpu_to_le16(skb->len); 1312 cb->u.tcb.tbd.size = cpu_to_le16(skb->len);
1289} 1313}
1290 1314
@@ -1297,7 +1321,8 @@ static int e100_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1297 /* SW workaround for ICH[x] 10Mbps/half duplex Tx hang. 1321 /* SW workaround for ICH[x] 10Mbps/half duplex Tx hang.
1298 Issue a NOP command followed by a 1us delay before 1322 Issue a NOP command followed by a 1us delay before
1299 issuing the Tx command. */ 1323 issuing the Tx command. */
1300 e100_exec_cmd(nic, cuc_nop, 0); 1324 if(e100_exec_cmd(nic, cuc_nop, 0))
1325 DPRINTK(TX_ERR, DEBUG, "exec cuc_nop failed\n");
1301 udelay(1); 1326 udelay(1);
1302 } 1327 }
1303 1328
@@ -1415,12 +1440,18 @@ static int e100_alloc_cbs(struct nic *nic)
1415 return 0; 1440 return 0;
1416} 1441}
1417 1442
1418static inline void e100_start_receiver(struct nic *nic) 1443static inline void e100_start_receiver(struct nic *nic, struct rx *rx)
1419{ 1444{
1445 if(!nic->rxs) return;
1446 if(RU_SUSPENDED != nic->ru_running) return;
1447
1448 /* handle init time starts */
1449 if(!rx) rx = nic->rxs;
1450
1420 /* (Re)start RU if suspended or idle and RFA is non-NULL */ 1451 /* (Re)start RU if suspended or idle and RFA is non-NULL */
1421 if(!nic->ru_running && nic->rx_to_clean->skb) { 1452 if(rx->skb) {
1422 e100_exec_cmd(nic, ruc_start, nic->rx_to_clean->dma_addr); 1453 e100_exec_cmd(nic, ruc_start, rx->dma_addr);
1423 nic->ru_running = 1; 1454 nic->ru_running = RU_RUNNING;
1424 } 1455 }
1425} 1456}
1426 1457
@@ -1437,6 +1468,13 @@ static inline int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)
1437 rx->dma_addr = pci_map_single(nic->pdev, rx->skb->data, 1468 rx->dma_addr = pci_map_single(nic->pdev, rx->skb->data,
1438 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); 1469 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
1439 1470
1471 if(pci_dma_mapping_error(rx->dma_addr)) {
1472 dev_kfree_skb_any(rx->skb);
1473 rx->skb = 0;
1474 rx->dma_addr = 0;
1475 return -ENOMEM;
1476 }
1477
1440 /* Link the RFD to end of RFA by linking previous RFD to 1478 /* Link the RFD to end of RFA by linking previous RFD to
1441 * this one, and clearing EL bit of previous. */ 1479 * this one, and clearing EL bit of previous. */
1442 if(rx->prev->skb) { 1480 if(rx->prev->skb) {
@@ -1471,7 +1509,7 @@ static inline int e100_rx_indicate(struct nic *nic, struct rx *rx,
1471 1509
1472 /* If data isn't ready, nothing to indicate */ 1510 /* If data isn't ready, nothing to indicate */
1473 if(unlikely(!(rfd_status & cb_complete))) 1511 if(unlikely(!(rfd_status & cb_complete)))
1474 return -EAGAIN; 1512 return -ENODATA;
1475 1513
1476 /* Get actual data size */ 1514 /* Get actual data size */
1477 actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF; 1515 actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF;
@@ -1482,6 +1520,10 @@ static inline int e100_rx_indicate(struct nic *nic, struct rx *rx,
1482 pci_unmap_single(nic->pdev, rx->dma_addr, 1520 pci_unmap_single(nic->pdev, rx->dma_addr,
1483 RFD_BUF_LEN, PCI_DMA_FROMDEVICE); 1521 RFD_BUF_LEN, PCI_DMA_FROMDEVICE);
1484 1522
1523 /* this allows for a fast restart without re-enabling interrupts */
1524 if(le16_to_cpu(rfd->command) & cb_el)
1525 nic->ru_running = RU_SUSPENDED;
1526
1485 /* Pull off the RFD and put the actual data (minus eth hdr) */ 1527 /* Pull off the RFD and put the actual data (minus eth hdr) */
1486 skb_reserve(skb, sizeof(struct rfd)); 1528 skb_reserve(skb, sizeof(struct rfd));
1487 skb_put(skb, actual_size); 1529 skb_put(skb, actual_size);
@@ -1514,20 +1556,45 @@ static inline void e100_rx_clean(struct nic *nic, unsigned int *work_done,
1514 unsigned int work_to_do) 1556 unsigned int work_to_do)
1515{ 1557{
1516 struct rx *rx; 1558 struct rx *rx;
1559 int restart_required = 0;
1560 struct rx *rx_to_start = NULL;
1561
1562 /* are we already rnr? then pay attention!!! this ensures that
1563 * the state machine progression never allows a start with a
1564 * partially cleaned list, avoiding a race between hardware
1565 * and rx_to_clean when in NAPI mode */
1566 if(RU_SUSPENDED == nic->ru_running)
1567 restart_required = 1;
1517 1568
1518 /* Indicate newly arrived packets */ 1569 /* Indicate newly arrived packets */
1519 for(rx = nic->rx_to_clean; rx->skb; rx = nic->rx_to_clean = rx->next) { 1570 for(rx = nic->rx_to_clean; rx->skb; rx = nic->rx_to_clean = rx->next) {
1520 if(e100_rx_indicate(nic, rx, work_done, work_to_do)) 1571 int err = e100_rx_indicate(nic, rx, work_done, work_to_do);
1572 if(-EAGAIN == err) {
1573 /* hit quota so have more work to do, restart once
1574 * cleanup is complete */
1575 restart_required = 0;
1576 break;
1577 } else if(-ENODATA == err)
1521 break; /* No more to clean */ 1578 break; /* No more to clean */
1522 } 1579 }
1523 1580
1581 /* save our starting point as the place we'll restart the receiver */
1582 if(restart_required)
1583 rx_to_start = nic->rx_to_clean;
1584
1524 /* Alloc new skbs to refill list */ 1585 /* Alloc new skbs to refill list */
1525 for(rx = nic->rx_to_use; !rx->skb; rx = nic->rx_to_use = rx->next) { 1586 for(rx = nic->rx_to_use; !rx->skb; rx = nic->rx_to_use = rx->next) {
1526 if(unlikely(e100_rx_alloc_skb(nic, rx))) 1587 if(unlikely(e100_rx_alloc_skb(nic, rx)))
1527 break; /* Better luck next time (see watchdog) */ 1588 break; /* Better luck next time (see watchdog) */
1528 } 1589 }
1529 1590
1530 e100_start_receiver(nic); 1591 if(restart_required) {
1592 // ack the rnr?
1593 writeb(stat_ack_rnr, &nic->csr->scb.stat_ack);
1594 e100_start_receiver(nic, rx_to_start);
1595 if(work_done)
1596 (*work_done)++;
1597 }
1531} 1598}
1532 1599
1533static void e100_rx_clean_list(struct nic *nic) 1600static void e100_rx_clean_list(struct nic *nic)
@@ -1535,6 +1602,8 @@ static void e100_rx_clean_list(struct nic *nic)
1535 struct rx *rx; 1602 struct rx *rx;
1536 unsigned int i, count = nic->params.rfds.count; 1603 unsigned int i, count = nic->params.rfds.count;
1537 1604
1605 nic->ru_running = RU_UNINITIALIZED;
1606
1538 if(nic->rxs) { 1607 if(nic->rxs) {
1539 for(rx = nic->rxs, i = 0; i < count; rx++, i++) { 1608 for(rx = nic->rxs, i = 0; i < count; rx++, i++) {
1540 if(rx->skb) { 1609 if(rx->skb) {
@@ -1548,7 +1617,6 @@ static void e100_rx_clean_list(struct nic *nic)
1548 } 1617 }
1549 1618
1550 nic->rx_to_use = nic->rx_to_clean = NULL; 1619 nic->rx_to_use = nic->rx_to_clean = NULL;
1551 nic->ru_running = 0;
1552} 1620}
1553 1621
1554static int e100_rx_alloc_list(struct nic *nic) 1622static int e100_rx_alloc_list(struct nic *nic)
@@ -1557,6 +1625,7 @@ static int e100_rx_alloc_list(struct nic *nic)
1557 unsigned int i, count = nic->params.rfds.count; 1625 unsigned int i, count = nic->params.rfds.count;
1558 1626
1559 nic->rx_to_use = nic->rx_to_clean = NULL; 1627 nic->rx_to_use = nic->rx_to_clean = NULL;
1628 nic->ru_running = RU_UNINITIALIZED;
1560 1629
1561 if(!(nic->rxs = kmalloc(sizeof(struct rx) * count, GFP_ATOMIC))) 1630 if(!(nic->rxs = kmalloc(sizeof(struct rx) * count, GFP_ATOMIC)))
1562 return -ENOMEM; 1631 return -ENOMEM;
@@ -1572,6 +1641,7 @@ static int e100_rx_alloc_list(struct nic *nic)
1572 } 1641 }
1573 1642
1574 nic->rx_to_use = nic->rx_to_clean = nic->rxs; 1643 nic->rx_to_use = nic->rx_to_clean = nic->rxs;
1644 nic->ru_running = RU_SUSPENDED;
1575 1645
1576 return 0; 1646 return 0;
1577} 1647}
@@ -1593,7 +1663,7 @@ static irqreturn_t e100_intr(int irq, void *dev_id, struct pt_regs *regs)
1593 1663
1594 /* We hit Receive No Resource (RNR); restart RU after cleaning */ 1664 /* We hit Receive No Resource (RNR); restart RU after cleaning */
1595 if(stat_ack & stat_ack_rnr) 1665 if(stat_ack & stat_ack_rnr)
1596 nic->ru_running = 0; 1666 nic->ru_running = RU_SUSPENDED;
1597 1667
1598 e100_disable_irq(nic); 1668 e100_disable_irq(nic);
1599 netif_rx_schedule(netdev); 1669 netif_rx_schedule(netdev);
@@ -1663,6 +1733,7 @@ static int e100_change_mtu(struct net_device *netdev, int new_mtu)
1663 return 0; 1733 return 0;
1664} 1734}
1665 1735
1736#ifdef CONFIG_PM
1666static int e100_asf(struct nic *nic) 1737static int e100_asf(struct nic *nic)
1667{ 1738{
1668 /* ASF can be enabled from eeprom */ 1739 /* ASF can be enabled from eeprom */
@@ -1671,6 +1742,7 @@ static int e100_asf(struct nic *nic)
1671 !(nic->eeprom[eeprom_config_asf] & eeprom_gcl) && 1742 !(nic->eeprom[eeprom_config_asf] & eeprom_gcl) &&
1672 ((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE)); 1743 ((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE));
1673} 1744}
1745#endif
1674 1746
1675static int e100_up(struct nic *nic) 1747static int e100_up(struct nic *nic)
1676{ 1748{
@@ -1683,13 +1755,16 @@ static int e100_up(struct nic *nic)
1683 if((err = e100_hw_init(nic))) 1755 if((err = e100_hw_init(nic)))
1684 goto err_clean_cbs; 1756 goto err_clean_cbs;
1685 e100_set_multicast_list(nic->netdev); 1757 e100_set_multicast_list(nic->netdev);
1686 e100_start_receiver(nic); 1758 e100_start_receiver(nic, 0);
1687 mod_timer(&nic->watchdog, jiffies); 1759 mod_timer(&nic->watchdog, jiffies);
1688 if((err = request_irq(nic->pdev->irq, e100_intr, SA_SHIRQ, 1760 if((err = request_irq(nic->pdev->irq, e100_intr, SA_SHIRQ,
1689 nic->netdev->name, nic->netdev))) 1761 nic->netdev->name, nic->netdev)))
1690 goto err_no_irq; 1762 goto err_no_irq;
1691 e100_enable_irq(nic);
1692 netif_wake_queue(nic->netdev); 1763 netif_wake_queue(nic->netdev);
1764 netif_poll_enable(nic->netdev);
1765 /* enable ints _after_ enabling poll, preventing a race between
1766 * disable ints+schedule */
1767 e100_enable_irq(nic);
1693 return 0; 1768 return 0;
1694 1769
1695err_no_irq: 1770err_no_irq:
@@ -1703,11 +1778,13 @@ err_rx_clean_list:
1703 1778
1704static void e100_down(struct nic *nic) 1779static void e100_down(struct nic *nic)
1705{ 1780{
1781 /* wait here for poll to complete */
1782 netif_poll_disable(nic->netdev);
1783 netif_stop_queue(nic->netdev);
1706 e100_hw_reset(nic); 1784 e100_hw_reset(nic);
1707 free_irq(nic->pdev->irq, nic->netdev); 1785 free_irq(nic->pdev->irq, nic->netdev);
1708 del_timer_sync(&nic->watchdog); 1786 del_timer_sync(&nic->watchdog);
1709 netif_carrier_off(nic->netdev); 1787 netif_carrier_off(nic->netdev);
1710 netif_stop_queue(nic->netdev);
1711 e100_clean_cbs(nic); 1788 e100_clean_cbs(nic);
1712 e100_rx_clean_list(nic); 1789 e100_rx_clean_list(nic);
1713} 1790}
@@ -1716,6 +1793,15 @@ static void e100_tx_timeout(struct net_device *netdev)
1716{ 1793{
1717 struct nic *nic = netdev_priv(netdev); 1794 struct nic *nic = netdev_priv(netdev);
1718 1795
1796 /* Reset outside of interrupt context, to avoid request_irq
1797 * in interrupt context */
1798 schedule_work(&nic->tx_timeout_task);
1799}
1800
1801static void e100_tx_timeout_task(struct net_device *netdev)
1802{
1803 struct nic *nic = netdev_priv(netdev);
1804
1719 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n", 1805 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n",
1720 readb(&nic->csr->scb.status)); 1806 readb(&nic->csr->scb.status));
1721 e100_down(netdev_priv(netdev)); 1807 e100_down(netdev_priv(netdev));
@@ -1749,7 +1835,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
1749 mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, 1835 mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR,
1750 BMCR_LOOPBACK); 1836 BMCR_LOOPBACK);
1751 1837
1752 e100_start_receiver(nic); 1838 e100_start_receiver(nic, 0);
1753 1839
1754 if(!(skb = dev_alloc_skb(ETH_DATA_LEN))) { 1840 if(!(skb = dev_alloc_skb(ETH_DATA_LEN))) {
1755 err = -ENOMEM; 1841 err = -ENOMEM;
@@ -1869,7 +1955,6 @@ static int e100_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1869 else 1955 else
1870 nic->flags &= ~wol_magic; 1956 nic->flags &= ~wol_magic;
1871 1957
1872 pci_enable_wake(nic->pdev, 0, nic->flags & (wol_magic | e100_asf(nic)));
1873 e100_exec_cb(nic, NULL, e100_configure); 1958 e100_exec_cb(nic, NULL, e100_configure);
1874 1959
1875 return 0; 1960 return 0;
@@ -2223,6 +2308,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2223 2308
2224 e100_get_defaults(nic); 2309 e100_get_defaults(nic);
2225 2310
2311 /* locks must be initialized before calling hw_reset */
2226 spin_lock_init(&nic->cb_lock); 2312 spin_lock_init(&nic->cb_lock);
2227 spin_lock_init(&nic->cmd_lock); 2313 spin_lock_init(&nic->cmd_lock);
2228 2314
@@ -2240,6 +2326,9 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2240 nic->blink_timer.function = e100_blink_led; 2326 nic->blink_timer.function = e100_blink_led;
2241 nic->blink_timer.data = (unsigned long)nic; 2327 nic->blink_timer.data = (unsigned long)nic;
2242 2328
2329 INIT_WORK(&nic->tx_timeout_task,
2330 (void (*)(void *))e100_tx_timeout_task, netdev);
2331
2243 if((err = e100_alloc(nic))) { 2332 if((err = e100_alloc(nic))) {
2244 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n"); 2333 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n");
2245 goto err_out_iounmap; 2334 goto err_out_iounmap;
@@ -2263,7 +2352,8 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2263 (nic->eeprom[eeprom_id] & eeprom_id_wol)) 2352 (nic->eeprom[eeprom_id] & eeprom_id_wol))
2264 nic->flags |= wol_magic; 2353 nic->flags |= wol_magic;
2265 2354
2266 pci_enable_wake(pdev, 0, nic->flags & (wol_magic | e100_asf(nic))); 2355 /* ack any pending wake events, disable PME */
2356 pci_enable_wake(pdev, 0, 0);
2267 2357
2268 strcpy(netdev->name, "eth%d"); 2358 strcpy(netdev->name, "eth%d");
2269 if((err = register_netdev(netdev))) { 2359 if((err = register_netdev(netdev))) {
@@ -2335,7 +2425,10 @@ static int e100_resume(struct pci_dev *pdev)
2335 2425
2336 pci_set_power_state(pdev, PCI_D0); 2426 pci_set_power_state(pdev, PCI_D0);
2337 pci_restore_state(pdev); 2427 pci_restore_state(pdev);
2338 e100_hw_init(nic); 2428 /* ack any pending wake events, disable PME */
2429 pci_enable_wake(pdev, 0, 0);
2430 if(e100_hw_init(nic))
2431 DPRINTK(HW, ERR, "e100_hw_init failed\n");
2339 2432
2340 netif_device_attach(netdev); 2433 netif_device_attach(netdev);
2341 if(netif_running(netdev)) 2434 if(netif_running(netdev))
@@ -2345,6 +2438,21 @@ static int e100_resume(struct pci_dev *pdev)
2345} 2438}
2346#endif 2439#endif
2347 2440
2441
2442static void e100_shutdown(struct device *dev)
2443{
2444 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
2445 struct net_device *netdev = pci_get_drvdata(pdev);
2446 struct nic *nic = netdev_priv(netdev);
2447
2448#ifdef CONFIG_PM
2449 pci_enable_wake(pdev, 0, nic->flags & (wol_magic | e100_asf(nic)));
2450#else
2451 pci_enable_wake(pdev, 0, nic->flags & (wol_magic));
2452#endif
2453}
2454
2455
2348static struct pci_driver e100_driver = { 2456static struct pci_driver e100_driver = {
2349 .name = DRV_NAME, 2457 .name = DRV_NAME,
2350 .id_table = e100_id_table, 2458 .id_table = e100_id_table,
@@ -2354,6 +2462,11 @@ static struct pci_driver e100_driver = {
2354 .suspend = e100_suspend, 2462 .suspend = e100_suspend,
2355 .resume = e100_resume, 2463 .resume = e100_resume,
2356#endif 2464#endif
2465
2466 .driver = {
2467 .shutdown = e100_shutdown,
2468 }
2469
2357}; 2470};
2358 2471
2359static int __init e100_init_module(void) 2472static int __init e100_init_module(void)
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 148930d4e9bd..af1e82c5b808 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -112,6 +112,8 @@ struct e1000_adapter;
112#define E1000_MAX_82544_RXD 4096 112#define E1000_MAX_82544_RXD 4096
113 113
114/* Supported Rx Buffer Sizes */ 114/* Supported Rx Buffer Sizes */
115#define E1000_RXBUFFER_128 128 /* Used for packet split */
116#define E1000_RXBUFFER_256 256 /* Used for packet split */
115#define E1000_RXBUFFER_2048 2048 117#define E1000_RXBUFFER_2048 2048
116#define E1000_RXBUFFER_4096 4096 118#define E1000_RXBUFFER_4096 4096
117#define E1000_RXBUFFER_8192 8192 119#define E1000_RXBUFFER_8192 8192
@@ -137,15 +139,19 @@ struct e1000_adapter;
137/* How many Rx Buffers do we bundle into one write to the hardware ? */ 139/* How many Rx Buffers do we bundle into one write to the hardware ? */
138#define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */ 140#define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */
139 141
140#define AUTO_ALL_MODES 0 142#define AUTO_ALL_MODES 0
141#define E1000_EEPROM_82544_APM 0x0004 143#define E1000_EEPROM_82544_APM 0x0400
142#define E1000_EEPROM_APME 0x0400 144#define E1000_EEPROM_APME 0x0400
143 145
144#ifndef E1000_MASTER_SLAVE 146#ifndef E1000_MASTER_SLAVE
145/* Switch to override PHY master/slave setting */ 147/* Switch to override PHY master/slave setting */
146#define E1000_MASTER_SLAVE e1000_ms_hw_default 148#define E1000_MASTER_SLAVE e1000_ms_hw_default
147#endif 149#endif
148 150
151#define E1000_MNG_VLAN_NONE -1
152/* Number of packet split data buffers (not including the header buffer) */
153#define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1
154
149/* only works for sizes that are powers of 2 */ 155/* only works for sizes that are powers of 2 */
150#define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1))) 156#define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
151 157
@@ -159,6 +165,9 @@ struct e1000_buffer {
159 uint16_t next_to_watch; 165 uint16_t next_to_watch;
160}; 166};
161 167
168struct e1000_ps_page { struct page *ps_page[MAX_PS_BUFFERS]; };
169struct e1000_ps_page_dma { uint64_t ps_page_dma[MAX_PS_BUFFERS]; };
170
162struct e1000_desc_ring { 171struct e1000_desc_ring {
163 /* pointer to the descriptor ring memory */ 172 /* pointer to the descriptor ring memory */
164 void *desc; 173 void *desc;
@@ -174,12 +183,19 @@ struct e1000_desc_ring {
174 unsigned int next_to_clean; 183 unsigned int next_to_clean;
175 /* array of buffer information structs */ 184 /* array of buffer information structs */
176 struct e1000_buffer *buffer_info; 185 struct e1000_buffer *buffer_info;
186 /* arrays of page information for packet split */
187 struct e1000_ps_page *ps_page;
188 struct e1000_ps_page_dma *ps_page_dma;
177}; 189};
178 190
179#define E1000_DESC_UNUSED(R) \ 191#define E1000_DESC_UNUSED(R) \
180 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \ 192 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
181 (R)->next_to_clean - (R)->next_to_use - 1) 193 (R)->next_to_clean - (R)->next_to_use - 1)
182 194
195#define E1000_RX_DESC_PS(R, i) \
196 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
197#define E1000_RX_DESC_EXT(R, i) \
198 (&(((union e1000_rx_desc_extended *)((R).desc))[i]))
183#define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i])) 199#define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
184#define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc) 200#define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc)
185#define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc) 201#define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
@@ -192,6 +208,7 @@ struct e1000_adapter {
192 struct timer_list watchdog_timer; 208 struct timer_list watchdog_timer;
193 struct timer_list phy_info_timer; 209 struct timer_list phy_info_timer;
194 struct vlan_group *vlgrp; 210 struct vlan_group *vlgrp;
211 uint16_t mng_vlan_id;
195 uint32_t bd_number; 212 uint32_t bd_number;
196 uint32_t rx_buffer_len; 213 uint32_t rx_buffer_len;
197 uint32_t part_num; 214 uint32_t part_num;
@@ -228,14 +245,23 @@ struct e1000_adapter {
228 boolean_t detect_tx_hung; 245 boolean_t detect_tx_hung;
229 246
230 /* RX */ 247 /* RX */
248#ifdef CONFIG_E1000_NAPI
249 boolean_t (*clean_rx) (struct e1000_adapter *adapter, int *work_done,
250 int work_to_do);
251#else
252 boolean_t (*clean_rx) (struct e1000_adapter *adapter);
253#endif
254 void (*alloc_rx_buf) (struct e1000_adapter *adapter);
231 struct e1000_desc_ring rx_ring; 255 struct e1000_desc_ring rx_ring;
232 uint64_t hw_csum_err; 256 uint64_t hw_csum_err;
233 uint64_t hw_csum_good; 257 uint64_t hw_csum_good;
234 uint32_t rx_int_delay; 258 uint32_t rx_int_delay;
235 uint32_t rx_abs_int_delay; 259 uint32_t rx_abs_int_delay;
236 boolean_t rx_csum; 260 boolean_t rx_csum;
261 boolean_t rx_ps;
237 uint32_t gorcl; 262 uint32_t gorcl;
238 uint64_t gorcl_old; 263 uint64_t gorcl_old;
264 uint16_t rx_ps_bsize0;
239 265
240 /* Interrupt Throttle Rate */ 266 /* Interrupt Throttle Rate */
241 uint32_t itr; 267 uint32_t itr;
@@ -257,5 +283,8 @@ struct e1000_adapter {
257 283
258 284
259 int msg_enable; 285 int msg_enable;
286#ifdef CONFIG_PCI_MSI
287 boolean_t have_msi;
288#endif
260}; 289};
261#endif /* _E1000_H_ */ 290#endif /* _E1000_H_ */
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 0a2ca7c73a41..237247f74df4 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -69,6 +69,7 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
69 { "rx_crc_errors", E1000_STAT(net_stats.rx_crc_errors) }, 69 { "rx_crc_errors", E1000_STAT(net_stats.rx_crc_errors) },
70 { "rx_frame_errors", E1000_STAT(net_stats.rx_frame_errors) }, 70 { "rx_frame_errors", E1000_STAT(net_stats.rx_frame_errors) },
71 { "rx_fifo_errors", E1000_STAT(net_stats.rx_fifo_errors) }, 71 { "rx_fifo_errors", E1000_STAT(net_stats.rx_fifo_errors) },
72 { "rx_no_buffer_count", E1000_STAT(stats.rnbc) },
72 { "rx_missed_errors", E1000_STAT(net_stats.rx_missed_errors) }, 73 { "rx_missed_errors", E1000_STAT(net_stats.rx_missed_errors) },
73 { "tx_aborted_errors", E1000_STAT(net_stats.tx_aborted_errors) }, 74 { "tx_aborted_errors", E1000_STAT(net_stats.tx_aborted_errors) },
74 { "tx_carrier_errors", E1000_STAT(net_stats.tx_carrier_errors) }, 75 { "tx_carrier_errors", E1000_STAT(net_stats.tx_carrier_errors) },
@@ -593,7 +594,7 @@ e1000_set_ringparam(struct net_device *netdev,
593 tx_old = adapter->tx_ring; 594 tx_old = adapter->tx_ring;
594 rx_old = adapter->rx_ring; 595 rx_old = adapter->rx_ring;
595 596
596 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 597 if((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
597 return -EINVAL; 598 return -EINVAL;
598 599
599 if(netif_running(adapter->netdev)) 600 if(netif_running(adapter->netdev))
@@ -784,8 +785,8 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
784 /* Hook up test interrupt handler just for this test */ 785 /* Hook up test interrupt handler just for this test */
785 if(!request_irq(irq, &e1000_test_intr, 0, netdev->name, netdev)) { 786 if(!request_irq(irq, &e1000_test_intr, 0, netdev->name, netdev)) {
786 shared_int = FALSE; 787 shared_int = FALSE;
787 } else if(request_irq(irq, &e1000_test_intr, SA_SHIRQ, 788 } else if(request_irq(irq, &e1000_test_intr, SA_SHIRQ,
788 netdev->name, netdev)){ 789 netdev->name, netdev)){
789 *data = 1; 790 *data = 1;
790 return -1; 791 return -1;
791 } 792 }
@@ -842,10 +843,8 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
842 * test failed. 843 * test failed.
843 */ 844 */
844 adapter->test_icr = 0; 845 adapter->test_icr = 0;
845 E1000_WRITE_REG(&adapter->hw, IMC, 846 E1000_WRITE_REG(&adapter->hw, IMC, ~mask & 0x00007FFF);
846 (~mask & 0x00007FFF)); 847 E1000_WRITE_REG(&adapter->hw, ICS, ~mask & 0x00007FFF);
847 E1000_WRITE_REG(&adapter->hw, ICS,
848 (~mask & 0x00007FFF));
849 msec_delay(10); 848 msec_delay(10);
850 849
851 if(adapter->test_icr) { 850 if(adapter->test_icr) {
@@ -919,7 +918,8 @@ e1000_setup_desc_rings(struct e1000_adapter *adapter)
919 918
920 /* Setup Tx descriptor ring and Tx buffers */ 919 /* Setup Tx descriptor ring and Tx buffers */
921 920
922 txdr->count = 80; 921 if(!txdr->count)
922 txdr->count = E1000_DEFAULT_TXD;
923 923
924 size = txdr->count * sizeof(struct e1000_buffer); 924 size = txdr->count * sizeof(struct e1000_buffer);
925 if(!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) { 925 if(!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
@@ -974,7 +974,8 @@ e1000_setup_desc_rings(struct e1000_adapter *adapter)
974 974
975 /* Setup Rx descriptor ring and Rx buffers */ 975 /* Setup Rx descriptor ring and Rx buffers */
976 976
977 rxdr->count = 80; 977 if(!rxdr->count)
978 rxdr->count = E1000_DEFAULT_RXD;
978 979
979 size = rxdr->count * sizeof(struct e1000_buffer); 980 size = rxdr->count * sizeof(struct e1000_buffer);
980 if(!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) { 981 if(!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
@@ -1008,7 +1009,7 @@ e1000_setup_desc_rings(struct e1000_adapter *adapter)
1008 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i); 1009 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i);
1009 struct sk_buff *skb; 1010 struct sk_buff *skb;
1010 1011
1011 if(!(skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN, 1012 if(!(skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN,
1012 GFP_KERNEL))) { 1013 GFP_KERNEL))) {
1013 ret_val = 6; 1014 ret_val = 6;
1014 goto err_nomem; 1015 goto err_nomem;
@@ -1310,31 +1311,62 @@ e1000_run_loopback_test(struct e1000_adapter *adapter)
1310 struct e1000_desc_ring *txdr = &adapter->test_tx_ring; 1311 struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
1311 struct e1000_desc_ring *rxdr = &adapter->test_rx_ring; 1312 struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
1312 struct pci_dev *pdev = adapter->pdev; 1313 struct pci_dev *pdev = adapter->pdev;
1313 int i, ret_val; 1314 int i, j, k, l, lc, good_cnt, ret_val=0;
1315 unsigned long time;
1314 1316
1315 E1000_WRITE_REG(&adapter->hw, RDT, rxdr->count - 1); 1317 E1000_WRITE_REG(&adapter->hw, RDT, rxdr->count - 1);
1316 1318
1317 for(i = 0; i < 64; i++) { 1319 /* Calculate the loop count based on the largest descriptor ring
1318 e1000_create_lbtest_frame(txdr->buffer_info[i].skb, 1024); 1320 * The idea is to wrap the largest ring a number of times using 64
1319 pci_dma_sync_single_for_device(pdev, txdr->buffer_info[i].dma, 1321 * send/receive pairs during each loop
1320 txdr->buffer_info[i].length, 1322 */
1321 PCI_DMA_TODEVICE);
1322 }
1323 E1000_WRITE_REG(&adapter->hw, TDT, i);
1324
1325 msec_delay(200);
1326
1327 i = 0;
1328 do {
1329 pci_dma_sync_single_for_cpu(pdev, rxdr->buffer_info[i].dma,
1330 rxdr->buffer_info[i].length,
1331 PCI_DMA_FROMDEVICE);
1332
1333 ret_val = e1000_check_lbtest_frame(rxdr->buffer_info[i].skb,
1334 1024);
1335 i++;
1336 } while (ret_val != 0 && i < 64);
1337 1323
1324 if(rxdr->count <= txdr->count)
1325 lc = ((txdr->count / 64) * 2) + 1;
1326 else
1327 lc = ((rxdr->count / 64) * 2) + 1;
1328
1329 k = l = 0;
1330 for(j = 0; j <= lc; j++) { /* loop count loop */
1331 for(i = 0; i < 64; i++) { /* send the packets */
1332 e1000_create_lbtest_frame(txdr->buffer_info[i].skb,
1333 1024);
1334 pci_dma_sync_single_for_device(pdev,
1335 txdr->buffer_info[k].dma,
1336 txdr->buffer_info[k].length,
1337 PCI_DMA_TODEVICE);
1338 if(unlikely(++k == txdr->count)) k = 0;
1339 }
1340 E1000_WRITE_REG(&adapter->hw, TDT, k);
1341 msec_delay(200);
1342 time = jiffies; /* set the start time for the receive */
1343 good_cnt = 0;
1344 do { /* receive the sent packets */
1345 pci_dma_sync_single_for_cpu(pdev,
1346 rxdr->buffer_info[l].dma,
1347 rxdr->buffer_info[l].length,
1348 PCI_DMA_FROMDEVICE);
1349
1350 ret_val = e1000_check_lbtest_frame(
1351 rxdr->buffer_info[l].skb,
1352 1024);
1353 if(!ret_val)
1354 good_cnt++;
1355 if(unlikely(++l == rxdr->count)) l = 0;
1356 /* time + 20 msecs (200 msecs on 2.4) is more than
1357 * enough time to complete the receives, if it's
1358 * exceeded, break and error off
1359 */
1360 } while (good_cnt < 64 && jiffies < (time + 20));
1361 if(good_cnt != 64) {
1362 ret_val = 13; /* ret_val is the same as mis-compare */
1363 break;
1364 }
1365 if(jiffies >= (time + 2)) {
1366 ret_val = 14; /* error code for time out error */
1367 break;
1368 }
1369 } /* end loop count loop */
1338 return ret_val; 1370 return ret_val;
1339} 1371}
1340 1372
@@ -1354,13 +1386,12 @@ static int
1354e1000_link_test(struct e1000_adapter *adapter, uint64_t *data) 1386e1000_link_test(struct e1000_adapter *adapter, uint64_t *data)
1355{ 1387{
1356 *data = 0; 1388 *data = 0;
1357
1358 if (adapter->hw.media_type == e1000_media_type_internal_serdes) { 1389 if (adapter->hw.media_type == e1000_media_type_internal_serdes) {
1359 int i = 0; 1390 int i = 0;
1360 adapter->hw.serdes_link_down = TRUE; 1391 adapter->hw.serdes_link_down = TRUE;
1361 1392
1362 /* on some blade server designs link establishment */ 1393 /* On some blade server designs, link establishment
1363 /* could take as long as 2-3 minutes. */ 1394 * could take as long as 2-3 minutes */
1364 do { 1395 do {
1365 e1000_check_for_link(&adapter->hw); 1396 e1000_check_for_link(&adapter->hw);
1366 if (adapter->hw.serdes_link_down == FALSE) 1397 if (adapter->hw.serdes_link_down == FALSE)
@@ -1368,9 +1399,11 @@ e1000_link_test(struct e1000_adapter *adapter, uint64_t *data)
1368 msec_delay(20); 1399 msec_delay(20);
1369 } while (i++ < 3750); 1400 } while (i++ < 3750);
1370 1401
1371 *data = 1; 1402 *data = 1;
1372 } else { 1403 } else {
1373 e1000_check_for_link(&adapter->hw); 1404 e1000_check_for_link(&adapter->hw);
1405 if(adapter->hw.autoneg) /* if auto_neg is set wait for it */
1406 msec_delay(4000);
1374 1407
1375 if(!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) { 1408 if(!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) {
1376 *data = 1; 1409 *data = 1;
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index 786a9b935659..723589b28be5 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -63,10 +63,11 @@ static uint16_t e1000_shift_in_ee_bits(struct e1000_hw *hw, uint16_t count);
63static int32_t e1000_acquire_eeprom(struct e1000_hw *hw); 63static int32_t e1000_acquire_eeprom(struct e1000_hw *hw);
64static void e1000_release_eeprom(struct e1000_hw *hw); 64static void e1000_release_eeprom(struct e1000_hw *hw);
65static void e1000_standby_eeprom(struct e1000_hw *hw); 65static void e1000_standby_eeprom(struct e1000_hw *hw);
66static int32_t e1000_id_led_init(struct e1000_hw * hw);
67static int32_t e1000_set_vco_speed(struct e1000_hw *hw); 66static int32_t e1000_set_vco_speed(struct e1000_hw *hw);
68static int32_t e1000_polarity_reversal_workaround(struct e1000_hw *hw); 67static int32_t e1000_polarity_reversal_workaround(struct e1000_hw *hw);
69static int32_t e1000_set_phy_mode(struct e1000_hw *hw); 68static int32_t e1000_set_phy_mode(struct e1000_hw *hw);
69static int32_t e1000_host_if_read_cookie(struct e1000_hw *hw, uint8_t *buffer);
70static uint8_t e1000_calculate_mng_checksum(char *buffer, uint32_t length);
70 71
71/* IGP cable length table */ 72/* IGP cable length table */
72static const 73static const
@@ -80,6 +81,17 @@ uint16_t e1000_igp_cable_length_table[IGP01E1000_AGC_LENGTH_TABLE_SIZE] =
80 100, 100, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 81 100, 100, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
81 110, 110, 110, 110, 110, 110, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120}; 82 110, 110, 110, 110, 110, 110, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120};
82 83
84static const
85uint16_t e1000_igp_2_cable_length_table[IGP02E1000_AGC_LENGTH_TABLE_SIZE] =
86 { 8, 13, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43,
87 22, 24, 27, 30, 32, 35, 37, 40, 42, 44, 47, 49, 51, 54, 56, 58,
88 32, 35, 38, 41, 44, 47, 50, 53, 55, 58, 61, 63, 66, 69, 71, 74,
89 43, 47, 51, 54, 58, 61, 64, 67, 71, 74, 77, 80, 82, 85, 88, 90,
90 57, 62, 66, 70, 74, 77, 81, 85, 88, 91, 94, 97, 100, 103, 106, 108,
91 73, 78, 82, 87, 91, 95, 98, 102, 105, 109, 112, 114, 117, 119, 122, 124,
92 91, 96, 101, 105, 109, 113, 116, 119, 122, 125, 127, 128, 128, 128, 128, 128,
93 108, 113, 117, 121, 124, 127, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128};
94
83 95
84/****************************************************************************** 96/******************************************************************************
85 * Set the phy type member in the hw struct. 97 * Set the phy type member in the hw struct.
@@ -91,10 +103,14 @@ e1000_set_phy_type(struct e1000_hw *hw)
91{ 103{
92 DEBUGFUNC("e1000_set_phy_type"); 104 DEBUGFUNC("e1000_set_phy_type");
93 105
106 if(hw->mac_type == e1000_undefined)
107 return -E1000_ERR_PHY_TYPE;
108
94 switch(hw->phy_id) { 109 switch(hw->phy_id) {
95 case M88E1000_E_PHY_ID: 110 case M88E1000_E_PHY_ID:
96 case M88E1000_I_PHY_ID: 111 case M88E1000_I_PHY_ID:
97 case M88E1011_I_PHY_ID: 112 case M88E1011_I_PHY_ID:
113 case M88E1111_I_PHY_ID:
98 hw->phy_type = e1000_phy_m88; 114 hw->phy_type = e1000_phy_m88;
99 break; 115 break;
100 case IGP01E1000_I_PHY_ID: 116 case IGP01E1000_I_PHY_ID:
@@ -128,7 +144,6 @@ e1000_phy_init_script(struct e1000_hw *hw)
128 144
129 DEBUGFUNC("e1000_phy_init_script"); 145 DEBUGFUNC("e1000_phy_init_script");
130 146
131
132 if(hw->phy_init_script) { 147 if(hw->phy_init_script) {
133 msec_delay(20); 148 msec_delay(20);
134 149
@@ -271,6 +286,7 @@ e1000_set_mac_type(struct e1000_hw *hw)
271 case E1000_DEV_ID_82546GB_FIBER: 286 case E1000_DEV_ID_82546GB_FIBER:
272 case E1000_DEV_ID_82546GB_SERDES: 287 case E1000_DEV_ID_82546GB_SERDES:
273 case E1000_DEV_ID_82546GB_PCIE: 288 case E1000_DEV_ID_82546GB_PCIE:
289 case E1000_DEV_ID_82546GB_QUAD_COPPER:
274 hw->mac_type = e1000_82546_rev_3; 290 hw->mac_type = e1000_82546_rev_3;
275 break; 291 break;
276 case E1000_DEV_ID_82541EI: 292 case E1000_DEV_ID_82541EI:
@@ -289,12 +305,19 @@ e1000_set_mac_type(struct e1000_hw *hw)
289 case E1000_DEV_ID_82547GI: 305 case E1000_DEV_ID_82547GI:
290 hw->mac_type = e1000_82547_rev_2; 306 hw->mac_type = e1000_82547_rev_2;
291 break; 307 break;
308 case E1000_DEV_ID_82573E:
309 case E1000_DEV_ID_82573E_IAMT:
310 hw->mac_type = e1000_82573;
311 break;
292 default: 312 default:
293 /* Should never have loaded on this device */ 313 /* Should never have loaded on this device */
294 return -E1000_ERR_MAC_TYPE; 314 return -E1000_ERR_MAC_TYPE;
295 } 315 }
296 316
297 switch(hw->mac_type) { 317 switch(hw->mac_type) {
318 case e1000_82573:
319 hw->eeprom_semaphore_present = TRUE;
320 /* fall through */
298 case e1000_82541: 321 case e1000_82541:
299 case e1000_82547: 322 case e1000_82547:
300 case e1000_82541_rev_2: 323 case e1000_82541_rev_2:
@@ -360,6 +383,9 @@ e1000_reset_hw(struct e1000_hw *hw)
360 uint32_t icr; 383 uint32_t icr;
361 uint32_t manc; 384 uint32_t manc;
362 uint32_t led_ctrl; 385 uint32_t led_ctrl;
386 uint32_t timeout;
387 uint32_t extcnf_ctrl;
388 int32_t ret_val;
363 389
364 DEBUGFUNC("e1000_reset_hw"); 390 DEBUGFUNC("e1000_reset_hw");
365 391
@@ -369,6 +395,15 @@ e1000_reset_hw(struct e1000_hw *hw)
369 e1000_pci_clear_mwi(hw); 395 e1000_pci_clear_mwi(hw);
370 } 396 }
371 397
398 if(hw->bus_type == e1000_bus_type_pci_express) {
399 /* Prevent the PCI-E bus from sticking if there is no TLP connection
400 * on the last TLP read/write transaction when MAC is reset.
401 */
402 if(e1000_disable_pciex_master(hw) != E1000_SUCCESS) {
403 DEBUGOUT("PCI-E Master disable polling has failed.\n");
404 }
405 }
406
372 /* Clear interrupt mask to stop board from generating interrupts */ 407 /* Clear interrupt mask to stop board from generating interrupts */
373 DEBUGOUT("Masking off all interrupts\n"); 408 DEBUGOUT("Masking off all interrupts\n");
374 E1000_WRITE_REG(hw, IMC, 0xffffffff); 409 E1000_WRITE_REG(hw, IMC, 0xffffffff);
@@ -393,10 +428,32 @@ e1000_reset_hw(struct e1000_hw *hw)
393 428
394 /* Must reset the PHY before resetting the MAC */ 429 /* Must reset the PHY before resetting the MAC */
395 if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) { 430 if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
396 E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_PHY_RST)); 431 E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_PHY_RST));
397 msec_delay(5); 432 msec_delay(5);
398 } 433 }
399 434
435 /* Must acquire the MDIO ownership before MAC reset.
436 * Ownership defaults to firmware after a reset. */
437 if(hw->mac_type == e1000_82573) {
438 timeout = 10;
439
440 extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
441 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
442
443 do {
444 E1000_WRITE_REG(hw, EXTCNF_CTRL, extcnf_ctrl);
445 extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
446
447 if(extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
448 break;
449 else
450 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
451
452 msec_delay(2);
453 timeout--;
454 } while(timeout);
455 }
456
400 /* Issue a global reset to the MAC. This will reset the chip's 457 /* Issue a global reset to the MAC. This will reset the chip's
401 * transmit, receive, DMA, and link units. It will not effect 458 * transmit, receive, DMA, and link units. It will not effect
402 * the current PCI configuration. The global reset bit is self- 459 * the current PCI configuration. The global reset bit is self-
@@ -450,6 +507,18 @@ e1000_reset_hw(struct e1000_hw *hw)
450 /* Wait for EEPROM reload */ 507 /* Wait for EEPROM reload */
451 msec_delay(20); 508 msec_delay(20);
452 break; 509 break;
510 case e1000_82573:
511 udelay(10);
512 ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
513 ctrl_ext |= E1000_CTRL_EXT_EE_RST;
514 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
515 E1000_WRITE_FLUSH(hw);
516 /* fall through */
517 ret_val = e1000_get_auto_rd_done(hw);
518 if(ret_val)
519 /* We don't want to continue accessing MAC registers. */
520 return ret_val;
521 break;
453 default: 522 default:
454 /* Wait for EEPROM reload (it happens automatically) */ 523 /* Wait for EEPROM reload (it happens automatically) */
455 msec_delay(5); 524 msec_delay(5);
@@ -457,7 +526,7 @@ e1000_reset_hw(struct e1000_hw *hw)
457 } 526 }
458 527
459 /* Disable HW ARPs on ASF enabled adapters */ 528 /* Disable HW ARPs on ASF enabled adapters */
460 if(hw->mac_type >= e1000_82540) { 529 if(hw->mac_type >= e1000_82540 && hw->mac_type <= e1000_82547_rev_2) {
461 manc = E1000_READ_REG(hw, MANC); 530 manc = E1000_READ_REG(hw, MANC);
462 manc &= ~(E1000_MANC_ARP_EN); 531 manc &= ~(E1000_MANC_ARP_EN);
463 E1000_WRITE_REG(hw, MANC, manc); 532 E1000_WRITE_REG(hw, MANC, manc);
@@ -510,6 +579,8 @@ e1000_init_hw(struct e1000_hw *hw)
510 uint16_t pcix_stat_hi_word; 579 uint16_t pcix_stat_hi_word;
511 uint16_t cmd_mmrbc; 580 uint16_t cmd_mmrbc;
512 uint16_t stat_mmrbc; 581 uint16_t stat_mmrbc;
582 uint32_t mta_size;
583
513 DEBUGFUNC("e1000_init_hw"); 584 DEBUGFUNC("e1000_init_hw");
514 585
515 /* Initialize Identification LED */ 586 /* Initialize Identification LED */
@@ -524,8 +595,8 @@ e1000_init_hw(struct e1000_hw *hw)
524 595
525 /* Disabling VLAN filtering. */ 596 /* Disabling VLAN filtering. */
526 DEBUGOUT("Initializing the IEEE VLAN\n"); 597 DEBUGOUT("Initializing the IEEE VLAN\n");
527 E1000_WRITE_REG(hw, VET, 0); 598 if (hw->mac_type < e1000_82545_rev_3)
528 599 E1000_WRITE_REG(hw, VET, 0);
529 e1000_clear_vfta(hw); 600 e1000_clear_vfta(hw);
530 601
531 /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */ 602 /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
@@ -553,14 +624,16 @@ e1000_init_hw(struct e1000_hw *hw)
553 624
554 /* Zero out the Multicast HASH table */ 625 /* Zero out the Multicast HASH table */
555 DEBUGOUT("Zeroing the MTA\n"); 626 DEBUGOUT("Zeroing the MTA\n");
556 for(i = 0; i < E1000_MC_TBL_SIZE; i++) 627 mta_size = E1000_MC_TBL_SIZE;
628 for(i = 0; i < mta_size; i++)
557 E1000_WRITE_REG_ARRAY(hw, MTA, i, 0); 629 E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
558 630
559 /* Set the PCI priority bit correctly in the CTRL register. This 631 /* Set the PCI priority bit correctly in the CTRL register. This
560 * determines if the adapter gives priority to receives, or if it 632 * determines if the adapter gives priority to receives, or if it
561 * gives equal priority to transmits and receives. 633 * gives equal priority to transmits and receives. Valid only on
634 * 82542 and 82543 silicon.
562 */ 635 */
563 if(hw->dma_fairness) { 636 if(hw->dma_fairness && hw->mac_type <= e1000_82543) {
564 ctrl = E1000_READ_REG(hw, CTRL); 637 ctrl = E1000_READ_REG(hw, CTRL);
565 E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PRIOR); 638 E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PRIOR);
566 } 639 }
@@ -598,9 +671,21 @@ e1000_init_hw(struct e1000_hw *hw)
598 if(hw->mac_type > e1000_82544) { 671 if(hw->mac_type > e1000_82544) {
599 ctrl = E1000_READ_REG(hw, TXDCTL); 672 ctrl = E1000_READ_REG(hw, TXDCTL);
600 ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB; 673 ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
674 switch (hw->mac_type) {
675 default:
676 break;
677 case e1000_82573:
678 ctrl |= E1000_TXDCTL_COUNT_DESC;
679 break;
680 }
601 E1000_WRITE_REG(hw, TXDCTL, ctrl); 681 E1000_WRITE_REG(hw, TXDCTL, ctrl);
602 } 682 }
603 683
684 if (hw->mac_type == e1000_82573) {
685 e1000_enable_tx_pkt_filtering(hw);
686 }
687
688
604 /* Clear all of the statistics registers (clear on read). It is 689 /* Clear all of the statistics registers (clear on read). It is
605 * important that we do this after we have tried to establish link 690 * important that we do this after we have tried to establish link
606 * because the symbol error count will increment wildly if there 691 * because the symbol error count will increment wildly if there
@@ -679,7 +764,7 @@ e1000_setup_link(struct e1000_hw *hw)
679 * control setting, then the variable hw->fc will 764 * control setting, then the variable hw->fc will
680 * be initialized based on a value in the EEPROM. 765 * be initialized based on a value in the EEPROM.
681 */ 766 */
682 if(e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data) < 0) { 767 if(e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data)) {
683 DEBUGOUT("EEPROM Read Error\n"); 768 DEBUGOUT("EEPROM Read Error\n");
684 return -E1000_ERR_EEPROM; 769 return -E1000_ERR_EEPROM;
685 } 770 }
@@ -736,6 +821,7 @@ e1000_setup_link(struct e1000_hw *hw)
736 E1000_WRITE_REG(hw, FCAL, FLOW_CONTROL_ADDRESS_LOW); 821 E1000_WRITE_REG(hw, FCAL, FLOW_CONTROL_ADDRESS_LOW);
737 E1000_WRITE_REG(hw, FCAH, FLOW_CONTROL_ADDRESS_HIGH); 822 E1000_WRITE_REG(hw, FCAH, FLOW_CONTROL_ADDRESS_HIGH);
738 E1000_WRITE_REG(hw, FCT, FLOW_CONTROL_TYPE); 823 E1000_WRITE_REG(hw, FCT, FLOW_CONTROL_TYPE);
824
739 E1000_WRITE_REG(hw, FCTTV, hw->fc_pause_time); 825 E1000_WRITE_REG(hw, FCTTV, hw->fc_pause_time);
740 826
741 /* Set the flow control receive threshold registers. Normally, 827 /* Set the flow control receive threshold registers. Normally,
@@ -906,20 +992,18 @@ e1000_setup_fiber_serdes_link(struct e1000_hw *hw)
906} 992}
907 993
908/****************************************************************************** 994/******************************************************************************
909* Detects which PHY is present and the speed and duplex 995* Make sure we have a valid PHY and change PHY mode before link setup.
910* 996*
911* hw - Struct containing variables accessed by shared code 997* hw - Struct containing variables accessed by shared code
912******************************************************************************/ 998******************************************************************************/
913static int32_t 999static int32_t
914e1000_setup_copper_link(struct e1000_hw *hw) 1000e1000_copper_link_preconfig(struct e1000_hw *hw)
915{ 1001{
916 uint32_t ctrl; 1002 uint32_t ctrl;
917 uint32_t led_ctrl;
918 int32_t ret_val; 1003 int32_t ret_val;
919 uint16_t i;
920 uint16_t phy_data; 1004 uint16_t phy_data;
921 1005
922 DEBUGFUNC("e1000_setup_copper_link"); 1006 DEBUGFUNC("e1000_copper_link_preconfig");
923 1007
924 ctrl = E1000_READ_REG(hw, CTRL); 1008 ctrl = E1000_READ_REG(hw, CTRL);
925 /* With 82543, we need to force speed and duplex on the MAC equal to what 1009 /* With 82543, we need to force speed and duplex on the MAC equal to what
@@ -933,7 +1017,9 @@ e1000_setup_copper_link(struct e1000_hw *hw)
933 } else { 1017 } else {
934 ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_SLU); 1018 ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_SLU);
935 E1000_WRITE_REG(hw, CTRL, ctrl); 1019 E1000_WRITE_REG(hw, CTRL, ctrl);
936 e1000_phy_hw_reset(hw); 1020 ret_val = e1000_phy_hw_reset(hw);
1021 if(ret_val)
1022 return ret_val;
937 } 1023 }
938 1024
939 /* Make sure we have a valid PHY */ 1025 /* Make sure we have a valid PHY */
@@ -961,274 +1047,398 @@ e1000_setup_copper_link(struct e1000_hw *hw)
961 hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2) 1047 hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2)
962 hw->phy_reset_disable = FALSE; 1048 hw->phy_reset_disable = FALSE;
963 1049
964 if(!hw->phy_reset_disable) { 1050 return E1000_SUCCESS;
965 if (hw->phy_type == e1000_phy_igp) { 1051}
966 1052
967 ret_val = e1000_phy_reset(hw);
968 if(ret_val) {
969 DEBUGOUT("Error Resetting the PHY\n");
970 return ret_val;
971 }
972 1053
973 /* Wait 10ms for MAC to configure PHY from eeprom settings */ 1054/********************************************************************
974 msec_delay(15); 1055* Copper link setup for e1000_phy_igp series.
1056*
1057* hw - Struct containing variables accessed by shared code
1058*********************************************************************/
1059static int32_t
1060e1000_copper_link_igp_setup(struct e1000_hw *hw)
1061{
1062 uint32_t led_ctrl;
1063 int32_t ret_val;
1064 uint16_t phy_data;
975 1065
976 /* Configure activity LED after PHY reset */ 1066 DEBUGFUNC("e1000_copper_link_igp_setup");
977 led_ctrl = E1000_READ_REG(hw, LEDCTL);
978 led_ctrl &= IGP_ACTIVITY_LED_MASK;
979 led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
980 E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
981 1067
982 /* disable lplu d3 during driver init */ 1068 if (hw->phy_reset_disable)
983 ret_val = e1000_set_d3_lplu_state(hw, FALSE); 1069 return E1000_SUCCESS;
984 if(ret_val) { 1070
985 DEBUGOUT("Error Disabling LPLU D3\n"); 1071 ret_val = e1000_phy_reset(hw);
986 return ret_val; 1072 if (ret_val) {
987 } 1073 DEBUGOUT("Error Resetting the PHY\n");
1074 return ret_val;
1075 }
988 1076
989 /* Configure mdi-mdix settings */ 1077 /* Wait 10ms for MAC to configure PHY from eeprom settings */
990 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, 1078 msec_delay(15);
991 &phy_data);
992 if(ret_val)
993 return ret_val;
994 1079
995 if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) { 1080 /* Configure activity LED after PHY reset */
996 hw->dsp_config_state = e1000_dsp_config_disabled; 1081 led_ctrl = E1000_READ_REG(hw, LEDCTL);
997 /* Force MDI for earlier revs of the IGP PHY */ 1082 led_ctrl &= IGP_ACTIVITY_LED_MASK;
998 phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX | 1083 led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
999 IGP01E1000_PSCR_FORCE_MDI_MDIX); 1084 E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
1000 hw->mdix = 1;
1001 1085
1002 } else { 1086 /* disable lplu d3 during driver init */
1003 hw->dsp_config_state = e1000_dsp_config_enabled; 1087 ret_val = e1000_set_d3_lplu_state(hw, FALSE);
1004 phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX; 1088 if (ret_val) {
1005 1089 DEBUGOUT("Error Disabling LPLU D3\n");
1006 switch (hw->mdix) { 1090 return ret_val;
1007 case 1: 1091 }
1008 phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
1009 break;
1010 case 2:
1011 phy_data |= IGP01E1000_PSCR_FORCE_MDI_MDIX;
1012 break;
1013 case 0:
1014 default:
1015 phy_data |= IGP01E1000_PSCR_AUTO_MDIX;
1016 break;
1017 }
1018 }
1019 ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL,
1020 phy_data);
1021 if(ret_val)
1022 return ret_val;
1023 1092
1024 /* set auto-master slave resolution settings */ 1093 /* disable lplu d0 during driver init */
1025 if(hw->autoneg) { 1094 ret_val = e1000_set_d0_lplu_state(hw, FALSE);
1026 e1000_ms_type phy_ms_setting = hw->master_slave; 1095 if (ret_val) {
1096 DEBUGOUT("Error Disabling LPLU D0\n");
1097 return ret_val;
1098 }
1099 /* Configure mdi-mdix settings */
1100 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
1101 if (ret_val)
1102 return ret_val;
1027 1103
1028 if(hw->ffe_config_state == e1000_ffe_config_active) 1104 if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
1029 hw->ffe_config_state = e1000_ffe_config_enabled; 1105 hw->dsp_config_state = e1000_dsp_config_disabled;
1106 /* Force MDI for earlier revs of the IGP PHY */
1107 phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX | IGP01E1000_PSCR_FORCE_MDI_MDIX);
1108 hw->mdix = 1;
1030 1109
1031 if(hw->dsp_config_state == e1000_dsp_config_activated) 1110 } else {
1032 hw->dsp_config_state = e1000_dsp_config_enabled; 1111 hw->dsp_config_state = e1000_dsp_config_enabled;
1112 phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
1033 1113
1034 /* when autonegotiation advertisment is only 1000Mbps then we 1114 switch (hw->mdix) {
1035 * should disable SmartSpeed and enable Auto MasterSlave 1115 case 1:
1036 * resolution as hardware default. */ 1116 phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
1037 if(hw->autoneg_advertised == ADVERTISE_1000_FULL) { 1117 break;
1038 /* Disable SmartSpeed */ 1118 case 2:
1039 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, 1119 phy_data |= IGP01E1000_PSCR_FORCE_MDI_MDIX;
1040 &phy_data); 1120 break;
1041 if(ret_val) 1121 case 0:
1042 return ret_val; 1122 default:
1043 phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED; 1123 phy_data |= IGP01E1000_PSCR_AUTO_MDIX;
1044 ret_val = e1000_write_phy_reg(hw, 1124 break;
1045 IGP01E1000_PHY_PORT_CONFIG, 1125 }
1046 phy_data); 1126 }
1047 if(ret_val) 1127 ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
1048 return ret_val; 1128 if(ret_val)
1049 /* Set auto Master/Slave resolution process */ 1129 return ret_val;
1050 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data);
1051 if(ret_val)
1052 return ret_val;
1053 phy_data &= ~CR_1000T_MS_ENABLE;
1054 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
1055 if(ret_val)
1056 return ret_val;
1057 }
1058 1130
1059 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data); 1131 /* set auto-master slave resolution settings */
1060 if(ret_val) 1132 if(hw->autoneg) {
1061 return ret_val; 1133 e1000_ms_type phy_ms_setting = hw->master_slave;
1062 1134
1063 /* load defaults for future use */ 1135 if(hw->ffe_config_state == e1000_ffe_config_active)
1064 hw->original_master_slave = (phy_data & CR_1000T_MS_ENABLE) ? 1136 hw->ffe_config_state = e1000_ffe_config_enabled;
1065 ((phy_data & CR_1000T_MS_VALUE) ? 1137
1066 e1000_ms_force_master : 1138 if(hw->dsp_config_state == e1000_dsp_config_activated)
1067 e1000_ms_force_slave) : 1139 hw->dsp_config_state = e1000_dsp_config_enabled;
1068 e1000_ms_auto; 1140
1069 1141 /* when autonegotiation advertisment is only 1000Mbps then we
1070 switch (phy_ms_setting) { 1142 * should disable SmartSpeed and enable Auto MasterSlave
1071 case e1000_ms_force_master: 1143 * resolution as hardware default. */
1072 phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE); 1144 if(hw->autoneg_advertised == ADVERTISE_1000_FULL) {
1073 break; 1145 /* Disable SmartSpeed */
1074 case e1000_ms_force_slave: 1146 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data);
1075 phy_data |= CR_1000T_MS_ENABLE; 1147 if(ret_val)
1076 phy_data &= ~(CR_1000T_MS_VALUE); 1148 return ret_val;
1077 break; 1149 phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
1078 case e1000_ms_auto: 1150 ret_val = e1000_write_phy_reg(hw,
1079 phy_data &= ~CR_1000T_MS_ENABLE; 1151 IGP01E1000_PHY_PORT_CONFIG,
1080 default: 1152 phy_data);
1081 break; 1153 if(ret_val)
1082 } 1154 return ret_val;
1083 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data); 1155 /* Set auto Master/Slave resolution process */
1084 if(ret_val) 1156 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data);
1085 return ret_val; 1157 if(ret_val)
1086 } 1158 return ret_val;
1087 } else { 1159 phy_data &= ~CR_1000T_MS_ENABLE;
1088 /* Enable CRS on TX. This must be set for half-duplex operation. */ 1160 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
1089 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
1090 &phy_data);
1091 if(ret_val) 1161 if(ret_val)
1092 return ret_val; 1162 return ret_val;
1163 }
1093 1164
1094 phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX; 1165 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data);
1166 if(ret_val)
1167 return ret_val;
1095 1168
1096 /* Options: 1169 /* load defaults for future use */
1097 * MDI/MDI-X = 0 (default) 1170 hw->original_master_slave = (phy_data & CR_1000T_MS_ENABLE) ?
1098 * 0 - Auto for all speeds 1171 ((phy_data & CR_1000T_MS_VALUE) ?
1099 * 1 - MDI mode 1172 e1000_ms_force_master :
1100 * 2 - MDI-X mode 1173 e1000_ms_force_slave) :
1101 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) 1174 e1000_ms_auto;
1102 */
1103 phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
1104 1175
1105 switch (hw->mdix) { 1176 switch (phy_ms_setting) {
1106 case 1: 1177 case e1000_ms_force_master:
1107 phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE; 1178 phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
1108 break; 1179 break;
1109 case 2: 1180 case e1000_ms_force_slave:
1110 phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE; 1181 phy_data |= CR_1000T_MS_ENABLE;
1111 break; 1182 phy_data &= ~(CR_1000T_MS_VALUE);
1112 case 3: 1183 break;
1113 phy_data |= M88E1000_PSCR_AUTO_X_1000T; 1184 case e1000_ms_auto:
1114 break; 1185 phy_data &= ~CR_1000T_MS_ENABLE;
1115 case 0:
1116 default: 1186 default:
1117 phy_data |= M88E1000_PSCR_AUTO_X_MODE; 1187 break;
1118 break; 1188 }
1119 } 1189 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
1190 if(ret_val)
1191 return ret_val;
1192 }
1120 1193
1121 /* Options: 1194 return E1000_SUCCESS;
1122 * disable_polarity_correction = 0 (default) 1195}
1123 * Automatic Correction for Reversed Cable Polarity
1124 * 0 - Disabled
1125 * 1 - Enabled
1126 */
1127 phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL;
1128 if(hw->disable_polarity_correction == 1)
1129 phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
1130 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
1131 phy_data);
1132 if(ret_val)
1133 return ret_val;
1134 1196
1135 /* Force TX_CLK in the Extended PHY Specific Control Register
1136 * to 25MHz clock.
1137 */
1138 ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL,
1139 &phy_data);
1140 if(ret_val)
1141 return ret_val;
1142 1197
1143 phy_data |= M88E1000_EPSCR_TX_CLK_25; 1198/********************************************************************
1199* Copper link setup for e1000_phy_m88 series.
1200*
1201* hw - Struct containing variables accessed by shared code
1202*********************************************************************/
1203static int32_t
1204e1000_copper_link_mgp_setup(struct e1000_hw *hw)
1205{
1206 int32_t ret_val;
1207 uint16_t phy_data;
1208
1209 DEBUGFUNC("e1000_copper_link_mgp_setup");
1210
1211 if(hw->phy_reset_disable)
1212 return E1000_SUCCESS;
1213
1214 /* Enable CRS on TX. This must be set for half-duplex operation. */
1215 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
1216 if(ret_val)
1217 return ret_val;
1218
1219 phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
1220
1221 /* Options:
1222 * MDI/MDI-X = 0 (default)
1223 * 0 - Auto for all speeds
1224 * 1 - MDI mode
1225 * 2 - MDI-X mode
1226 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
1227 */
1228 phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
1229
1230 switch (hw->mdix) {
1231 case 1:
1232 phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE;
1233 break;
1234 case 2:
1235 phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE;
1236 break;
1237 case 3:
1238 phy_data |= M88E1000_PSCR_AUTO_X_1000T;
1239 break;
1240 case 0:
1241 default:
1242 phy_data |= M88E1000_PSCR_AUTO_X_MODE;
1243 break;
1244 }
1245
1246 /* Options:
1247 * disable_polarity_correction = 0 (default)
1248 * Automatic Correction for Reversed Cable Polarity
1249 * 0 - Disabled
1250 * 1 - Enabled
1251 */
1252 phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL;
1253 if(hw->disable_polarity_correction == 1)
1254 phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
1255 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
1256 if(ret_val)
1257 return ret_val;
1144 1258
1145 if (hw->phy_revision < M88E1011_I_REV_4) { 1259 /* Force TX_CLK in the Extended PHY Specific Control Register
1146 /* Configure Master and Slave downshift values */ 1260 * to 25MHz clock.
1147 phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK | 1261 */
1262 ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
1263 if(ret_val)
1264 return ret_val;
1265
1266 phy_data |= M88E1000_EPSCR_TX_CLK_25;
1267
1268 if (hw->phy_revision < M88E1011_I_REV_4) {
1269 /* Configure Master and Slave downshift values */
1270 phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
1148 M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK); 1271 M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
1149 phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X | 1272 phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
1150 M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X); 1273 M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
1151 ret_val = e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, 1274 ret_val = e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
1152 phy_data); 1275 if(ret_val)
1153 if(ret_val) 1276 return ret_val;
1154 return ret_val; 1277 }
1155 }
1156 1278
1157 /* SW Reset the PHY so all changes take effect */ 1279 /* SW Reset the PHY so all changes take effect */
1158 ret_val = e1000_phy_reset(hw); 1280 ret_val = e1000_phy_reset(hw);
1159 if(ret_val) { 1281 if(ret_val) {
1160 DEBUGOUT("Error Resetting the PHY\n"); 1282 DEBUGOUT("Error Resetting the PHY\n");
1161 return ret_val; 1283 return ret_val;
1162 } 1284 }
1285
1286 return E1000_SUCCESS;
1287}
1288
1289/********************************************************************
1290* Setup auto-negotiation and flow control advertisements,
1291* and then perform auto-negotiation.
1292*
1293* hw - Struct containing variables accessed by shared code
1294*********************************************************************/
1295static int32_t
1296e1000_copper_link_autoneg(struct e1000_hw *hw)
1297{
1298 int32_t ret_val;
1299 uint16_t phy_data;
1300
1301 DEBUGFUNC("e1000_copper_link_autoneg");
1302
1303 /* Perform some bounds checking on the hw->autoneg_advertised
1304 * parameter. If this variable is zero, then set it to the default.
1305 */
1306 hw->autoneg_advertised &= AUTONEG_ADVERTISE_SPEED_DEFAULT;
1307
1308 /* If autoneg_advertised is zero, we assume it was not defaulted
1309 * by the calling code so we set to advertise full capability.
1310 */
1311 if(hw->autoneg_advertised == 0)
1312 hw->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT;
1313
1314 DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
1315 ret_val = e1000_phy_setup_autoneg(hw);
1316 if(ret_val) {
1317 DEBUGOUT("Error Setting up Auto-Negotiation\n");
1318 return ret_val;
1319 }
1320 DEBUGOUT("Restarting Auto-Neg\n");
1321
1322 /* Restart auto-negotiation by setting the Auto Neg Enable bit and
1323 * the Auto Neg Restart bit in the PHY control register.
1324 */
1325 ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data);
1326 if(ret_val)
1327 return ret_val;
1328
1329 phy_data |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
1330 ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data);
1331 if(ret_val)
1332 return ret_val;
1333
1334 /* Does the user want to wait for Auto-Neg to complete here, or
1335 * check at a later time (for example, callback routine).
1336 */
1337 if(hw->wait_autoneg_complete) {
1338 ret_val = e1000_wait_autoneg(hw);
1339 if(ret_val) {
1340 DEBUGOUT("Error while waiting for autoneg to complete\n");
1341 return ret_val;
1163 } 1342 }
1343 }
1164 1344
1165 /* Options: 1345 hw->get_link_status = TRUE;
1166 * autoneg = 1 (default)
1167 * PHY will advertise value(s) parsed from
1168 * autoneg_advertised and fc
1169 * autoneg = 0
1170 * PHY will be set to 10H, 10F, 100H, or 100F
1171 * depending on value parsed from forced_speed_duplex.
1172 */
1173 1346
1174 /* Is autoneg enabled? This is enabled by default or by software 1347 return E1000_SUCCESS;
1175 * override. If so, call e1000_phy_setup_autoneg routine to parse the 1348}
1176 * autoneg_advertised and fc options. If autoneg is NOT enabled, then
1177 * the user should have provided a speed/duplex override. If so, then
1178 * call e1000_phy_force_speed_duplex to parse and set this up.
1179 */
1180 if(hw->autoneg) {
1181 /* Perform some bounds checking on the hw->autoneg_advertised
1182 * parameter. If this variable is zero, then set it to the default.
1183 */
1184 hw->autoneg_advertised &= AUTONEG_ADVERTISE_SPEED_DEFAULT;
1185 1349
1186 /* If autoneg_advertised is zero, we assume it was not defaulted
1187 * by the calling code so we set to advertise full capability.
1188 */
1189 if(hw->autoneg_advertised == 0)
1190 hw->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT;
1191 1350
1192 DEBUGOUT("Reconfiguring auto-neg advertisement params\n"); 1351/******************************************************************************
1193 ret_val = e1000_phy_setup_autoneg(hw); 1352* Config the MAC and the PHY after link is up.
1194 if(ret_val) { 1353* 1) Set up the MAC to the current PHY speed/duplex
1195 DEBUGOUT("Error Setting up Auto-Negotiation\n"); 1354* if we are on 82543. If we
1196 return ret_val; 1355* are on newer silicon, we only need to configure
1197 } 1356* collision distance in the Transmit Control Register.
1198 DEBUGOUT("Restarting Auto-Neg\n"); 1357* 2) Set up flow control on the MAC to that established with
1358* the link partner.
1359* 3) Config DSP to improve Gigabit link quality for some PHY revisions.
1360*
1361* hw - Struct containing variables accessed by shared code
1362******************************************************************************/
1363static int32_t
1364e1000_copper_link_postconfig(struct e1000_hw *hw)
1365{
1366 int32_t ret_val;
1367 DEBUGFUNC("e1000_copper_link_postconfig");
1368
1369 if(hw->mac_type >= e1000_82544) {
1370 e1000_config_collision_dist(hw);
1371 } else {
1372 ret_val = e1000_config_mac_to_phy(hw);
1373 if(ret_val) {
1374 DEBUGOUT("Error configuring MAC to PHY settings\n");
1375 return ret_val;
1376 }
1377 }
1378 ret_val = e1000_config_fc_after_link_up(hw);
1379 if(ret_val) {
1380 DEBUGOUT("Error Configuring Flow Control\n");
1381 return ret_val;
1382 }
1199 1383
1200 /* Restart auto-negotiation by setting the Auto Neg Enable bit and 1384 /* Config DSP to improve Giga link quality */
1201 * the Auto Neg Restart bit in the PHY control register. 1385 if(hw->phy_type == e1000_phy_igp) {
1202 */ 1386 ret_val = e1000_config_dsp_after_link_change(hw, TRUE);
1203 ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data); 1387 if(ret_val) {
1204 if(ret_val) 1388 DEBUGOUT("Error Configuring DSP after link up\n");
1205 return ret_val; 1389 return ret_val;
1390 }
1391 }
1392
1393 return E1000_SUCCESS;
1394}
1206 1395
1207 phy_data |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG); 1396/******************************************************************************
1208 ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data); 1397* Detects which PHY is present and setup the speed and duplex
1209 if(ret_val) 1398*
1210 return ret_val; 1399* hw - Struct containing variables accessed by shared code
1400******************************************************************************/
1401static int32_t
1402e1000_setup_copper_link(struct e1000_hw *hw)
1403{
1404 int32_t ret_val;
1405 uint16_t i;
1406 uint16_t phy_data;
1211 1407
1212 /* Does the user want to wait for Auto-Neg to complete here, or 1408 DEBUGFUNC("e1000_setup_copper_link");
1213 * check at a later time (for example, callback routine). 1409
1214 */ 1410 /* Check if it is a valid PHY and set PHY mode if necessary. */
1215 if(hw->wait_autoneg_complete) { 1411 ret_val = e1000_copper_link_preconfig(hw);
1216 ret_val = e1000_wait_autoneg(hw); 1412 if(ret_val)
1217 if(ret_val) { 1413 return ret_val;
1218 DEBUGOUT("Error while waiting for autoneg to complete\n"); 1414
1219 return ret_val; 1415 if (hw->phy_type == e1000_phy_igp ||
1220 } 1416 hw->phy_type == e1000_phy_igp_2) {
1221 } 1417 ret_val = e1000_copper_link_igp_setup(hw);
1222 hw->get_link_status = TRUE; 1418 if(ret_val)
1223 } else { 1419 return ret_val;
1224 DEBUGOUT("Forcing speed and duplex\n"); 1420 } else if (hw->phy_type == e1000_phy_m88) {
1225 ret_val = e1000_phy_force_speed_duplex(hw); 1421 ret_val = e1000_copper_link_mgp_setup(hw);
1226 if(ret_val) { 1422 if(ret_val)
1227 DEBUGOUT("Error Forcing Speed and Duplex\n"); 1423 return ret_val;
1228 return ret_val; 1424 }
1229 } 1425
1426 if(hw->autoneg) {
1427 /* Setup autoneg and flow control advertisement
1428 * and perform autonegotiation */
1429 ret_val = e1000_copper_link_autoneg(hw);
1430 if(ret_val)
1431 return ret_val;
1432 } else {
1433 /* PHY will be set to 10H, 10F, 100H,or 100F
1434 * depending on value from forced_speed_duplex. */
1435 DEBUGOUT("Forcing speed and duplex\n");
1436 ret_val = e1000_phy_force_speed_duplex(hw);
1437 if(ret_val) {
1438 DEBUGOUT("Error Forcing Speed and Duplex\n");
1439 return ret_val;
1230 } 1440 }
1231 } /* !hw->phy_reset_disable */ 1441 }
1232 1442
1233 /* Check link status. Wait up to 100 microseconds for link to become 1443 /* Check link status. Wait up to 100 microseconds for link to become
1234 * valid. 1444 * valid.
@@ -1242,37 +1452,11 @@ e1000_setup_copper_link(struct e1000_hw *hw)
1242 return ret_val; 1452 return ret_val;
1243 1453
1244 if(phy_data & MII_SR_LINK_STATUS) { 1454 if(phy_data & MII_SR_LINK_STATUS) {
1245 /* We have link, so we need to finish the config process: 1455 /* Config the MAC and PHY after link is up */
1246 * 1) Set up the MAC to the current PHY speed/duplex 1456 ret_val = e1000_copper_link_postconfig(hw);
1247 * if we are on 82543. If we 1457 if(ret_val)
1248 * are on newer silicon, we only need to configure
1249 * collision distance in the Transmit Control Register.
1250 * 2) Set up flow control on the MAC to that established with
1251 * the link partner.
1252 */
1253 if(hw->mac_type >= e1000_82544) {
1254 e1000_config_collision_dist(hw);
1255 } else {
1256 ret_val = e1000_config_mac_to_phy(hw);
1257 if(ret_val) {
1258 DEBUGOUT("Error configuring MAC to PHY settings\n");
1259 return ret_val;
1260 }
1261 }
1262 ret_val = e1000_config_fc_after_link_up(hw);
1263 if(ret_val) {
1264 DEBUGOUT("Error Configuring Flow Control\n");
1265 return ret_val; 1458 return ret_val;
1266 } 1459
1267 DEBUGOUT("Valid link established!!!\n");
1268
1269 if(hw->phy_type == e1000_phy_igp) {
1270 ret_val = e1000_config_dsp_after_link_change(hw, TRUE);
1271 if(ret_val) {
1272 DEBUGOUT("Error Configuring DSP after link up\n");
1273 return ret_val;
1274 }
1275 }
1276 DEBUGOUT("Valid link established!!!\n"); 1460 DEBUGOUT("Valid link established!!!\n");
1277 return E1000_SUCCESS; 1461 return E1000_SUCCESS;
1278 } 1462 }
@@ -1302,10 +1486,10 @@ e1000_phy_setup_autoneg(struct e1000_hw *hw)
1302 if(ret_val) 1486 if(ret_val)
1303 return ret_val; 1487 return ret_val;
1304 1488
1305 /* Read the MII 1000Base-T Control Register (Address 9). */ 1489 /* Read the MII 1000Base-T Control Register (Address 9). */
1306 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg); 1490 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg);
1307 if(ret_val) 1491 if(ret_val)
1308 return ret_val; 1492 return ret_val;
1309 1493
1310 /* Need to parse both autoneg_advertised and fc and set up 1494 /* Need to parse both autoneg_advertised and fc and set up
1311 * the appropriate PHY registers. First we will parse for 1495 * the appropriate PHY registers. First we will parse for
@@ -1417,7 +1601,7 @@ e1000_phy_setup_autoneg(struct e1000_hw *hw)
1417 1601
1418 DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); 1602 DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
1419 1603
1420 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg); 1604 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg);
1421 if(ret_val) 1605 if(ret_val)
1422 return ret_val; 1606 return ret_val;
1423 1607
@@ -1678,6 +1862,11 @@ e1000_config_mac_to_phy(struct e1000_hw *hw)
1678 1862
1679 DEBUGFUNC("e1000_config_mac_to_phy"); 1863 DEBUGFUNC("e1000_config_mac_to_phy");
1680 1864
1865 /* 82544 or newer MAC, Auto Speed Detection takes care of
1866 * MAC speed/duplex configuration.*/
1867 if (hw->mac_type >= e1000_82544)
1868 return E1000_SUCCESS;
1869
1681 /* Read the Device Control Register and set the bits to Force Speed 1870 /* Read the Device Control Register and set the bits to Force Speed
1682 * and Duplex. 1871 * and Duplex.
1683 */ 1872 */
@@ -1688,45 +1877,25 @@ e1000_config_mac_to_phy(struct e1000_hw *hw)
1688 /* Set up duplex in the Device Control and Transmit Control 1877 /* Set up duplex in the Device Control and Transmit Control
1689 * registers depending on negotiated values. 1878 * registers depending on negotiated values.
1690 */ 1879 */
1691 if (hw->phy_type == e1000_phy_igp) { 1880 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
1692 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS, 1881 if(ret_val)
1693 &phy_data); 1882 return ret_val;
1694 if(ret_val)
1695 return ret_val;
1696
1697 if(phy_data & IGP01E1000_PSSR_FULL_DUPLEX) ctrl |= E1000_CTRL_FD;
1698 else ctrl &= ~E1000_CTRL_FD;
1699
1700 e1000_config_collision_dist(hw);
1701 1883
1702 /* Set up speed in the Device Control register depending on 1884 if(phy_data & M88E1000_PSSR_DPLX)
1703 * negotiated values. 1885 ctrl |= E1000_CTRL_FD;
1704 */ 1886 else
1705 if((phy_data & IGP01E1000_PSSR_SPEED_MASK) == 1887 ctrl &= ~E1000_CTRL_FD;
1706 IGP01E1000_PSSR_SPEED_1000MBPS)
1707 ctrl |= E1000_CTRL_SPD_1000;
1708 else if((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
1709 IGP01E1000_PSSR_SPEED_100MBPS)
1710 ctrl |= E1000_CTRL_SPD_100;
1711 } else {
1712 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
1713 &phy_data);
1714 if(ret_val)
1715 return ret_val;
1716 1888
1717 if(phy_data & M88E1000_PSSR_DPLX) ctrl |= E1000_CTRL_FD; 1889 e1000_config_collision_dist(hw);
1718 else ctrl &= ~E1000_CTRL_FD;
1719 1890
1720 e1000_config_collision_dist(hw); 1891 /* Set up speed in the Device Control register depending on
1892 * negotiated values.
1893 */
1894 if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)
1895 ctrl |= E1000_CTRL_SPD_1000;
1896 else if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS)
1897 ctrl |= E1000_CTRL_SPD_100;
1721 1898
1722 /* Set up speed in the Device Control register depending on
1723 * negotiated values.
1724 */
1725 if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)
1726 ctrl |= E1000_CTRL_SPD_1000;
1727 else if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS)
1728 ctrl |= E1000_CTRL_SPD_100;
1729 }
1730 /* Write the configured values back to the Device Control Reg. */ 1899 /* Write the configured values back to the Device Control Reg. */
1731 E1000_WRITE_REG(hw, CTRL, ctrl); 1900 E1000_WRITE_REG(hw, CTRL, ctrl);
1732 return E1000_SUCCESS; 1901 return E1000_SUCCESS;
@@ -2494,8 +2663,8 @@ e1000_read_phy_reg(struct e1000_hw *hw,
2494 2663
2495 DEBUGFUNC("e1000_read_phy_reg"); 2664 DEBUGFUNC("e1000_read_phy_reg");
2496 2665
2497 2666 if((hw->phy_type == e1000_phy_igp ||
2498 if(hw->phy_type == e1000_phy_igp && 2667 hw->phy_type == e1000_phy_igp_2) &&
2499 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) { 2668 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
2500 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT, 2669 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
2501 (uint16_t)reg_addr); 2670 (uint16_t)reg_addr);
@@ -2600,8 +2769,8 @@ e1000_write_phy_reg(struct e1000_hw *hw,
2600 2769
2601 DEBUGFUNC("e1000_write_phy_reg"); 2770 DEBUGFUNC("e1000_write_phy_reg");
2602 2771
2603 2772 if((hw->phy_type == e1000_phy_igp ||
2604 if(hw->phy_type == e1000_phy_igp && 2773 hw->phy_type == e1000_phy_igp_2) &&
2605 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) { 2774 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
2606 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT, 2775 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
2607 (uint16_t)reg_addr); 2776 (uint16_t)reg_addr);
@@ -2679,19 +2848,27 @@ e1000_write_phy_reg_ex(struct e1000_hw *hw,
2679 return E1000_SUCCESS; 2848 return E1000_SUCCESS;
2680} 2849}
2681 2850
2851
2682/****************************************************************************** 2852/******************************************************************************
2683* Returns the PHY to the power-on reset state 2853* Returns the PHY to the power-on reset state
2684* 2854*
2685* hw - Struct containing variables accessed by shared code 2855* hw - Struct containing variables accessed by shared code
2686******************************************************************************/ 2856******************************************************************************/
2687void 2857int32_t
2688e1000_phy_hw_reset(struct e1000_hw *hw) 2858e1000_phy_hw_reset(struct e1000_hw *hw)
2689{ 2859{
2690 uint32_t ctrl, ctrl_ext; 2860 uint32_t ctrl, ctrl_ext;
2691 uint32_t led_ctrl; 2861 uint32_t led_ctrl;
2862 int32_t ret_val;
2692 2863
2693 DEBUGFUNC("e1000_phy_hw_reset"); 2864 DEBUGFUNC("e1000_phy_hw_reset");
2694 2865
2866 /* In the case of the phy reset being blocked, it's not an error, we
2867 * simply return success without performing the reset. */
2868 ret_val = e1000_check_phy_reset_block(hw);
2869 if (ret_val)
2870 return E1000_SUCCESS;
2871
2695 DEBUGOUT("Resetting Phy...\n"); 2872 DEBUGOUT("Resetting Phy...\n");
2696 2873
2697 if(hw->mac_type > e1000_82543) { 2874 if(hw->mac_type > e1000_82543) {
@@ -2727,6 +2904,11 @@ e1000_phy_hw_reset(struct e1000_hw *hw)
2727 led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE); 2904 led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
2728 E1000_WRITE_REG(hw, LEDCTL, led_ctrl); 2905 E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
2729 } 2906 }
2907
2908 /* Wait for FW to finish PHY configuration. */
2909 ret_val = e1000_get_phy_cfg_done(hw);
2910
2911 return ret_val;
2730} 2912}
2731 2913
2732/****************************************************************************** 2914/******************************************************************************
@@ -2744,7 +2926,19 @@ e1000_phy_reset(struct e1000_hw *hw)
2744 2926
2745 DEBUGFUNC("e1000_phy_reset"); 2927 DEBUGFUNC("e1000_phy_reset");
2746 2928
2747 if(hw->mac_type != e1000_82541_rev_2) { 2929 /* In the case of the phy reset being blocked, it's not an error, we
2930 * simply return success without performing the reset. */
2931 ret_val = e1000_check_phy_reset_block(hw);
2932 if (ret_val)
2933 return E1000_SUCCESS;
2934
2935 switch (hw->mac_type) {
2936 case e1000_82541_rev_2:
2937 ret_val = e1000_phy_hw_reset(hw);
2938 if(ret_val)
2939 return ret_val;
2940 break;
2941 default:
2748 ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data); 2942 ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data);
2749 if(ret_val) 2943 if(ret_val)
2750 return ret_val; 2944 return ret_val;
@@ -2755,9 +2949,10 @@ e1000_phy_reset(struct e1000_hw *hw)
2755 return ret_val; 2949 return ret_val;
2756 2950
2757 udelay(1); 2951 udelay(1);
2758 } else e1000_phy_hw_reset(hw); 2952 break;
2953 }
2759 2954
2760 if(hw->phy_type == e1000_phy_igp) 2955 if(hw->phy_type == e1000_phy_igp || hw->phy_type == e1000_phy_igp_2)
2761 e1000_phy_init_script(hw); 2956 e1000_phy_init_script(hw);
2762 2957
2763 return E1000_SUCCESS; 2958 return E1000_SUCCESS;
@@ -2811,6 +3006,9 @@ e1000_detect_gig_phy(struct e1000_hw *hw)
2811 case e1000_82547_rev_2: 3006 case e1000_82547_rev_2:
2812 if(hw->phy_id == IGP01E1000_I_PHY_ID) match = TRUE; 3007 if(hw->phy_id == IGP01E1000_I_PHY_ID) match = TRUE;
2813 break; 3008 break;
3009 case e1000_82573:
3010 if(hw->phy_id == M88E1111_I_PHY_ID) match = TRUE;
3011 break;
2814 default: 3012 default:
2815 DEBUGOUT1("Invalid MAC type %d\n", hw->mac_type); 3013 DEBUGOUT1("Invalid MAC type %d\n", hw->mac_type);
2816 return -E1000_ERR_CONFIG; 3014 return -E1000_ERR_CONFIG;
@@ -2866,7 +3064,7 @@ e1000_phy_igp_get_info(struct e1000_hw *hw,
2866 3064
2867 /* The downshift status is checked only once, after link is established, 3065 /* The downshift status is checked only once, after link is established,
2868 * and it stored in the hw->speed_downgraded parameter. */ 3066 * and it stored in the hw->speed_downgraded parameter. */
2869 phy_info->downshift = hw->speed_downgraded; 3067 phy_info->downshift = (e1000_downshift)hw->speed_downgraded;
2870 3068
2871 /* IGP01E1000 does not need to support it. */ 3069 /* IGP01E1000 does not need to support it. */
2872 phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_normal; 3070 phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_normal;
@@ -2905,7 +3103,7 @@ e1000_phy_igp_get_info(struct e1000_hw *hw,
2905 if(ret_val) 3103 if(ret_val)
2906 return ret_val; 3104 return ret_val;
2907 3105
2908 /* transalte to old method */ 3106 /* Translate to old method */
2909 average = (max_length + min_length) / 2; 3107 average = (max_length + min_length) / 2;
2910 3108
2911 if(average <= e1000_igp_cable_length_50) 3109 if(average <= e1000_igp_cable_length_50)
@@ -2940,7 +3138,7 @@ e1000_phy_m88_get_info(struct e1000_hw *hw,
2940 3138
2941 /* The downshift status is checked only once, after link is established, 3139 /* The downshift status is checked only once, after link is established,
2942 * and it stored in the hw->speed_downgraded parameter. */ 3140 * and it stored in the hw->speed_downgraded parameter. */
2943 phy_info->downshift = hw->speed_downgraded; 3141 phy_info->downshift = (e1000_downshift)hw->speed_downgraded;
2944 3142
2945 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 3143 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
2946 if(ret_val) 3144 if(ret_val)
@@ -3029,7 +3227,8 @@ e1000_phy_get_info(struct e1000_hw *hw,
3029 return -E1000_ERR_CONFIG; 3227 return -E1000_ERR_CONFIG;
3030 } 3228 }
3031 3229
3032 if(hw->phy_type == e1000_phy_igp) 3230 if(hw->phy_type == e1000_phy_igp ||
3231 hw->phy_type == e1000_phy_igp_2)
3033 return e1000_phy_igp_get_info(hw, phy_info); 3232 return e1000_phy_igp_get_info(hw, phy_info);
3034 else 3233 else
3035 return e1000_phy_m88_get_info(hw, phy_info); 3234 return e1000_phy_m88_get_info(hw, phy_info);
@@ -3055,11 +3254,12 @@ e1000_validate_mdi_setting(struct e1000_hw *hw)
3055 * 3254 *
3056 * hw - Struct containing variables accessed by shared code 3255 * hw - Struct containing variables accessed by shared code
3057 *****************************************************************************/ 3256 *****************************************************************************/
3058void 3257int32_t
3059e1000_init_eeprom_params(struct e1000_hw *hw) 3258e1000_init_eeprom_params(struct e1000_hw *hw)
3060{ 3259{
3061 struct e1000_eeprom_info *eeprom = &hw->eeprom; 3260 struct e1000_eeprom_info *eeprom = &hw->eeprom;
3062 uint32_t eecd = E1000_READ_REG(hw, EECD); 3261 uint32_t eecd = E1000_READ_REG(hw, EECD);
3262 int32_t ret_val = E1000_SUCCESS;
3063 uint16_t eeprom_size; 3263 uint16_t eeprom_size;
3064 3264
3065 DEBUGFUNC("e1000_init_eeprom_params"); 3265 DEBUGFUNC("e1000_init_eeprom_params");
@@ -3074,6 +3274,8 @@ e1000_init_eeprom_params(struct e1000_hw *hw)
3074 eeprom->opcode_bits = 3; 3274 eeprom->opcode_bits = 3;
3075 eeprom->address_bits = 6; 3275 eeprom->address_bits = 6;
3076 eeprom->delay_usec = 50; 3276 eeprom->delay_usec = 50;
3277 eeprom->use_eerd = FALSE;
3278 eeprom->use_eewr = FALSE;
3077 break; 3279 break;
3078 case e1000_82540: 3280 case e1000_82540:
3079 case e1000_82545: 3281 case e1000_82545:
@@ -3090,6 +3292,8 @@ e1000_init_eeprom_params(struct e1000_hw *hw)
3090 eeprom->word_size = 64; 3292 eeprom->word_size = 64;
3091 eeprom->address_bits = 6; 3293 eeprom->address_bits = 6;
3092 } 3294 }
3295 eeprom->use_eerd = FALSE;
3296 eeprom->use_eewr = FALSE;
3093 break; 3297 break;
3094 case e1000_82541: 3298 case e1000_82541:
3095 case e1000_82541_rev_2: 3299 case e1000_82541_rev_2:
@@ -3118,42 +3322,60 @@ e1000_init_eeprom_params(struct e1000_hw *hw)
3118 eeprom->address_bits = 6; 3322 eeprom->address_bits = 6;
3119 } 3323 }
3120 } 3324 }
3325 eeprom->use_eerd = FALSE;
3326 eeprom->use_eewr = FALSE;
3327 break;
3328 case e1000_82573:
3329 eeprom->type = e1000_eeprom_spi;
3330 eeprom->opcode_bits = 8;
3331 eeprom->delay_usec = 1;
3332 if (eecd & E1000_EECD_ADDR_BITS) {
3333 eeprom->page_size = 32;
3334 eeprom->address_bits = 16;
3335 } else {
3336 eeprom->page_size = 8;
3337 eeprom->address_bits = 8;
3338 }
3339 eeprom->use_eerd = TRUE;
3340 eeprom->use_eewr = TRUE;
3341 if(e1000_is_onboard_nvm_eeprom(hw) == FALSE) {
3342 eeprom->type = e1000_eeprom_flash;
3343 eeprom->word_size = 2048;
3344
3345 /* Ensure that the Autonomous FLASH update bit is cleared due to
3346 * Flash update issue on parts which use a FLASH for NVM. */
3347 eecd &= ~E1000_EECD_AUPDEN;
3348 E1000_WRITE_REG(hw, EECD, eecd);
3349 }
3121 break; 3350 break;
3122 default: 3351 default:
3123 break; 3352 break;
3124 } 3353 }
3125 3354
3126 if (eeprom->type == e1000_eeprom_spi) { 3355 if (eeprom->type == e1000_eeprom_spi) {
3127 eeprom->word_size = 64; 3356 /* eeprom_size will be an enum [0..8] that maps to eeprom sizes 128B to
3128 if (e1000_read_eeprom(hw, EEPROM_CFG, 1, &eeprom_size) == 0) { 3357 * 32KB (incremented by powers of 2).
3129 eeprom_size &= EEPROM_SIZE_MASK; 3358 */
3130 3359 if(hw->mac_type <= e1000_82547_rev_2) {
3131 switch (eeprom_size) { 3360 /* Set to default value for initial eeprom read. */
3132 case EEPROM_SIZE_16KB: 3361 eeprom->word_size = 64;
3133 eeprom->word_size = 8192; 3362 ret_val = e1000_read_eeprom(hw, EEPROM_CFG, 1, &eeprom_size);
3134 break; 3363 if(ret_val)
3135 case EEPROM_SIZE_8KB: 3364 return ret_val;
3136 eeprom->word_size = 4096; 3365 eeprom_size = (eeprom_size & EEPROM_SIZE_MASK) >> EEPROM_SIZE_SHIFT;
3137 break; 3366 /* 256B eeprom size was not supported in earlier hardware, so we
3138 case EEPROM_SIZE_4KB: 3367 * bump eeprom_size up one to ensure that "1" (which maps to 256B)
3139 eeprom->word_size = 2048; 3368 * is never the result used in the shifting logic below. */
3140 break; 3369 if(eeprom_size)
3141 case EEPROM_SIZE_2KB: 3370 eeprom_size++;
3142 eeprom->word_size = 1024; 3371 } else {
3143 break; 3372 eeprom_size = (uint16_t)((eecd & E1000_EECD_SIZE_EX_MASK) >>
3144 case EEPROM_SIZE_1KB: 3373 E1000_EECD_SIZE_EX_SHIFT);
3145 eeprom->word_size = 512;
3146 break;
3147 case EEPROM_SIZE_512B:
3148 eeprom->word_size = 256;
3149 break;
3150 case EEPROM_SIZE_128B:
3151 default:
3152 eeprom->word_size = 64;
3153 break;
3154 }
3155 } 3374 }
3375
3376 eeprom->word_size = 1 << (eeprom_size + EEPROM_WORD_SIZE_SHIFT);
3156 } 3377 }
3378 return ret_val;
3157} 3379}
3158 3380
3159/****************************************************************************** 3381/******************************************************************************
@@ -3306,8 +3528,12 @@ e1000_acquire_eeprom(struct e1000_hw *hw)
3306 3528
3307 DEBUGFUNC("e1000_acquire_eeprom"); 3529 DEBUGFUNC("e1000_acquire_eeprom");
3308 3530
3531 if(e1000_get_hw_eeprom_semaphore(hw))
3532 return -E1000_ERR_EEPROM;
3533
3309 eecd = E1000_READ_REG(hw, EECD); 3534 eecd = E1000_READ_REG(hw, EECD);
3310 3535
3536 if (hw->mac_type != e1000_82573) {
3311 /* Request EEPROM Access */ 3537 /* Request EEPROM Access */
3312 if(hw->mac_type > e1000_82544) { 3538 if(hw->mac_type > e1000_82544) {
3313 eecd |= E1000_EECD_REQ; 3539 eecd |= E1000_EECD_REQ;
@@ -3326,6 +3552,7 @@ e1000_acquire_eeprom(struct e1000_hw *hw)
3326 return -E1000_ERR_EEPROM; 3552 return -E1000_ERR_EEPROM;
3327 } 3553 }
3328 } 3554 }
3555 }
3329 3556
3330 /* Setup EEPROM for Read/Write */ 3557 /* Setup EEPROM for Read/Write */
3331 3558
@@ -3443,6 +3670,8 @@ e1000_release_eeprom(struct e1000_hw *hw)
3443 eecd &= ~E1000_EECD_REQ; 3670 eecd &= ~E1000_EECD_REQ;
3444 E1000_WRITE_REG(hw, EECD, eecd); 3671 E1000_WRITE_REG(hw, EECD, eecd);
3445 } 3672 }
3673
3674 e1000_put_hw_eeprom_semaphore(hw);
3446} 3675}
3447 3676
3448/****************************************************************************** 3677/******************************************************************************
@@ -3504,8 +3733,10 @@ e1000_read_eeprom(struct e1000_hw *hw,
3504{ 3733{
3505 struct e1000_eeprom_info *eeprom = &hw->eeprom; 3734 struct e1000_eeprom_info *eeprom = &hw->eeprom;
3506 uint32_t i = 0; 3735 uint32_t i = 0;
3736 int32_t ret_val;
3507 3737
3508 DEBUGFUNC("e1000_read_eeprom"); 3738 DEBUGFUNC("e1000_read_eeprom");
3739
3509 /* A check for invalid values: offset too large, too many words, and not 3740 /* A check for invalid values: offset too large, too many words, and not
3510 * enough words. 3741 * enough words.
3511 */ 3742 */
@@ -3515,9 +3746,23 @@ e1000_read_eeprom(struct e1000_hw *hw,
3515 return -E1000_ERR_EEPROM; 3746 return -E1000_ERR_EEPROM;
3516 } 3747 }
3517 3748
3518 /* Prepare the EEPROM for reading */ 3749 /* FLASH reads without acquiring the semaphore are safe in 82573-based
3519 if(e1000_acquire_eeprom(hw) != E1000_SUCCESS) 3750 * controllers.
3520 return -E1000_ERR_EEPROM; 3751 */
3752 if ((e1000_is_onboard_nvm_eeprom(hw) == TRUE) ||
3753 (hw->mac_type != e1000_82573)) {
3754 /* Prepare the EEPROM for reading */
3755 if(e1000_acquire_eeprom(hw) != E1000_SUCCESS)
3756 return -E1000_ERR_EEPROM;
3757 }
3758
3759 if(eeprom->use_eerd == TRUE) {
3760 ret_val = e1000_read_eeprom_eerd(hw, offset, words, data);
3761 if ((e1000_is_onboard_nvm_eeprom(hw) == TRUE) ||
3762 (hw->mac_type != e1000_82573))
3763 e1000_release_eeprom(hw);
3764 return ret_val;
3765 }
3521 3766
3522 if(eeprom->type == e1000_eeprom_spi) { 3767 if(eeprom->type == e1000_eeprom_spi) {
3523 uint16_t word_in; 3768 uint16_t word_in;
@@ -3569,6 +3814,132 @@ e1000_read_eeprom(struct e1000_hw *hw,
3569} 3814}
3570 3815
3571/****************************************************************************** 3816/******************************************************************************
3817 * Reads a 16 bit word from the EEPROM using the EERD register.
3818 *
3819 * hw - Struct containing variables accessed by shared code
3820 * offset - offset of word in the EEPROM to read
3821 * data - word read from the EEPROM
3822 * words - number of words to read
3823 *****************************************************************************/
3824int32_t
3825e1000_read_eeprom_eerd(struct e1000_hw *hw,
3826 uint16_t offset,
3827 uint16_t words,
3828 uint16_t *data)
3829{
3830 uint32_t i, eerd = 0;
3831 int32_t error = 0;
3832
3833 for (i = 0; i < words; i++) {
3834 eerd = ((offset+i) << E1000_EEPROM_RW_ADDR_SHIFT) +
3835 E1000_EEPROM_RW_REG_START;
3836
3837 E1000_WRITE_REG(hw, EERD, eerd);
3838 error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_READ);
3839
3840 if(error) {
3841 break;
3842 }
3843 data[i] = (E1000_READ_REG(hw, EERD) >> E1000_EEPROM_RW_REG_DATA);
3844
3845 }
3846
3847 return error;
3848}
3849
3850/******************************************************************************
3851 * Writes a 16 bit word from the EEPROM using the EEWR register.
3852 *
3853 * hw - Struct containing variables accessed by shared code
3854 * offset - offset of word in the EEPROM to read
3855 * data - word read from the EEPROM
3856 * words - number of words to read
3857 *****************************************************************************/
3858int32_t
3859e1000_write_eeprom_eewr(struct e1000_hw *hw,
3860 uint16_t offset,
3861 uint16_t words,
3862 uint16_t *data)
3863{
3864 uint32_t register_value = 0;
3865 uint32_t i = 0;
3866 int32_t error = 0;
3867
3868 for (i = 0; i < words; i++) {
3869 register_value = (data[i] << E1000_EEPROM_RW_REG_DATA) |
3870 ((offset+i) << E1000_EEPROM_RW_ADDR_SHIFT) |
3871 E1000_EEPROM_RW_REG_START;
3872
3873 error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_WRITE);
3874 if(error) {
3875 break;
3876 }
3877
3878 E1000_WRITE_REG(hw, EEWR, register_value);
3879
3880 error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_WRITE);
3881
3882 if(error) {
3883 break;
3884 }
3885 }
3886
3887 return error;
3888}
3889
3890/******************************************************************************
3891 * Polls the status bit (bit 1) of the EERD to determine when the read is done.
3892 *
3893 * hw - Struct containing variables accessed by shared code
3894 *****************************************************************************/
3895int32_t
3896e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd)
3897{
3898 uint32_t attempts = 100000;
3899 uint32_t i, reg = 0;
3900 int32_t done = E1000_ERR_EEPROM;
3901
3902 for(i = 0; i < attempts; i++) {
3903 if(eerd == E1000_EEPROM_POLL_READ)
3904 reg = E1000_READ_REG(hw, EERD);
3905 else
3906 reg = E1000_READ_REG(hw, EEWR);
3907
3908 if(reg & E1000_EEPROM_RW_REG_DONE) {
3909 done = E1000_SUCCESS;
3910 break;
3911 }
3912 udelay(5);
3913 }
3914
3915 return done;
3916}
3917
3918/***************************************************************************
3919* Description: Determines if the onboard NVM is FLASH or EEPROM.
3920*
3921* hw - Struct containing variables accessed by shared code
3922****************************************************************************/
3923boolean_t
3924e1000_is_onboard_nvm_eeprom(struct e1000_hw *hw)
3925{
3926 uint32_t eecd = 0;
3927
3928 if(hw->mac_type == e1000_82573) {
3929 eecd = E1000_READ_REG(hw, EECD);
3930
3931 /* Isolate bits 15 & 16 */
3932 eecd = ((eecd >> 15) & 0x03);
3933
3934 /* If both bits are set, device is Flash type */
3935 if(eecd == 0x03) {
3936 return FALSE;
3937 }
3938 }
3939 return TRUE;
3940}
3941
3942/******************************************************************************
3572 * Verifies that the EEPROM has a valid checksum 3943 * Verifies that the EEPROM has a valid checksum
3573 * 3944 *
3574 * hw - Struct containing variables accessed by shared code 3945 * hw - Struct containing variables accessed by shared code
@@ -3585,6 +3956,25 @@ e1000_validate_eeprom_checksum(struct e1000_hw *hw)
3585 3956
3586 DEBUGFUNC("e1000_validate_eeprom_checksum"); 3957 DEBUGFUNC("e1000_validate_eeprom_checksum");
3587 3958
3959 if ((hw->mac_type == e1000_82573) &&
3960 (e1000_is_onboard_nvm_eeprom(hw) == FALSE)) {
3961 /* Check bit 4 of word 10h. If it is 0, firmware is done updating
3962 * 10h-12h. Checksum may need to be fixed. */
3963 e1000_read_eeprom(hw, 0x10, 1, &eeprom_data);
3964 if ((eeprom_data & 0x10) == 0) {
3965 /* Read 0x23 and check bit 15. This bit is a 1 when the checksum
3966 * has already been fixed. If the checksum is still wrong and this
3967 * bit is a 1, we need to return bad checksum. Otherwise, we need
3968 * to set this bit to a 1 and update the checksum. */
3969 e1000_read_eeprom(hw, 0x23, 1, &eeprom_data);
3970 if ((eeprom_data & 0x8000) == 0) {
3971 eeprom_data |= 0x8000;
3972 e1000_write_eeprom(hw, 0x23, 1, &eeprom_data);
3973 e1000_update_eeprom_checksum(hw);
3974 }
3975 }
3976 }
3977
3588 for(i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) { 3978 for(i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
3589 if(e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) { 3979 if(e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) {
3590 DEBUGOUT("EEPROM Read Error\n"); 3980 DEBUGOUT("EEPROM Read Error\n");
@@ -3628,6 +4018,8 @@ e1000_update_eeprom_checksum(struct e1000_hw *hw)
3628 if(e1000_write_eeprom(hw, EEPROM_CHECKSUM_REG, 1, &checksum) < 0) { 4018 if(e1000_write_eeprom(hw, EEPROM_CHECKSUM_REG, 1, &checksum) < 0) {
3629 DEBUGOUT("EEPROM Write Error\n"); 4019 DEBUGOUT("EEPROM Write Error\n");
3630 return -E1000_ERR_EEPROM; 4020 return -E1000_ERR_EEPROM;
4021 } else if (hw->eeprom.type == e1000_eeprom_flash) {
4022 e1000_commit_shadow_ram(hw);
3631 } 4023 }
3632 return E1000_SUCCESS; 4024 return E1000_SUCCESS;
3633} 4025}
@@ -3663,6 +4055,10 @@ e1000_write_eeprom(struct e1000_hw *hw,
3663 return -E1000_ERR_EEPROM; 4055 return -E1000_ERR_EEPROM;
3664 } 4056 }
3665 4057
4058 /* 82573 reads only through eerd */
4059 if(eeprom->use_eewr == TRUE)
4060 return e1000_write_eeprom_eewr(hw, offset, words, data);
4061
3666 /* Prepare the EEPROM for writing */ 4062 /* Prepare the EEPROM for writing */
3667 if (e1000_acquire_eeprom(hw) != E1000_SUCCESS) 4063 if (e1000_acquire_eeprom(hw) != E1000_SUCCESS)
3668 return -E1000_ERR_EEPROM; 4064 return -E1000_ERR_EEPROM;
@@ -3833,6 +4229,65 @@ e1000_write_eeprom_microwire(struct e1000_hw *hw,
3833} 4229}
3834 4230
3835/****************************************************************************** 4231/******************************************************************************
4232 * Flushes the cached eeprom to NVM. This is done by saving the modified values
4233 * in the eeprom cache and the non modified values in the currently active bank
4234 * to the new bank.
4235 *
4236 * hw - Struct containing variables accessed by shared code
4237 * offset - offset of word in the EEPROM to read
4238 * data - word read from the EEPROM
4239 * words - number of words to read
4240 *****************************************************************************/
4241int32_t
4242e1000_commit_shadow_ram(struct e1000_hw *hw)
4243{
4244 uint32_t attempts = 100000;
4245 uint32_t eecd = 0;
4246 uint32_t flop = 0;
4247 uint32_t i = 0;
4248 int32_t error = E1000_SUCCESS;
4249
4250 /* The flop register will be used to determine if flash type is STM */
4251 flop = E1000_READ_REG(hw, FLOP);
4252
4253 if (hw->mac_type == e1000_82573) {
4254 for (i=0; i < attempts; i++) {
4255 eecd = E1000_READ_REG(hw, EECD);
4256 if ((eecd & E1000_EECD_FLUPD) == 0) {
4257 break;
4258 }
4259 udelay(5);
4260 }
4261
4262 if (i == attempts) {
4263 return -E1000_ERR_EEPROM;
4264 }
4265
4266 /* If STM opcode located in bits 15:8 of flop, reset firmware */
4267 if ((flop & 0xFF00) == E1000_STM_OPCODE) {
4268 E1000_WRITE_REG(hw, HICR, E1000_HICR_FW_RESET);
4269 }
4270
4271 /* Perform the flash update */
4272 E1000_WRITE_REG(hw, EECD, eecd | E1000_EECD_FLUPD);
4273
4274 for (i=0; i < attempts; i++) {
4275 eecd = E1000_READ_REG(hw, EECD);
4276 if ((eecd & E1000_EECD_FLUPD) == 0) {
4277 break;
4278 }
4279 udelay(5);
4280 }
4281
4282 if (i == attempts) {
4283 return -E1000_ERR_EEPROM;
4284 }
4285 }
4286
4287 return error;
4288}
4289
4290/******************************************************************************
3836 * Reads the adapter's part number from the EEPROM 4291 * Reads the adapter's part number from the EEPROM
3837 * 4292 *
3838 * hw - Struct containing variables accessed by shared code 4293 * hw - Struct containing variables accessed by shared code
@@ -3911,6 +4366,7 @@ void
3911e1000_init_rx_addrs(struct e1000_hw *hw) 4366e1000_init_rx_addrs(struct e1000_hw *hw)
3912{ 4367{
3913 uint32_t i; 4368 uint32_t i;
4369 uint32_t rar_num;
3914 4370
3915 DEBUGFUNC("e1000_init_rx_addrs"); 4371 DEBUGFUNC("e1000_init_rx_addrs");
3916 4372
@@ -3919,9 +4375,10 @@ e1000_init_rx_addrs(struct e1000_hw *hw)
3919 4375
3920 e1000_rar_set(hw, hw->mac_addr, 0); 4376 e1000_rar_set(hw, hw->mac_addr, 0);
3921 4377
4378 rar_num = E1000_RAR_ENTRIES;
3922 /* Zero out the other 15 receive addresses. */ 4379 /* Zero out the other 15 receive addresses. */
3923 DEBUGOUT("Clearing RAR[1-15]\n"); 4380 DEBUGOUT("Clearing RAR[1-15]\n");
3924 for(i = 1; i < E1000_RAR_ENTRIES; i++) { 4381 for(i = 1; i < rar_num; i++) {
3925 E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0); 4382 E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
3926 E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0); 4383 E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
3927 } 4384 }
@@ -3950,7 +4407,9 @@ e1000_mc_addr_list_update(struct e1000_hw *hw,
3950{ 4407{
3951 uint32_t hash_value; 4408 uint32_t hash_value;
3952 uint32_t i; 4409 uint32_t i;
3953 4410 uint32_t num_rar_entry;
4411 uint32_t num_mta_entry;
4412
3954 DEBUGFUNC("e1000_mc_addr_list_update"); 4413 DEBUGFUNC("e1000_mc_addr_list_update");
3955 4414
3956 /* Set the new number of MC addresses that we are being requested to use. */ 4415 /* Set the new number of MC addresses that we are being requested to use. */
@@ -3958,14 +4417,16 @@ e1000_mc_addr_list_update(struct e1000_hw *hw,
3958 4417
3959 /* Clear RAR[1-15] */ 4418 /* Clear RAR[1-15] */
3960 DEBUGOUT(" Clearing RAR[1-15]\n"); 4419 DEBUGOUT(" Clearing RAR[1-15]\n");
3961 for(i = rar_used_count; i < E1000_RAR_ENTRIES; i++) { 4420 num_rar_entry = E1000_RAR_ENTRIES;
4421 for(i = rar_used_count; i < num_rar_entry; i++) {
3962 E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0); 4422 E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
3963 E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0); 4423 E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
3964 } 4424 }
3965 4425
3966 /* Clear the MTA */ 4426 /* Clear the MTA */
3967 DEBUGOUT(" Clearing MTA\n"); 4427 DEBUGOUT(" Clearing MTA\n");
3968 for(i = 0; i < E1000_NUM_MTA_REGISTERS; i++) { 4428 num_mta_entry = E1000_NUM_MTA_REGISTERS;
4429 for(i = 0; i < num_mta_entry; i++) {
3969 E1000_WRITE_REG_ARRAY(hw, MTA, i, 0); 4430 E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
3970 } 4431 }
3971 4432
@@ -3989,7 +4450,7 @@ e1000_mc_addr_list_update(struct e1000_hw *hw,
3989 /* Place this multicast address in the RAR if there is room, * 4450 /* Place this multicast address in the RAR if there is room, *
3990 * else put it in the MTA 4451 * else put it in the MTA
3991 */ 4452 */
3992 if(rar_used_count < E1000_RAR_ENTRIES) { 4453 if (rar_used_count < num_rar_entry) {
3993 e1000_rar_set(hw, 4454 e1000_rar_set(hw,
3994 mc_addr_list + (i * (ETH_LENGTH_OF_ADDRESS + pad)), 4455 mc_addr_list + (i * (ETH_LENGTH_OF_ADDRESS + pad)),
3995 rar_used_count); 4456 rar_used_count);
@@ -4040,6 +4501,7 @@ e1000_hash_mc_addr(struct e1000_hw *hw,
4040 } 4501 }
4041 4502
4042 hash_value &= 0xFFF; 4503 hash_value &= 0xFFF;
4504
4043 return hash_value; 4505 return hash_value;
4044} 4506}
4045 4507
@@ -4144,12 +4606,33 @@ void
4144e1000_clear_vfta(struct e1000_hw *hw) 4606e1000_clear_vfta(struct e1000_hw *hw)
4145{ 4607{
4146 uint32_t offset; 4608 uint32_t offset;
4147 4609 uint32_t vfta_value = 0;
4148 for(offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) 4610 uint32_t vfta_offset = 0;
4149 E1000_WRITE_REG_ARRAY(hw, VFTA, offset, 0); 4611 uint32_t vfta_bit_in_reg = 0;
4612
4613 if (hw->mac_type == e1000_82573) {
4614 if (hw->mng_cookie.vlan_id != 0) {
4615 /* The VFTA is a 4096b bit-field, each identifying a single VLAN
4616 * ID. The following operations determine which 32b entry
4617 * (i.e. offset) into the array we want to set the VLAN ID
4618 * (i.e. bit) of the manageability unit. */
4619 vfta_offset = (hw->mng_cookie.vlan_id >>
4620 E1000_VFTA_ENTRY_SHIFT) &
4621 E1000_VFTA_ENTRY_MASK;
4622 vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id &
4623 E1000_VFTA_ENTRY_BIT_SHIFT_MASK);
4624 }
4625 }
4626 for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
4627 /* If the offset we want to clear is the same offset of the
4628 * manageability VLAN ID, then clear all bits except that of the
4629 * manageability unit */
4630 vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;
4631 E1000_WRITE_REG_ARRAY(hw, VFTA, offset, vfta_value);
4632 }
4150} 4633}
4151 4634
4152static int32_t 4635int32_t
4153e1000_id_led_init(struct e1000_hw * hw) 4636e1000_id_led_init(struct e1000_hw * hw)
4154{ 4637{
4155 uint32_t ledctl; 4638 uint32_t ledctl;
@@ -4480,6 +4963,19 @@ e1000_clear_hw_cntrs(struct e1000_hw *hw)
4480 temp = E1000_READ_REG(hw, MGTPRC); 4963 temp = E1000_READ_REG(hw, MGTPRC);
4481 temp = E1000_READ_REG(hw, MGTPDC); 4964 temp = E1000_READ_REG(hw, MGTPDC);
4482 temp = E1000_READ_REG(hw, MGTPTC); 4965 temp = E1000_READ_REG(hw, MGTPTC);
4966
4967 if(hw->mac_type <= e1000_82547_rev_2) return;
4968
4969 temp = E1000_READ_REG(hw, IAC);
4970 temp = E1000_READ_REG(hw, ICRXOC);
4971 temp = E1000_READ_REG(hw, ICRXPTC);
4972 temp = E1000_READ_REG(hw, ICRXATC);
4973 temp = E1000_READ_REG(hw, ICTXPTC);
4974 temp = E1000_READ_REG(hw, ICTXATC);
4975 temp = E1000_READ_REG(hw, ICTXQEC);
4976 temp = E1000_READ_REG(hw, ICTXQMTC);
4977 temp = E1000_READ_REG(hw, ICRXDMTC);
4978
4483} 4979}
4484 4980
4485/****************************************************************************** 4981/******************************************************************************
@@ -4646,6 +5142,11 @@ e1000_get_bus_info(struct e1000_hw *hw)
4646 hw->bus_speed = e1000_bus_speed_unknown; 5142 hw->bus_speed = e1000_bus_speed_unknown;
4647 hw->bus_width = e1000_bus_width_unknown; 5143 hw->bus_width = e1000_bus_width_unknown;
4648 break; 5144 break;
5145 case e1000_82573:
5146 hw->bus_type = e1000_bus_type_pci_express;
5147 hw->bus_speed = e1000_bus_speed_2500;
5148 hw->bus_width = e1000_bus_width_pciex_4;
5149 break;
4649 default: 5150 default:
4650 status = E1000_READ_REG(hw, STATUS); 5151 status = E1000_READ_REG(hw, STATUS);
4651 hw->bus_type = (status & E1000_STATUS_PCIX_MODE) ? 5152 hw->bus_type = (status & E1000_STATUS_PCIX_MODE) ?
@@ -4749,6 +5250,7 @@ e1000_get_cable_length(struct e1000_hw *hw,
4749 5250
4750 /* Use old method for Phy older than IGP */ 5251 /* Use old method for Phy older than IGP */
4751 if(hw->phy_type == e1000_phy_m88) { 5252 if(hw->phy_type == e1000_phy_m88) {
5253
4752 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, 5254 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
4753 &phy_data); 5255 &phy_data);
4754 if(ret_val) 5256 if(ret_val)
@@ -4865,7 +5367,8 @@ e1000_check_polarity(struct e1000_hw *hw,
4865 return ret_val; 5367 return ret_val;
4866 *polarity = (phy_data & M88E1000_PSSR_REV_POLARITY) >> 5368 *polarity = (phy_data & M88E1000_PSSR_REV_POLARITY) >>
4867 M88E1000_PSSR_REV_POLARITY_SHIFT; 5369 M88E1000_PSSR_REV_POLARITY_SHIFT;
4868 } else if(hw->phy_type == e1000_phy_igp) { 5370 } else if(hw->phy_type == e1000_phy_igp ||
5371 hw->phy_type == e1000_phy_igp_2) {
4869 /* Read the Status register to check the speed */ 5372 /* Read the Status register to check the speed */
4870 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS, 5373 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS,
4871 &phy_data); 5374 &phy_data);
@@ -4917,7 +5420,8 @@ e1000_check_downshift(struct e1000_hw *hw)
4917 5420
4918 DEBUGFUNC("e1000_check_downshift"); 5421 DEBUGFUNC("e1000_check_downshift");
4919 5422
4920 if(hw->phy_type == e1000_phy_igp) { 5423 if(hw->phy_type == e1000_phy_igp ||
5424 hw->phy_type == e1000_phy_igp_2) {
4921 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_LINK_HEALTH, 5425 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_LINK_HEALTH,
4922 &phy_data); 5426 &phy_data);
4923 if(ret_val) 5427 if(ret_val)
@@ -4933,6 +5437,7 @@ e1000_check_downshift(struct e1000_hw *hw)
4933 hw->speed_downgraded = (phy_data & M88E1000_PSSR_DOWNSHIFT) >> 5437 hw->speed_downgraded = (phy_data & M88E1000_PSSR_DOWNSHIFT) >>
4934 M88E1000_PSSR_DOWNSHIFT_SHIFT; 5438 M88E1000_PSSR_DOWNSHIFT_SHIFT;
4935 } 5439 }
5440
4936 return E1000_SUCCESS; 5441 return E1000_SUCCESS;
4937} 5442}
4938 5443
@@ -5047,7 +5552,7 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw,
5047 if(ret_val) 5552 if(ret_val)
5048 return ret_val; 5553 return ret_val;
5049 5554
5050 msec_delay(20); 5555 msec_delay_irq(20);
5051 5556
5052 ret_val = e1000_write_phy_reg(hw, 0x0000, 5557 ret_val = e1000_write_phy_reg(hw, 0x0000,
5053 IGP01E1000_IEEE_FORCE_GIGA); 5558 IGP01E1000_IEEE_FORCE_GIGA);
@@ -5071,7 +5576,7 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw,
5071 if(ret_val) 5576 if(ret_val)
5072 return ret_val; 5577 return ret_val;
5073 5578
5074 msec_delay(20); 5579 msec_delay_irq(20);
5075 5580
5076 /* Now enable the transmitter */ 5581 /* Now enable the transmitter */
5077 ret_val = e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data); 5582 ret_val = e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
@@ -5096,7 +5601,7 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw,
5096 if(ret_val) 5601 if(ret_val)
5097 return ret_val; 5602 return ret_val;
5098 5603
5099 msec_delay(20); 5604 msec_delay_irq(20);
5100 5605
5101 ret_val = e1000_write_phy_reg(hw, 0x0000, 5606 ret_val = e1000_write_phy_reg(hw, 0x0000,
5102 IGP01E1000_IEEE_FORCE_GIGA); 5607 IGP01E1000_IEEE_FORCE_GIGA);
@@ -5112,7 +5617,7 @@ e1000_config_dsp_after_link_change(struct e1000_hw *hw,
5112 if(ret_val) 5617 if(ret_val)
5113 return ret_val; 5618 return ret_val;
5114 5619
5115 msec_delay(20); 5620 msec_delay_irq(20);
5116 5621
5117 /* Now enable the transmitter */ 5622 /* Now enable the transmitter */
5118 ret_val = e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data); 5623 ret_val = e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
@@ -5187,22 +5692,36 @@ e1000_set_d3_lplu_state(struct e1000_hw *hw,
5187 uint16_t phy_data; 5692 uint16_t phy_data;
5188 DEBUGFUNC("e1000_set_d3_lplu_state"); 5693 DEBUGFUNC("e1000_set_d3_lplu_state");
5189 5694
5190 if(!((hw->mac_type == e1000_82541_rev_2) || 5695 if(hw->phy_type != e1000_phy_igp && hw->phy_type != e1000_phy_igp_2)
5191 (hw->mac_type == e1000_82547_rev_2)))
5192 return E1000_SUCCESS; 5696 return E1000_SUCCESS;
5193 5697
5194 /* During driver activity LPLU should not be used or it will attain link 5698 /* During driver activity LPLU should not be used or it will attain link
5195 * from the lowest speeds starting from 10Mbps. The capability is used for 5699 * from the lowest speeds starting from 10Mbps. The capability is used for
5196 * Dx transitions and states */ 5700 * Dx transitions and states */
5197 ret_val = e1000_read_phy_reg(hw, IGP01E1000_GMII_FIFO, &phy_data); 5701 if(hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2) {
5198 if(ret_val) 5702 ret_val = e1000_read_phy_reg(hw, IGP01E1000_GMII_FIFO, &phy_data);
5199 return ret_val;
5200
5201 if(!active) {
5202 phy_data &= ~IGP01E1000_GMII_FLEX_SPD;
5203 ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO, phy_data);
5204 if(ret_val) 5703 if(ret_val)
5205 return ret_val; 5704 return ret_val;
5705 } else {
5706 ret_val = e1000_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data);
5707 if(ret_val)
5708 return ret_val;
5709 }
5710
5711 if(!active) {
5712 if(hw->mac_type == e1000_82541_rev_2 ||
5713 hw->mac_type == e1000_82547_rev_2) {
5714 phy_data &= ~IGP01E1000_GMII_FLEX_SPD;
5715 ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO, phy_data);
5716 if(ret_val)
5717 return ret_val;
5718 } else {
5719 phy_data &= ~IGP02E1000_PM_D3_LPLU;
5720 ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
5721 phy_data);
5722 if (ret_val)
5723 return ret_val;
5724 }
5206 5725
5207 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used during 5726 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used during
5208 * Dx states where the power conservation is most important. During 5727 * Dx states where the power conservation is most important. During
@@ -5236,11 +5755,105 @@ e1000_set_d3_lplu_state(struct e1000_hw *hw,
5236 (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_ALL ) || 5755 (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_ALL ) ||
5237 (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_100_ALL)) { 5756 (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_100_ALL)) {
5238 5757
5239 phy_data |= IGP01E1000_GMII_FLEX_SPD; 5758 if(hw->mac_type == e1000_82541_rev_2 ||
5240 ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO, phy_data); 5759 hw->mac_type == e1000_82547_rev_2) {
5760 phy_data |= IGP01E1000_GMII_FLEX_SPD;
5761 ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO, phy_data);
5762 if(ret_val)
5763 return ret_val;
5764 } else {
5765 phy_data |= IGP02E1000_PM_D3_LPLU;
5766 ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
5767 phy_data);
5768 if (ret_val)
5769 return ret_val;
5770 }
5771
5772 /* When LPLU is enabled we should disable SmartSpeed */
5773 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data);
5774 if(ret_val)
5775 return ret_val;
5776
5777 phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
5778 ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, phy_data);
5241 if(ret_val) 5779 if(ret_val)
5242 return ret_val; 5780 return ret_val;
5243 5781
5782 }
5783 return E1000_SUCCESS;
5784}
5785
5786/*****************************************************************************
5787 *
5788 * This function sets the lplu d0 state according to the active flag. When
5789 * activating lplu this function also disables smart speed and vise versa.
5790 * lplu will not be activated unless the device autonegotiation advertisment
5791 * meets standards of either 10 or 10/100 or 10/100/1000 at all duplexes.
5792 * hw: Struct containing variables accessed by shared code
5793 * active - true to enable lplu false to disable lplu.
5794 *
5795 * returns: - E1000_ERR_PHY if fail to read/write the PHY
5796 * E1000_SUCCESS at any other case.
5797 *
5798 ****************************************************************************/
5799
5800int32_t
5801e1000_set_d0_lplu_state(struct e1000_hw *hw,
5802 boolean_t active)
5803{
5804 int32_t ret_val;
5805 uint16_t phy_data;
5806 DEBUGFUNC("e1000_set_d0_lplu_state");
5807
5808 if(hw->mac_type <= e1000_82547_rev_2)
5809 return E1000_SUCCESS;
5810
5811 ret_val = e1000_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data);
5812 if(ret_val)
5813 return ret_val;
5814
5815 if (!active) {
5816 phy_data &= ~IGP02E1000_PM_D0_LPLU;
5817 ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
5818 if (ret_val)
5819 return ret_val;
5820
5821 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used during
5822 * Dx states where the power conservation is most important. During
5823 * driver activity we should enable SmartSpeed, so performance is
5824 * maintained. */
5825 if (hw->smart_speed == e1000_smart_speed_on) {
5826 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
5827 &phy_data);
5828 if(ret_val)
5829 return ret_val;
5830
5831 phy_data |= IGP01E1000_PSCFR_SMART_SPEED;
5832 ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
5833 phy_data);
5834 if(ret_val)
5835 return ret_val;
5836 } else if (hw->smart_speed == e1000_smart_speed_off) {
5837 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
5838 &phy_data);
5839 if (ret_val)
5840 return ret_val;
5841
5842 phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
5843 ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
5844 phy_data);
5845 if(ret_val)
5846 return ret_val;
5847 }
5848
5849
5850 } else {
5851
5852 phy_data |= IGP02E1000_PM_D0_LPLU;
5853 ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
5854 if (ret_val)
5855 return ret_val;
5856
5244 /* When LPLU is enabled we should disable SmartSpeed */ 5857 /* When LPLU is enabled we should disable SmartSpeed */
5245 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data); 5858 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data);
5246 if(ret_val) 5859 if(ret_val)
@@ -5318,6 +5931,338 @@ e1000_set_vco_speed(struct e1000_hw *hw)
5318 return E1000_SUCCESS; 5931 return E1000_SUCCESS;
5319} 5932}
5320 5933
5934
5935/*****************************************************************************
5936 * This function reads the cookie from ARC ram.
5937 *
5938 * returns: - E1000_SUCCESS .
5939 ****************************************************************************/
5940int32_t
5941e1000_host_if_read_cookie(struct e1000_hw * hw, uint8_t *buffer)
5942{
5943 uint8_t i;
5944 uint32_t offset = E1000_MNG_DHCP_COOKIE_OFFSET;
5945 uint8_t length = E1000_MNG_DHCP_COOKIE_LENGTH;
5946
5947 length = (length >> 2);
5948 offset = (offset >> 2);
5949
5950 for (i = 0; i < length; i++) {
5951 *((uint32_t *) buffer + i) =
5952 E1000_READ_REG_ARRAY_DWORD(hw, HOST_IF, offset + i);
5953 }
5954 return E1000_SUCCESS;
5955}
5956
5957
5958/*****************************************************************************
5959 * This function checks whether the HOST IF is enabled for command operaton
5960 * and also checks whether the previous command is completed.
5961 * It busy waits in case of previous command is not completed.
5962 *
5963 * returns: - E1000_ERR_HOST_INTERFACE_COMMAND in case if is not ready or
5964 * timeout
5965 * - E1000_SUCCESS for success.
5966 ****************************************************************************/
5967int32_t
5968e1000_mng_enable_host_if(struct e1000_hw * hw)
5969{
5970 uint32_t hicr;
5971 uint8_t i;
5972
5973 /* Check that the host interface is enabled. */
5974 hicr = E1000_READ_REG(hw, HICR);
5975 if ((hicr & E1000_HICR_EN) == 0) {
5976 DEBUGOUT("E1000_HOST_EN bit disabled.\n");
5977 return -E1000_ERR_HOST_INTERFACE_COMMAND;
5978 }
5979 /* check the previous command is completed */
5980 for (i = 0; i < E1000_MNG_DHCP_COMMAND_TIMEOUT; i++) {
5981 hicr = E1000_READ_REG(hw, HICR);
5982 if (!(hicr & E1000_HICR_C))
5983 break;
5984 msec_delay_irq(1);
5985 }
5986
5987 if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) {
5988 DEBUGOUT("Previous command timeout failed .\n");
5989 return -E1000_ERR_HOST_INTERFACE_COMMAND;
5990 }
5991 return E1000_SUCCESS;
5992}
5993
5994/*****************************************************************************
5995 * This function writes the buffer content at the offset given on the host if.
5996 * It also does alignment considerations to do the writes in most efficient way.
5997 * Also fills up the sum of the buffer in *buffer parameter.
5998 *
5999 * returns - E1000_SUCCESS for success.
6000 ****************************************************************************/
6001int32_t
6002e1000_mng_host_if_write(struct e1000_hw * hw, uint8_t *buffer,
6003 uint16_t length, uint16_t offset, uint8_t *sum)
6004{
6005 uint8_t *tmp;
6006 uint8_t *bufptr = buffer;
6007 uint32_t data;
6008 uint16_t remaining, i, j, prev_bytes;
6009
6010 /* sum = only sum of the data and it is not checksum */
6011
6012 if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH) {
6013 return -E1000_ERR_PARAM;
6014 }
6015
6016 tmp = (uint8_t *)&data;
6017 prev_bytes = offset & 0x3;
6018 offset &= 0xFFFC;
6019 offset >>= 2;
6020
6021 if (prev_bytes) {
6022 data = E1000_READ_REG_ARRAY_DWORD(hw, HOST_IF, offset);
6023 for (j = prev_bytes; j < sizeof(uint32_t); j++) {
6024 *(tmp + j) = *bufptr++;
6025 *sum += *(tmp + j);
6026 }
6027 E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, offset, data);
6028 length -= j - prev_bytes;
6029 offset++;
6030 }
6031
6032 remaining = length & 0x3;
6033 length -= remaining;
6034
6035 /* Calculate length in DWORDs */
6036 length >>= 2;
6037
6038 /* The device driver writes the relevant command block into the
6039 * ram area. */
6040 for (i = 0; i < length; i++) {
6041 for (j = 0; j < sizeof(uint32_t); j++) {
6042 *(tmp + j) = *bufptr++;
6043 *sum += *(tmp + j);
6044 }
6045
6046 E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, offset + i, data);
6047 }
6048 if (remaining) {
6049 for (j = 0; j < sizeof(uint32_t); j++) {
6050 if (j < remaining)
6051 *(tmp + j) = *bufptr++;
6052 else
6053 *(tmp + j) = 0;
6054
6055 *sum += *(tmp + j);
6056 }
6057 E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, offset + i, data);
6058 }
6059
6060 return E1000_SUCCESS;
6061}
6062
6063
6064/*****************************************************************************
6065 * This function writes the command header after does the checksum calculation.
6066 *
6067 * returns - E1000_SUCCESS for success.
6068 ****************************************************************************/
6069int32_t
6070e1000_mng_write_cmd_header(struct e1000_hw * hw,
6071 struct e1000_host_mng_command_header * hdr)
6072{
6073 uint16_t i;
6074 uint8_t sum;
6075 uint8_t *buffer;
6076
6077 /* Write the whole command header structure which includes sum of
6078 * the buffer */
6079
6080 uint16_t length = sizeof(struct e1000_host_mng_command_header);
6081
6082 sum = hdr->checksum;
6083 hdr->checksum = 0;
6084
6085 buffer = (uint8_t *) hdr;
6086 i = length;
6087 while(i--)
6088 sum += buffer[i];
6089
6090 hdr->checksum = 0 - sum;
6091
6092 length >>= 2;
6093 /* The device driver writes the relevant command block into the ram area. */
6094 for (i = 0; i < length; i++)
6095 E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, i, *((uint32_t *) hdr + i));
6096
6097 return E1000_SUCCESS;
6098}
6099
6100
6101/*****************************************************************************
6102 * This function indicates to ARC that a new command is pending which completes
6103 * one write operation by the driver.
6104 *
6105 * returns - E1000_SUCCESS for success.
6106 ****************************************************************************/
6107int32_t
6108e1000_mng_write_commit(
6109 struct e1000_hw * hw)
6110{
6111 uint32_t hicr;
6112
6113 hicr = E1000_READ_REG(hw, HICR);
6114 /* Setting this bit tells the ARC that a new command is pending. */
6115 E1000_WRITE_REG(hw, HICR, hicr | E1000_HICR_C);
6116
6117 return E1000_SUCCESS;
6118}
6119
6120
6121/*****************************************************************************
6122 * This function checks the mode of the firmware.
6123 *
6124 * returns - TRUE when the mode is IAMT or FALSE.
6125 ****************************************************************************/
6126boolean_t
6127e1000_check_mng_mode(
6128 struct e1000_hw *hw)
6129{
6130 uint32_t fwsm;
6131
6132 fwsm = E1000_READ_REG(hw, FWSM);
6133
6134 if((fwsm & E1000_FWSM_MODE_MASK) ==
6135 (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT))
6136 return TRUE;
6137
6138 return FALSE;
6139}
6140
6141
6142/*****************************************************************************
6143 * This function writes the dhcp info .
6144 ****************************************************************************/
6145int32_t
6146e1000_mng_write_dhcp_info(struct e1000_hw * hw, uint8_t *buffer,
6147 uint16_t length)
6148{
6149 int32_t ret_val;
6150 struct e1000_host_mng_command_header hdr;
6151
6152 hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD;
6153 hdr.command_length = length;
6154 hdr.reserved1 = 0;
6155 hdr.reserved2 = 0;
6156 hdr.checksum = 0;
6157
6158 ret_val = e1000_mng_enable_host_if(hw);
6159 if (ret_val == E1000_SUCCESS) {
6160 ret_val = e1000_mng_host_if_write(hw, buffer, length, sizeof(hdr),
6161 &(hdr.checksum));
6162 if (ret_val == E1000_SUCCESS) {
6163 ret_val = e1000_mng_write_cmd_header(hw, &hdr);
6164 if (ret_val == E1000_SUCCESS)
6165 ret_val = e1000_mng_write_commit(hw);
6166 }
6167 }
6168 return ret_val;
6169}
6170
6171
6172/*****************************************************************************
6173 * This function calculates the checksum.
6174 *
6175 * returns - checksum of buffer contents.
6176 ****************************************************************************/
6177uint8_t
6178e1000_calculate_mng_checksum(char *buffer, uint32_t length)
6179{
6180 uint8_t sum = 0;
6181 uint32_t i;
6182
6183 if (!buffer)
6184 return 0;
6185
6186 for (i=0; i < length; i++)
6187 sum += buffer[i];
6188
6189 return (uint8_t) (0 - sum);
6190}
6191
6192/*****************************************************************************
6193 * This function checks whether tx pkt filtering needs to be enabled or not.
6194 *
6195 * returns - TRUE for packet filtering or FALSE.
6196 ****************************************************************************/
6197boolean_t
6198e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
6199{
6200 /* called in init as well as watchdog timer functions */
6201
6202 int32_t ret_val, checksum;
6203 boolean_t tx_filter = FALSE;
6204 struct e1000_host_mng_dhcp_cookie *hdr = &(hw->mng_cookie);
6205 uint8_t *buffer = (uint8_t *) &(hw->mng_cookie);
6206
6207 if (e1000_check_mng_mode(hw)) {
6208 ret_val = e1000_mng_enable_host_if(hw);
6209 if (ret_val == E1000_SUCCESS) {
6210 ret_val = e1000_host_if_read_cookie(hw, buffer);
6211 if (ret_val == E1000_SUCCESS) {
6212 checksum = hdr->checksum;
6213 hdr->checksum = 0;
6214 if ((hdr->signature == E1000_IAMT_SIGNATURE) &&
6215 checksum == e1000_calculate_mng_checksum((char *)buffer,
6216 E1000_MNG_DHCP_COOKIE_LENGTH)) {
6217 if (hdr->status &
6218 E1000_MNG_DHCP_COOKIE_STATUS_PARSING_SUPPORT)
6219 tx_filter = TRUE;
6220 } else
6221 tx_filter = TRUE;
6222 } else
6223 tx_filter = TRUE;
6224 }
6225 }
6226
6227 hw->tx_pkt_filtering = tx_filter;
6228 return tx_filter;
6229}
6230
6231/******************************************************************************
6232 * Verifies the hardware needs to allow ARPs to be processed by the host
6233 *
6234 * hw - Struct containing variables accessed by shared code
6235 *
6236 * returns: - TRUE/FALSE
6237 *
6238 *****************************************************************************/
6239uint32_t
6240e1000_enable_mng_pass_thru(struct e1000_hw *hw)
6241{
6242 uint32_t manc;
6243 uint32_t fwsm, factps;
6244
6245 if (hw->asf_firmware_present) {
6246 manc = E1000_READ_REG(hw, MANC);
6247
6248 if (!(manc & E1000_MANC_RCV_TCO_EN) ||
6249 !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
6250 return FALSE;
6251 if (e1000_arc_subsystem_valid(hw) == TRUE) {
6252 fwsm = E1000_READ_REG(hw, FWSM);
6253 factps = E1000_READ_REG(hw, FACTPS);
6254
6255 if (((fwsm & E1000_FWSM_MODE_MASK) ==
6256 (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT)) &&
6257 (factps & E1000_FACTPS_MNGCG))
6258 return TRUE;
6259 } else
6260 if ((manc & E1000_MANC_SMBUS_EN) && !(manc & E1000_MANC_ASF_EN))
6261 return TRUE;
6262 }
6263 return FALSE;
6264}
6265
5321static int32_t 6266static int32_t
5322e1000_polarity_reversal_workaround(struct e1000_hw *hw) 6267e1000_polarity_reversal_workaround(struct e1000_hw *hw)
5323{ 6268{
@@ -5403,3 +6348,265 @@ e1000_polarity_reversal_workaround(struct e1000_hw *hw)
5403 return E1000_SUCCESS; 6348 return E1000_SUCCESS;
5404} 6349}
5405 6350
6351/***************************************************************************
6352 *
6353 * Disables PCI-Express master access.
6354 *
6355 * hw: Struct containing variables accessed by shared code
6356 *
6357 * returns: - none.
6358 *
6359 ***************************************************************************/
6360void
6361e1000_set_pci_express_master_disable(struct e1000_hw *hw)
6362{
6363 uint32_t ctrl;
6364
6365 DEBUGFUNC("e1000_set_pci_express_master_disable");
6366
6367 if (hw->bus_type != e1000_bus_type_pci_express)
6368 return;
6369
6370 ctrl = E1000_READ_REG(hw, CTRL);
6371 ctrl |= E1000_CTRL_GIO_MASTER_DISABLE;
6372 E1000_WRITE_REG(hw, CTRL, ctrl);
6373}
6374
6375/***************************************************************************
6376 *
6377 * Enables PCI-Express master access.
6378 *
6379 * hw: Struct containing variables accessed by shared code
6380 *
6381 * returns: - none.
6382 *
6383 ***************************************************************************/
6384void
6385e1000_enable_pciex_master(struct e1000_hw *hw)
6386{
6387 uint32_t ctrl;
6388
6389 DEBUGFUNC("e1000_enable_pciex_master");
6390
6391 if (hw->bus_type != e1000_bus_type_pci_express)
6392 return;
6393
6394 ctrl = E1000_READ_REG(hw, CTRL);
6395 ctrl &= ~E1000_CTRL_GIO_MASTER_DISABLE;
6396 E1000_WRITE_REG(hw, CTRL, ctrl);
6397}
6398
6399/*******************************************************************************
6400 *
6401 * Disables PCI-Express master access and verifies there are no pending requests
6402 *
6403 * hw: Struct containing variables accessed by shared code
6404 *
6405 * returns: - E1000_ERR_MASTER_REQUESTS_PENDING if master disable bit hasn't
6406 * caused the master requests to be disabled.
6407 * E1000_SUCCESS master requests disabled.
6408 *
6409 ******************************************************************************/
6410int32_t
6411e1000_disable_pciex_master(struct e1000_hw *hw)
6412{
6413 int32_t timeout = MASTER_DISABLE_TIMEOUT; /* 80ms */
6414
6415 DEBUGFUNC("e1000_disable_pciex_master");
6416
6417 if (hw->bus_type != e1000_bus_type_pci_express)
6418 return E1000_SUCCESS;
6419
6420 e1000_set_pci_express_master_disable(hw);
6421
6422 while(timeout) {
6423 if(!(E1000_READ_REG(hw, STATUS) & E1000_STATUS_GIO_MASTER_ENABLE))
6424 break;
6425 else
6426 udelay(100);
6427 timeout--;
6428 }
6429
6430 if(!timeout) {
6431 DEBUGOUT("Master requests are pending.\n");
6432 return -E1000_ERR_MASTER_REQUESTS_PENDING;
6433 }
6434
6435 return E1000_SUCCESS;
6436}
6437
6438/*******************************************************************************
6439 *
6440 * Check for EEPROM Auto Read bit done.
6441 *
6442 * hw: Struct containing variables accessed by shared code
6443 *
6444 * returns: - E1000_ERR_RESET if fail to reset MAC
6445 * E1000_SUCCESS at any other case.
6446 *
6447 ******************************************************************************/
6448int32_t
6449e1000_get_auto_rd_done(struct e1000_hw *hw)
6450{
6451 int32_t timeout = AUTO_READ_DONE_TIMEOUT;
6452
6453 DEBUGFUNC("e1000_get_auto_rd_done");
6454
6455 switch (hw->mac_type) {
6456 default:
6457 msec_delay(5);
6458 break;
6459 case e1000_82573:
6460 while(timeout) {
6461 if (E1000_READ_REG(hw, EECD) & E1000_EECD_AUTO_RD) break;
6462 else msec_delay(1);
6463 timeout--;
6464 }
6465
6466 if(!timeout) {
6467 DEBUGOUT("Auto read by HW from EEPROM has not completed.\n");
6468 return -E1000_ERR_RESET;
6469 }
6470 break;
6471 }
6472
6473 return E1000_SUCCESS;
6474}
6475
6476/***************************************************************************
6477 * Checks if the PHY configuration is done
6478 *
6479 * hw: Struct containing variables accessed by shared code
6480 *
6481 * returns: - E1000_ERR_RESET if fail to reset MAC
6482 * E1000_SUCCESS at any other case.
6483 *
6484 ***************************************************************************/
6485int32_t
6486e1000_get_phy_cfg_done(struct e1000_hw *hw)
6487{
6488 DEBUGFUNC("e1000_get_phy_cfg_done");
6489
6490 /* Simply wait for 10ms */
6491 msec_delay(10);
6492
6493 return E1000_SUCCESS;
6494}
6495
6496/***************************************************************************
6497 *
6498 * Using the combination of SMBI and SWESMBI semaphore bits when resetting
6499 * adapter or Eeprom access.
6500 *
6501 * hw: Struct containing variables accessed by shared code
6502 *
6503 * returns: - E1000_ERR_EEPROM if fail to access EEPROM.
6504 * E1000_SUCCESS at any other case.
6505 *
6506 ***************************************************************************/
6507int32_t
6508e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw)
6509{
6510 int32_t timeout;
6511 uint32_t swsm;
6512
6513 DEBUGFUNC("e1000_get_hw_eeprom_semaphore");
6514
6515 if(!hw->eeprom_semaphore_present)
6516 return E1000_SUCCESS;
6517
6518
6519 /* Get the FW semaphore. */
6520 timeout = hw->eeprom.word_size + 1;
6521 while(timeout) {
6522 swsm = E1000_READ_REG(hw, SWSM);
6523 swsm |= E1000_SWSM_SWESMBI;
6524 E1000_WRITE_REG(hw, SWSM, swsm);
6525 /* if we managed to set the bit we got the semaphore. */
6526 swsm = E1000_READ_REG(hw, SWSM);
6527 if(swsm & E1000_SWSM_SWESMBI)
6528 break;
6529
6530 udelay(50);
6531 timeout--;
6532 }
6533
6534 if(!timeout) {
6535 /* Release semaphores */
6536 e1000_put_hw_eeprom_semaphore(hw);
6537 DEBUGOUT("Driver can't access the Eeprom - SWESMBI bit is set.\n");
6538 return -E1000_ERR_EEPROM;
6539 }
6540
6541 return E1000_SUCCESS;
6542}
6543
6544/***************************************************************************
6545 * This function clears HW semaphore bits.
6546 *
6547 * hw: Struct containing variables accessed by shared code
6548 *
6549 * returns: - None.
6550 *
6551 ***************************************************************************/
6552void
6553e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw)
6554{
6555 uint32_t swsm;
6556
6557 DEBUGFUNC("e1000_put_hw_eeprom_semaphore");
6558
6559 if(!hw->eeprom_semaphore_present)
6560 return;
6561
6562 swsm = E1000_READ_REG(hw, SWSM);
6563 /* Release both semaphores. */
6564 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
6565 E1000_WRITE_REG(hw, SWSM, swsm);
6566}
6567
6568/******************************************************************************
6569 * Checks if PHY reset is blocked due to SOL/IDER session, for example.
6570 * Returning E1000_BLK_PHY_RESET isn't necessarily an error. But it's up to
6571 * the caller to figure out how to deal with it.
6572 *
6573 * hw - Struct containing variables accessed by shared code
6574 *
6575 * returns: - E1000_BLK_PHY_RESET
6576 * E1000_SUCCESS
6577 *
6578 *****************************************************************************/
6579int32_t
6580e1000_check_phy_reset_block(struct e1000_hw *hw)
6581{
6582 uint32_t manc = 0;
6583 if(hw->mac_type > e1000_82547_rev_2)
6584 manc = E1000_READ_REG(hw, MANC);
6585 return (manc & E1000_MANC_BLK_PHY_RST_ON_IDE) ?
6586 E1000_BLK_PHY_RESET : E1000_SUCCESS;
6587}
6588
6589uint8_t
6590e1000_arc_subsystem_valid(struct e1000_hw *hw)
6591{
6592 uint32_t fwsm;
6593
6594 /* On 8257x silicon, registers in the range of 0x8800 - 0x8FFC
6595 * may not be provided a DMA clock when no manageability features are
6596 * enabled. We do not want to perform any reads/writes to these registers
6597 * if this is the case. We read FWSM to determine the manageability mode.
6598 */
6599 switch (hw->mac_type) {
6600 case e1000_82573:
6601 fwsm = E1000_READ_REG(hw, FWSM);
6602 if((fwsm & E1000_FWSM_MODE_MASK) != 0)
6603 return TRUE;
6604 break;
6605 default:
6606 break;
6607 }
6608 return FALSE;
6609}
6610
6611
6612
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index f397e637a3c5..a0263ee96c6b 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -57,6 +57,7 @@ typedef enum {
57 e1000_82541_rev_2, 57 e1000_82541_rev_2,
58 e1000_82547, 58 e1000_82547,
59 e1000_82547_rev_2, 59 e1000_82547_rev_2,
60 e1000_82573,
60 e1000_num_macs 61 e1000_num_macs
61} e1000_mac_type; 62} e1000_mac_type;
62 63
@@ -64,6 +65,7 @@ typedef enum {
64 e1000_eeprom_uninitialized = 0, 65 e1000_eeprom_uninitialized = 0,
65 e1000_eeprom_spi, 66 e1000_eeprom_spi,
66 e1000_eeprom_microwire, 67 e1000_eeprom_microwire,
68 e1000_eeprom_flash,
67 e1000_num_eeprom_types 69 e1000_num_eeprom_types
68} e1000_eeprom_type; 70} e1000_eeprom_type;
69 71
@@ -96,6 +98,7 @@ typedef enum {
96 e1000_bus_type_unknown = 0, 98 e1000_bus_type_unknown = 0,
97 e1000_bus_type_pci, 99 e1000_bus_type_pci,
98 e1000_bus_type_pcix, 100 e1000_bus_type_pcix,
101 e1000_bus_type_pci_express,
99 e1000_bus_type_reserved 102 e1000_bus_type_reserved
100} e1000_bus_type; 103} e1000_bus_type;
101 104
@@ -107,6 +110,7 @@ typedef enum {
107 e1000_bus_speed_100, 110 e1000_bus_speed_100,
108 e1000_bus_speed_120, 111 e1000_bus_speed_120,
109 e1000_bus_speed_133, 112 e1000_bus_speed_133,
113 e1000_bus_speed_2500,
110 e1000_bus_speed_reserved 114 e1000_bus_speed_reserved
111} e1000_bus_speed; 115} e1000_bus_speed;
112 116
@@ -115,6 +119,8 @@ typedef enum {
115 e1000_bus_width_unknown = 0, 119 e1000_bus_width_unknown = 0,
116 e1000_bus_width_32, 120 e1000_bus_width_32,
117 e1000_bus_width_64, 121 e1000_bus_width_64,
122 e1000_bus_width_pciex_1,
123 e1000_bus_width_pciex_4,
118 e1000_bus_width_reserved 124 e1000_bus_width_reserved
119} e1000_bus_width; 125} e1000_bus_width;
120 126
@@ -196,6 +202,7 @@ typedef enum {
196typedef enum { 202typedef enum {
197 e1000_phy_m88 = 0, 203 e1000_phy_m88 = 0,
198 e1000_phy_igp, 204 e1000_phy_igp,
205 e1000_phy_igp_2,
199 e1000_phy_undefined = 0xFF 206 e1000_phy_undefined = 0xFF
200} e1000_phy_type; 207} e1000_phy_type;
201 208
@@ -242,8 +249,19 @@ struct e1000_eeprom_info {
242 uint16_t address_bits; 249 uint16_t address_bits;
243 uint16_t delay_usec; 250 uint16_t delay_usec;
244 uint16_t page_size; 251 uint16_t page_size;
252 boolean_t use_eerd;
253 boolean_t use_eewr;
245}; 254};
246 255
256/* Flex ASF Information */
257#define E1000_HOST_IF_MAX_SIZE 2048
258
259typedef enum {
260 e1000_byte_align = 0,
261 e1000_word_align = 1,
262 e1000_dword_align = 2
263} e1000_align_type;
264
247 265
248 266
249/* Error Codes */ 267/* Error Codes */
@@ -254,11 +272,16 @@ struct e1000_eeprom_info {
254#define E1000_ERR_PARAM 4 272#define E1000_ERR_PARAM 4
255#define E1000_ERR_MAC_TYPE 5 273#define E1000_ERR_MAC_TYPE 5
256#define E1000_ERR_PHY_TYPE 6 274#define E1000_ERR_PHY_TYPE 6
275#define E1000_ERR_RESET 9
276#define E1000_ERR_MASTER_REQUESTS_PENDING 10
277#define E1000_ERR_HOST_INTERFACE_COMMAND 11
278#define E1000_BLK_PHY_RESET 12
257 279
258/* Function prototypes */ 280/* Function prototypes */
259/* Initialization */ 281/* Initialization */
260int32_t e1000_reset_hw(struct e1000_hw *hw); 282int32_t e1000_reset_hw(struct e1000_hw *hw);
261int32_t e1000_init_hw(struct e1000_hw *hw); 283int32_t e1000_init_hw(struct e1000_hw *hw);
284int32_t e1000_id_led_init(struct e1000_hw * hw);
262int32_t e1000_set_mac_type(struct e1000_hw *hw); 285int32_t e1000_set_mac_type(struct e1000_hw *hw);
263void e1000_set_media_type(struct e1000_hw *hw); 286void e1000_set_media_type(struct e1000_hw *hw);
264 287
@@ -275,7 +298,7 @@ int32_t e1000_force_mac_fc(struct e1000_hw *hw);
275/* PHY */ 298/* PHY */
276int32_t e1000_read_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *phy_data); 299int32_t e1000_read_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *phy_data);
277int32_t e1000_write_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t data); 300int32_t e1000_write_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t data);
278void e1000_phy_hw_reset(struct e1000_hw *hw); 301int32_t e1000_phy_hw_reset(struct e1000_hw *hw);
279int32_t e1000_phy_reset(struct e1000_hw *hw); 302int32_t e1000_phy_reset(struct e1000_hw *hw);
280int32_t e1000_detect_gig_phy(struct e1000_hw *hw); 303int32_t e1000_detect_gig_phy(struct e1000_hw *hw);
281int32_t e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info); 304int32_t e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info);
@@ -287,13 +310,86 @@ int32_t e1000_check_downshift(struct e1000_hw *hw);
287int32_t e1000_validate_mdi_setting(struct e1000_hw *hw); 310int32_t e1000_validate_mdi_setting(struct e1000_hw *hw);
288 311
289/* EEPROM Functions */ 312/* EEPROM Functions */
290void e1000_init_eeprom_params(struct e1000_hw *hw); 313int32_t e1000_init_eeprom_params(struct e1000_hw *hw);
314boolean_t e1000_is_onboard_nvm_eeprom(struct e1000_hw *hw);
315int32_t e1000_read_eeprom_eerd(struct e1000_hw *hw, uint16_t offset, uint16_t words, uint16_t *data);
316int32_t e1000_write_eeprom_eewr(struct e1000_hw *hw, uint16_t offset, uint16_t words, uint16_t *data);
317int32_t e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd);
318
319/* MNG HOST IF functions */
320uint32_t e1000_enable_mng_pass_thru(struct e1000_hw *hw);
321
322#define E1000_MNG_DHCP_TX_PAYLOAD_CMD 64
323#define E1000_HI_MAX_MNG_DATA_LENGTH 0x6F8 /* Host Interface data length */
324
325#define E1000_MNG_DHCP_COMMAND_TIMEOUT 10 /* Time in ms to process MNG command */
326#define E1000_MNG_DHCP_COOKIE_OFFSET 0x6F0 /* Cookie offset */
327#define E1000_MNG_DHCP_COOKIE_LENGTH 0x10 /* Cookie length */
328#define E1000_MNG_IAMT_MODE 0x3
329#define E1000_IAMT_SIGNATURE 0x544D4149 /* Intel(R) Active Management Technology signature */
330
331#define E1000_MNG_DHCP_COOKIE_STATUS_PARSING_SUPPORT 0x1 /* DHCP parsing enabled */
332#define E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT 0x2 /* DHCP parsing enabled */
333#define E1000_VFTA_ENTRY_SHIFT 0x5
334#define E1000_VFTA_ENTRY_MASK 0x7F
335#define E1000_VFTA_ENTRY_BIT_SHIFT_MASK 0x1F
336
337struct e1000_host_mng_command_header {
338 uint8_t command_id;
339 uint8_t checksum;
340 uint16_t reserved1;
341 uint16_t reserved2;
342 uint16_t command_length;
343};
344
345struct e1000_host_mng_command_info {
346 struct e1000_host_mng_command_header command_header; /* Command Head/Command Result Head has 4 bytes */
347 uint8_t command_data[E1000_HI_MAX_MNG_DATA_LENGTH]; /* Command data can length 0..0x658*/
348};
349#ifdef __BIG_ENDIAN
350struct e1000_host_mng_dhcp_cookie{
351 uint32_t signature;
352 uint16_t vlan_id;
353 uint8_t reserved0;
354 uint8_t status;
355 uint32_t reserved1;
356 uint8_t checksum;
357 uint8_t reserved3;
358 uint16_t reserved2;
359};
360#else
361struct e1000_host_mng_dhcp_cookie{
362 uint32_t signature;
363 uint8_t status;
364 uint8_t reserved0;
365 uint16_t vlan_id;
366 uint32_t reserved1;
367 uint16_t reserved2;
368 uint8_t reserved3;
369 uint8_t checksum;
370};
371#endif
372
373int32_t e1000_mng_write_dhcp_info(struct e1000_hw *hw, uint8_t *buffer,
374 uint16_t length);
375boolean_t e1000_check_mng_mode(struct e1000_hw *hw);
376boolean_t e1000_enable_tx_pkt_filtering(struct e1000_hw *hw);
377int32_t e1000_mng_enable_host_if(struct e1000_hw *hw);
378int32_t e1000_mng_host_if_write(struct e1000_hw *hw, uint8_t *buffer,
379 uint16_t length, uint16_t offset, uint8_t *sum);
380int32_t e1000_mng_write_cmd_header(struct e1000_hw* hw,
381 struct e1000_host_mng_command_header* hdr);
382
383int32_t e1000_mng_write_commit(struct e1000_hw *hw);
384
291int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data); 385int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data);
292int32_t e1000_validate_eeprom_checksum(struct e1000_hw *hw); 386int32_t e1000_validate_eeprom_checksum(struct e1000_hw *hw);
293int32_t e1000_update_eeprom_checksum(struct e1000_hw *hw); 387int32_t e1000_update_eeprom_checksum(struct e1000_hw *hw);
294int32_t e1000_write_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data); 388int32_t e1000_write_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data);
295int32_t e1000_read_part_num(struct e1000_hw *hw, uint32_t * part_num); 389int32_t e1000_read_part_num(struct e1000_hw *hw, uint32_t * part_num);
296int32_t e1000_read_mac_addr(struct e1000_hw * hw); 390int32_t e1000_read_mac_addr(struct e1000_hw * hw);
391int32_t e1000_swfw_sync_acquire(struct e1000_hw *hw, uint16_t mask);
392void e1000_swfw_sync_release(struct e1000_hw *hw, uint16_t mask);
297 393
298/* Filters (multicast, vlan, receive) */ 394/* Filters (multicast, vlan, receive) */
299void e1000_init_rx_addrs(struct e1000_hw *hw); 395void e1000_init_rx_addrs(struct e1000_hw *hw);
@@ -313,7 +409,6 @@ int32_t e1000_led_off(struct e1000_hw *hw);
313/* Adaptive IFS Functions */ 409/* Adaptive IFS Functions */
314 410
315/* Everything else */ 411/* Everything else */
316uint32_t e1000_enable_mng_pass_thru(struct e1000_hw *hw);
317void e1000_clear_hw_cntrs(struct e1000_hw *hw); 412void e1000_clear_hw_cntrs(struct e1000_hw *hw);
318void e1000_reset_adaptive(struct e1000_hw *hw); 413void e1000_reset_adaptive(struct e1000_hw *hw);
319void e1000_update_adaptive(struct e1000_hw *hw); 414void e1000_update_adaptive(struct e1000_hw *hw);
@@ -330,6 +425,19 @@ void e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value);
330void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset, uint32_t value); 425void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset, uint32_t value);
331int32_t e1000_config_dsp_after_link_change(struct e1000_hw *hw, boolean_t link_up); 426int32_t e1000_config_dsp_after_link_change(struct e1000_hw *hw, boolean_t link_up);
332int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active); 427int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active);
428int32_t e1000_set_d0_lplu_state(struct e1000_hw *hw, boolean_t active);
429void e1000_set_pci_express_master_disable(struct e1000_hw *hw);
430void e1000_enable_pciex_master(struct e1000_hw *hw);
431int32_t e1000_disable_pciex_master(struct e1000_hw *hw);
432int32_t e1000_get_auto_rd_done(struct e1000_hw *hw);
433int32_t e1000_get_phy_cfg_done(struct e1000_hw *hw);
434int32_t e1000_get_software_semaphore(struct e1000_hw *hw);
435void e1000_release_software_semaphore(struct e1000_hw *hw);
436int32_t e1000_check_phy_reset_block(struct e1000_hw *hw);
437int32_t e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw);
438void e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw);
439int32_t e1000_commit_shadow_ram(struct e1000_hw *hw);
440uint8_t e1000_arc_subsystem_valid(struct e1000_hw *hw);
333 441
334#define E1000_READ_REG_IO(a, reg) \ 442#define E1000_READ_REG_IO(a, reg) \
335 e1000_read_reg_io((a), E1000_##reg) 443 e1000_read_reg_io((a), E1000_##reg)
@@ -369,6 +477,10 @@ int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active);
369#define E1000_DEV_ID_82546GB_SERDES 0x107B 477#define E1000_DEV_ID_82546GB_SERDES 0x107B
370#define E1000_DEV_ID_82546GB_PCIE 0x108A 478#define E1000_DEV_ID_82546GB_PCIE 0x108A
371#define E1000_DEV_ID_82547EI 0x1019 479#define E1000_DEV_ID_82547EI 0x1019
480#define E1000_DEV_ID_82573E 0x108B
481#define E1000_DEV_ID_82573E_IAMT 0x108C
482
483#define E1000_DEV_ID_82546GB_QUAD_COPPER 0x1099
372 484
373#define NODE_ADDRESS_SIZE 6 485#define NODE_ADDRESS_SIZE 6
374#define ETH_LENGTH_OF_ADDRESS 6 486#define ETH_LENGTH_OF_ADDRESS 6
@@ -381,6 +493,7 @@ int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active);
381#define E1000_REVISION_0 0 493#define E1000_REVISION_0 0
382#define E1000_REVISION_1 1 494#define E1000_REVISION_1 1
383#define E1000_REVISION_2 2 495#define E1000_REVISION_2 2
496#define E1000_REVISION_3 3
384 497
385#define SPEED_10 10 498#define SPEED_10 10
386#define SPEED_100 100 499#define SPEED_100 100
@@ -437,6 +550,7 @@ int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active);
437 E1000_IMS_RXSEQ | \ 550 E1000_IMS_RXSEQ | \
438 E1000_IMS_LSC) 551 E1000_IMS_LSC)
439 552
553
440/* Number of high/low register pairs in the RAR. The RAR (Receive Address 554/* Number of high/low register pairs in the RAR. The RAR (Receive Address
441 * Registers) holds the directed and multicast addresses that we monitor. We 555 * Registers) holds the directed and multicast addresses that we monitor. We
442 * reserve one of these spots for our directed address, allowing us room for 556 * reserve one of these spots for our directed address, allowing us room for
@@ -457,14 +571,74 @@ struct e1000_rx_desc {
457 uint16_t special; 571 uint16_t special;
458}; 572};
459 573
574/* Receive Descriptor - Extended */
575union e1000_rx_desc_extended {
576 struct {
577 uint64_t buffer_addr;
578 uint64_t reserved;
579 } read;
580 struct {
581 struct {
582 uint32_t mrq; /* Multiple Rx Queues */
583 union {
584 uint32_t rss; /* RSS Hash */
585 struct {
586 uint16_t ip_id; /* IP id */
587 uint16_t csum; /* Packet Checksum */
588 } csum_ip;
589 } hi_dword;
590 } lower;
591 struct {
592 uint32_t status_error; /* ext status/error */
593 uint16_t length;
594 uint16_t vlan; /* VLAN tag */
595 } upper;
596 } wb; /* writeback */
597};
598
599#define MAX_PS_BUFFERS 4
600/* Receive Descriptor - Packet Split */
601union e1000_rx_desc_packet_split {
602 struct {
603 /* one buffer for protocol header(s), three data buffers */
604 uint64_t buffer_addr[MAX_PS_BUFFERS];
605 } read;
606 struct {
607 struct {
608 uint32_t mrq; /* Multiple Rx Queues */
609 union {
610 uint32_t rss; /* RSS Hash */
611 struct {
612 uint16_t ip_id; /* IP id */
613 uint16_t csum; /* Packet Checksum */
614 } csum_ip;
615 } hi_dword;
616 } lower;
617 struct {
618 uint32_t status_error; /* ext status/error */
619 uint16_t length0; /* length of buffer 0 */
620 uint16_t vlan; /* VLAN tag */
621 } middle;
622 struct {
623 uint16_t header_status;
624 uint16_t length[3]; /* length of buffers 1-3 */
625 } upper;
626 uint64_t reserved;
627 } wb; /* writeback */
628};
629
460/* Receive Decriptor bit definitions */ 630/* Receive Decriptor bit definitions */
461#define E1000_RXD_STAT_DD 0x01 /* Descriptor Done */ 631#define E1000_RXD_STAT_DD 0x01 /* Descriptor Done */
462#define E1000_RXD_STAT_EOP 0x02 /* End of Packet */ 632#define E1000_RXD_STAT_EOP 0x02 /* End of Packet */
463#define E1000_RXD_STAT_IXSM 0x04 /* Ignore checksum */ 633#define E1000_RXD_STAT_IXSM 0x04 /* Ignore checksum */
464#define E1000_RXD_STAT_VP 0x08 /* IEEE VLAN Packet */ 634#define E1000_RXD_STAT_VP 0x08 /* IEEE VLAN Packet */
635#define E1000_RXD_STAT_UDPCS 0x10 /* UDP xsum caculated */
465#define E1000_RXD_STAT_TCPCS 0x20 /* TCP xsum calculated */ 636#define E1000_RXD_STAT_TCPCS 0x20 /* TCP xsum calculated */
466#define E1000_RXD_STAT_IPCS 0x40 /* IP xsum calculated */ 637#define E1000_RXD_STAT_IPCS 0x40 /* IP xsum calculated */
467#define E1000_RXD_STAT_PIF 0x80 /* passed in-exact filter */ 638#define E1000_RXD_STAT_PIF 0x80 /* passed in-exact filter */
639#define E1000_RXD_STAT_IPIDV 0x200 /* IP identification valid */
640#define E1000_RXD_STAT_UDPV 0x400 /* Valid UDP checksum */
641#define E1000_RXD_STAT_ACK 0x8000 /* ACK Packet indication */
468#define E1000_RXD_ERR_CE 0x01 /* CRC Error */ 642#define E1000_RXD_ERR_CE 0x01 /* CRC Error */
469#define E1000_RXD_ERR_SE 0x02 /* Symbol Error */ 643#define E1000_RXD_ERR_SE 0x02 /* Symbol Error */
470#define E1000_RXD_ERR_SEQ 0x04 /* Sequence Error */ 644#define E1000_RXD_ERR_SEQ 0x04 /* Sequence Error */
@@ -474,9 +648,20 @@ struct e1000_rx_desc {
474#define E1000_RXD_ERR_RXE 0x80 /* Rx Data Error */ 648#define E1000_RXD_ERR_RXE 0x80 /* Rx Data Error */
475#define E1000_RXD_SPC_VLAN_MASK 0x0FFF /* VLAN ID is in lower 12 bits */ 649#define E1000_RXD_SPC_VLAN_MASK 0x0FFF /* VLAN ID is in lower 12 bits */
476#define E1000_RXD_SPC_PRI_MASK 0xE000 /* Priority is in upper 3 bits */ 650#define E1000_RXD_SPC_PRI_MASK 0xE000 /* Priority is in upper 3 bits */
477#define E1000_RXD_SPC_PRI_SHIFT 0x000D /* Priority is in upper 3 of 16 */ 651#define E1000_RXD_SPC_PRI_SHIFT 13
478#define E1000_RXD_SPC_CFI_MASK 0x1000 /* CFI is bit 12 */ 652#define E1000_RXD_SPC_CFI_MASK 0x1000 /* CFI is bit 12 */
479#define E1000_RXD_SPC_CFI_SHIFT 0x000C /* CFI is bit 12 */ 653#define E1000_RXD_SPC_CFI_SHIFT 12
654
655#define E1000_RXDEXT_STATERR_CE 0x01000000
656#define E1000_RXDEXT_STATERR_SE 0x02000000
657#define E1000_RXDEXT_STATERR_SEQ 0x04000000
658#define E1000_RXDEXT_STATERR_CXE 0x10000000
659#define E1000_RXDEXT_STATERR_TCPE 0x20000000
660#define E1000_RXDEXT_STATERR_IPE 0x40000000
661#define E1000_RXDEXT_STATERR_RXE 0x80000000
662
663#define E1000_RXDPS_HDRSTAT_HDRSP 0x00008000
664#define E1000_RXDPS_HDRSTAT_HDRLEN_MASK 0x000003FF
480 665
481/* mask to determine if packets should be dropped due to frame errors */ 666/* mask to determine if packets should be dropped due to frame errors */
482#define E1000_RXD_ERR_FRAME_ERR_MASK ( \ 667#define E1000_RXD_ERR_FRAME_ERR_MASK ( \
@@ -486,6 +671,15 @@ struct e1000_rx_desc {
486 E1000_RXD_ERR_CXE | \ 671 E1000_RXD_ERR_CXE | \
487 E1000_RXD_ERR_RXE) 672 E1000_RXD_ERR_RXE)
488 673
674
675/* Same mask, but for extended and packet split descriptors */
676#define E1000_RXDEXT_ERR_FRAME_ERR_MASK ( \
677 E1000_RXDEXT_STATERR_CE | \
678 E1000_RXDEXT_STATERR_SE | \
679 E1000_RXDEXT_STATERR_SEQ | \
680 E1000_RXDEXT_STATERR_CXE | \
681 E1000_RXDEXT_STATERR_RXE)
682
489/* Transmit Descriptor */ 683/* Transmit Descriptor */
490struct e1000_tx_desc { 684struct e1000_tx_desc {
491 uint64_t buffer_addr; /* Address of the descriptor's data buffer */ 685 uint64_t buffer_addr; /* Address of the descriptor's data buffer */
@@ -667,6 +861,7 @@ struct e1000_ffvt_entry {
667#define E1000_ICS 0x000C8 /* Interrupt Cause Set - WO */ 861#define E1000_ICS 0x000C8 /* Interrupt Cause Set - WO */
668#define E1000_IMS 0x000D0 /* Interrupt Mask Set - RW */ 862#define E1000_IMS 0x000D0 /* Interrupt Mask Set - RW */
669#define E1000_IMC 0x000D8 /* Interrupt Mask Clear - WO */ 863#define E1000_IMC 0x000D8 /* Interrupt Mask Clear - WO */
864#define E1000_IAM 0x000E0 /* Interrupt Acknowledge Auto Mask */
670#define E1000_RCTL 0x00100 /* RX Control - RW */ 865#define E1000_RCTL 0x00100 /* RX Control - RW */
671#define E1000_FCTTV 0x00170 /* Flow Control Transmit Timer Value - RW */ 866#define E1000_FCTTV 0x00170 /* Flow Control Transmit Timer Value - RW */
672#define E1000_TXCW 0x00178 /* TX Configuration Word - RW */ 867#define E1000_TXCW 0x00178 /* TX Configuration Word - RW */
@@ -676,9 +871,23 @@ struct e1000_ffvt_entry {
676#define E1000_TBT 0x00448 /* TX Burst Timer - RW */ 871#define E1000_TBT 0x00448 /* TX Burst Timer - RW */
677#define E1000_AIT 0x00458 /* Adaptive Interframe Spacing Throttle - RW */ 872#define E1000_AIT 0x00458 /* Adaptive Interframe Spacing Throttle - RW */
678#define E1000_LEDCTL 0x00E00 /* LED Control - RW */ 873#define E1000_LEDCTL 0x00E00 /* LED Control - RW */
874#define E1000_EXTCNF_CTRL 0x00F00 /* Extended Configuration Control */
875#define E1000_EXTCNF_SIZE 0x00F08 /* Extended Configuration Size */
679#define E1000_PBA 0x01000 /* Packet Buffer Allocation - RW */ 876#define E1000_PBA 0x01000 /* Packet Buffer Allocation - RW */
877#define E1000_PBS 0x01008 /* Packet Buffer Size */
878#define E1000_EEMNGCTL 0x01010 /* MNG EEprom Control */
879#define E1000_FLASH_UPDATES 1000
880#define E1000_EEARBC 0x01024 /* EEPROM Auto Read Bus Control */
881#define E1000_FLASHT 0x01028 /* FLASH Timer Register */
882#define E1000_EEWR 0x0102C /* EEPROM Write Register - RW */
883#define E1000_FLSWCTL 0x01030 /* FLASH control register */
884#define E1000_FLSWDATA 0x01034 /* FLASH data register */
885#define E1000_FLSWCNT 0x01038 /* FLASH Access Counter */
886#define E1000_FLOP 0x0103C /* FLASH Opcode Register */
887#define E1000_ERT 0x02008 /* Early Rx Threshold - RW */
680#define E1000_FCRTL 0x02160 /* Flow Control Receive Threshold Low - RW */ 888#define E1000_FCRTL 0x02160 /* Flow Control Receive Threshold Low - RW */
681#define E1000_FCRTH 0x02168 /* Flow Control Receive Threshold High - RW */ 889#define E1000_FCRTH 0x02168 /* Flow Control Receive Threshold High - RW */
890#define E1000_PSRCTL 0x02170 /* Packet Split Receive Control - RW */
682#define E1000_RDBAL 0x02800 /* RX Descriptor Base Address Low - RW */ 891#define E1000_RDBAL 0x02800 /* RX Descriptor Base Address Low - RW */
683#define E1000_RDBAH 0x02804 /* RX Descriptor Base Address High - RW */ 892#define E1000_RDBAH 0x02804 /* RX Descriptor Base Address High - RW */
684#define E1000_RDLEN 0x02808 /* RX Descriptor Length - RW */ 893#define E1000_RDLEN 0x02808 /* RX Descriptor Length - RW */
@@ -688,6 +897,7 @@ struct e1000_ffvt_entry {
688#define E1000_RXDCTL 0x02828 /* RX Descriptor Control - RW */ 897#define E1000_RXDCTL 0x02828 /* RX Descriptor Control - RW */
689#define E1000_RADV 0x0282C /* RX Interrupt Absolute Delay Timer - RW */ 898#define E1000_RADV 0x0282C /* RX Interrupt Absolute Delay Timer - RW */
690#define E1000_RSRPD 0x02C00 /* RX Small Packet Detect - RW */ 899#define E1000_RSRPD 0x02C00 /* RX Small Packet Detect - RW */
900#define E1000_RAID 0x02C08 /* Receive Ack Interrupt Delay - RW */
691#define E1000_TXDMAC 0x03000 /* TX DMA Control - RW */ 901#define E1000_TXDMAC 0x03000 /* TX DMA Control - RW */
692#define E1000_TDFH 0x03410 /* TX Data FIFO Head - RW */ 902#define E1000_TDFH 0x03410 /* TX Data FIFO Head - RW */
693#define E1000_TDFT 0x03418 /* TX Data FIFO Tail - RW */ 903#define E1000_TDFT 0x03418 /* TX Data FIFO Tail - RW */
@@ -703,6 +913,14 @@ struct e1000_ffvt_entry {
703#define E1000_TXDCTL 0x03828 /* TX Descriptor Control - RW */ 913#define E1000_TXDCTL 0x03828 /* TX Descriptor Control - RW */
704#define E1000_TADV 0x0382C /* TX Interrupt Absolute Delay Val - RW */ 914#define E1000_TADV 0x0382C /* TX Interrupt Absolute Delay Val - RW */
705#define E1000_TSPMT 0x03830 /* TCP Segmentation PAD & Min Threshold - RW */ 915#define E1000_TSPMT 0x03830 /* TCP Segmentation PAD & Min Threshold - RW */
916#define E1000_TARC0 0x03840 /* TX Arbitration Count (0) */
917#define E1000_TDBAL1 0x03900 /* TX Desc Base Address Low (1) - RW */
918#define E1000_TDBAH1 0x03904 /* TX Desc Base Address High (1) - RW */
919#define E1000_TDLEN1 0x03908 /* TX Desc Length (1) - RW */
920#define E1000_TDH1 0x03910 /* TX Desc Head (1) - RW */
921#define E1000_TDT1 0x03918 /* TX Desc Tail (1) - RW */
922#define E1000_TXDCTL1 0x03928 /* TX Descriptor Control (1) - RW */
923#define E1000_TARC1 0x03940 /* TX Arbitration Count (1) */
706#define E1000_CRCERRS 0x04000 /* CRC Error Count - R/clr */ 924#define E1000_CRCERRS 0x04000 /* CRC Error Count - R/clr */
707#define E1000_ALGNERRC 0x04004 /* Alignment Error Count - R/clr */ 925#define E1000_ALGNERRC 0x04004 /* Alignment Error Count - R/clr */
708#define E1000_SYMERRS 0x04008 /* Symbol Error Count - R/clr */ 926#define E1000_SYMERRS 0x04008 /* Symbol Error Count - R/clr */
@@ -761,7 +979,17 @@ struct e1000_ffvt_entry {
761#define E1000_BPTC 0x040F4 /* Broadcast Packets TX Count - R/clr */ 979#define E1000_BPTC 0x040F4 /* Broadcast Packets TX Count - R/clr */
762#define E1000_TSCTC 0x040F8 /* TCP Segmentation Context TX - R/clr */ 980#define E1000_TSCTC 0x040F8 /* TCP Segmentation Context TX - R/clr */
763#define E1000_TSCTFC 0x040FC /* TCP Segmentation Context TX Fail - R/clr */ 981#define E1000_TSCTFC 0x040FC /* TCP Segmentation Context TX Fail - R/clr */
982#define E1000_IAC 0x4100 /* Interrupt Assertion Count */
983#define E1000_ICRXPTC 0x4104 /* Interrupt Cause Rx Packet Timer Expire Count */
984#define E1000_ICRXATC 0x4108 /* Interrupt Cause Rx Absolute Timer Expire Count */
985#define E1000_ICTXPTC 0x410C /* Interrupt Cause Tx Packet Timer Expire Count */
986#define E1000_ICTXATC 0x4110 /* Interrupt Cause Tx Absolute Timer Expire Count */
987#define E1000_ICTXQEC 0x4118 /* Interrupt Cause Tx Queue Empty Count */
988#define E1000_ICTXQMTC 0x411C /* Interrupt Cause Tx Queue Minimum Threshold Count */
989#define E1000_ICRXDMTC 0x4120 /* Interrupt Cause Rx Descriptor Minimum Threshold Count */
990#define E1000_ICRXOC 0x4124 /* Interrupt Cause Receiver Overrun Count */
764#define E1000_RXCSUM 0x05000 /* RX Checksum Control - RW */ 991#define E1000_RXCSUM 0x05000 /* RX Checksum Control - RW */
992#define E1000_RFCTL 0x05008 /* Receive Filter Control*/
765#define E1000_MTA 0x05200 /* Multicast Table Array - RW Array */ 993#define E1000_MTA 0x05200 /* Multicast Table Array - RW Array */
766#define E1000_RA 0x05400 /* Receive Address - RW Array */ 994#define E1000_RA 0x05400 /* Receive Address - RW Array */
767#define E1000_VFTA 0x05600 /* VLAN Filter Table Array - RW Array */ 995#define E1000_VFTA 0x05600 /* VLAN Filter Table Array - RW Array */
@@ -779,6 +1007,16 @@ struct e1000_ffvt_entry {
779#define E1000_FFMT 0x09000 /* Flexible Filter Mask Table - RW Array */ 1007#define E1000_FFMT 0x09000 /* Flexible Filter Mask Table - RW Array */
780#define E1000_FFVT 0x09800 /* Flexible Filter Value Table - RW Array */ 1008#define E1000_FFVT 0x09800 /* Flexible Filter Value Table - RW Array */
781 1009
1010#define E1000_GCR 0x05B00 /* PCI-Ex Control */
1011#define E1000_GSCL_1 0x05B10 /* PCI-Ex Statistic Control #1 */
1012#define E1000_GSCL_2 0x05B14 /* PCI-Ex Statistic Control #2 */
1013#define E1000_GSCL_3 0x05B18 /* PCI-Ex Statistic Control #3 */
1014#define E1000_GSCL_4 0x05B1C /* PCI-Ex Statistic Control #4 */
1015#define E1000_FACTPS 0x05B30 /* Function Active and Power State to MNG */
1016#define E1000_SWSM 0x05B50 /* SW Semaphore */
1017#define E1000_FWSM 0x05B54 /* FW Semaphore */
1018#define E1000_FFLT_DBG 0x05F04 /* Debug Register */
1019#define E1000_HICR 0x08F00 /* Host Inteface Control */
782/* Register Set (82542) 1020/* Register Set (82542)
783 * 1021 *
784 * Some of the 82542 registers are located at different offsets than they are 1022 * Some of the 82542 registers are located at different offsets than they are
@@ -829,6 +1067,18 @@ struct e1000_ffvt_entry {
829#define E1000_82542_VFTA 0x00600 1067#define E1000_82542_VFTA 0x00600
830#define E1000_82542_LEDCTL E1000_LEDCTL 1068#define E1000_82542_LEDCTL E1000_LEDCTL
831#define E1000_82542_PBA E1000_PBA 1069#define E1000_82542_PBA E1000_PBA
1070#define E1000_82542_PBS E1000_PBS
1071#define E1000_82542_EEMNGCTL E1000_EEMNGCTL
1072#define E1000_82542_EEARBC E1000_EEARBC
1073#define E1000_82542_FLASHT E1000_FLASHT
1074#define E1000_82542_EEWR E1000_EEWR
1075#define E1000_82542_FLSWCTL E1000_FLSWCTL
1076#define E1000_82542_FLSWDATA E1000_FLSWDATA
1077#define E1000_82542_FLSWCNT E1000_FLSWCNT
1078#define E1000_82542_FLOP E1000_FLOP
1079#define E1000_82542_EXTCNF_CTRL E1000_EXTCNF_CTRL
1080#define E1000_82542_EXTCNF_SIZE E1000_EXTCNF_SIZE
1081#define E1000_82542_ERT E1000_ERT
832#define E1000_82542_RXDCTL E1000_RXDCTL 1082#define E1000_82542_RXDCTL E1000_RXDCTL
833#define E1000_82542_RADV E1000_RADV 1083#define E1000_82542_RADV E1000_RADV
834#define E1000_82542_RSRPD E1000_RSRPD 1084#define E1000_82542_RSRPD E1000_RSRPD
@@ -913,6 +1163,38 @@ struct e1000_ffvt_entry {
913#define E1000_82542_FFMT E1000_FFMT 1163#define E1000_82542_FFMT E1000_FFMT
914#define E1000_82542_FFVT E1000_FFVT 1164#define E1000_82542_FFVT E1000_FFVT
915#define E1000_82542_HOST_IF E1000_HOST_IF 1165#define E1000_82542_HOST_IF E1000_HOST_IF
1166#define E1000_82542_IAM E1000_IAM
1167#define E1000_82542_EEMNGCTL E1000_EEMNGCTL
1168#define E1000_82542_PSRCTL E1000_PSRCTL
1169#define E1000_82542_RAID E1000_RAID
1170#define E1000_82542_TARC0 E1000_TARC0
1171#define E1000_82542_TDBAL1 E1000_TDBAL1
1172#define E1000_82542_TDBAH1 E1000_TDBAH1
1173#define E1000_82542_TDLEN1 E1000_TDLEN1
1174#define E1000_82542_TDH1 E1000_TDH1
1175#define E1000_82542_TDT1 E1000_TDT1
1176#define E1000_82542_TXDCTL1 E1000_TXDCTL1
1177#define E1000_82542_TARC1 E1000_TARC1
1178#define E1000_82542_RFCTL E1000_RFCTL
1179#define E1000_82542_GCR E1000_GCR
1180#define E1000_82542_GSCL_1 E1000_GSCL_1
1181#define E1000_82542_GSCL_2 E1000_GSCL_2
1182#define E1000_82542_GSCL_3 E1000_GSCL_3
1183#define E1000_82542_GSCL_4 E1000_GSCL_4
1184#define E1000_82542_FACTPS E1000_FACTPS
1185#define E1000_82542_SWSM E1000_SWSM
1186#define E1000_82542_FWSM E1000_FWSM
1187#define E1000_82542_FFLT_DBG E1000_FFLT_DBG
1188#define E1000_82542_IAC E1000_IAC
1189#define E1000_82542_ICRXPTC E1000_ICRXPTC
1190#define E1000_82542_ICRXATC E1000_ICRXATC
1191#define E1000_82542_ICTXPTC E1000_ICTXPTC
1192#define E1000_82542_ICTXATC E1000_ICTXATC
1193#define E1000_82542_ICTXQEC E1000_ICTXQEC
1194#define E1000_82542_ICTXQMTC E1000_ICTXQMTC
1195#define E1000_82542_ICRXDMTC E1000_ICRXDMTC
1196#define E1000_82542_ICRXOC E1000_ICRXOC
1197#define E1000_82542_HICR E1000_HICR
916 1198
917/* Statistics counters collected by the MAC */ 1199/* Statistics counters collected by the MAC */
918struct e1000_hw_stats { 1200struct e1000_hw_stats {
@@ -974,11 +1256,21 @@ struct e1000_hw_stats {
974 uint64_t bptc; 1256 uint64_t bptc;
975 uint64_t tsctc; 1257 uint64_t tsctc;
976 uint64_t tsctfc; 1258 uint64_t tsctfc;
1259 uint64_t iac;
1260 uint64_t icrxptc;
1261 uint64_t icrxatc;
1262 uint64_t ictxptc;
1263 uint64_t ictxatc;
1264 uint64_t ictxqec;
1265 uint64_t ictxqmtc;
1266 uint64_t icrxdmtc;
1267 uint64_t icrxoc;
977}; 1268};
978 1269
979/* Structure containing variables used by the shared code (e1000_hw.c) */ 1270/* Structure containing variables used by the shared code (e1000_hw.c) */
980struct e1000_hw { 1271struct e1000_hw {
981 uint8_t __iomem *hw_addr; 1272 uint8_t *hw_addr;
1273 uint8_t *flash_address;
982 e1000_mac_type mac_type; 1274 e1000_mac_type mac_type;
983 e1000_phy_type phy_type; 1275 e1000_phy_type phy_type;
984 uint32_t phy_init_script; 1276 uint32_t phy_init_script;
@@ -993,6 +1285,7 @@ struct e1000_hw {
993 e1000_ms_type original_master_slave; 1285 e1000_ms_type original_master_slave;
994 e1000_ffe_config ffe_config_state; 1286 e1000_ffe_config ffe_config_state;
995 uint32_t asf_firmware_present; 1287 uint32_t asf_firmware_present;
1288 uint32_t eeprom_semaphore_present;
996 unsigned long io_base; 1289 unsigned long io_base;
997 uint32_t phy_id; 1290 uint32_t phy_id;
998 uint32_t phy_revision; 1291 uint32_t phy_revision;
@@ -1009,6 +1302,8 @@ struct e1000_hw {
1009 uint32_t ledctl_default; 1302 uint32_t ledctl_default;
1010 uint32_t ledctl_mode1; 1303 uint32_t ledctl_mode1;
1011 uint32_t ledctl_mode2; 1304 uint32_t ledctl_mode2;
1305 boolean_t tx_pkt_filtering;
1306 struct e1000_host_mng_dhcp_cookie mng_cookie;
1012 uint16_t phy_spd_default; 1307 uint16_t phy_spd_default;
1013 uint16_t autoneg_advertised; 1308 uint16_t autoneg_advertised;
1014 uint16_t pci_cmd_word; 1309 uint16_t pci_cmd_word;
@@ -1047,16 +1342,24 @@ struct e1000_hw {
1047 boolean_t adaptive_ifs; 1342 boolean_t adaptive_ifs;
1048 boolean_t ifs_params_forced; 1343 boolean_t ifs_params_forced;
1049 boolean_t in_ifs_mode; 1344 boolean_t in_ifs_mode;
1345 boolean_t mng_reg_access_disabled;
1050}; 1346};
1051 1347
1052 1348
1053#define E1000_EEPROM_SWDPIN0 0x0001 /* SWDPIN 0 EEPROM Value */ 1349#define E1000_EEPROM_SWDPIN0 0x0001 /* SWDPIN 0 EEPROM Value */
1054#define E1000_EEPROM_LED_LOGIC 0x0020 /* Led Logic Word */ 1350#define E1000_EEPROM_LED_LOGIC 0x0020 /* Led Logic Word */
1351#define E1000_EEPROM_RW_REG_DATA 16 /* Offset to data in EEPROM read/write registers */
1352#define E1000_EEPROM_RW_REG_DONE 2 /* Offset to READ/WRITE done bit */
1353#define E1000_EEPROM_RW_REG_START 1 /* First bit for telling part to start operation */
1354#define E1000_EEPROM_RW_ADDR_SHIFT 2 /* Shift to the address bits */
1355#define E1000_EEPROM_POLL_WRITE 1 /* Flag for polling for write complete */
1356#define E1000_EEPROM_POLL_READ 0 /* Flag for polling for read complete */
1055/* Register Bit Masks */ 1357/* Register Bit Masks */
1056/* Device Control */ 1358/* Device Control */
1057#define E1000_CTRL_FD 0x00000001 /* Full duplex.0=half; 1=full */ 1359#define E1000_CTRL_FD 0x00000001 /* Full duplex.0=half; 1=full */
1058#define E1000_CTRL_BEM 0x00000002 /* Endian Mode.0=little,1=big */ 1360#define E1000_CTRL_BEM 0x00000002 /* Endian Mode.0=little,1=big */
1059#define E1000_CTRL_PRIOR 0x00000004 /* Priority on PCI. 0=rx,1=fair */ 1361#define E1000_CTRL_PRIOR 0x00000004 /* Priority on PCI. 0=rx,1=fair */
1362#define E1000_CTRL_GIO_MASTER_DISABLE 0x00000004 /*Blocks new Master requests */
1060#define E1000_CTRL_LRST 0x00000008 /* Link reset. 0=normal,1=reset */ 1363#define E1000_CTRL_LRST 0x00000008 /* Link reset. 0=normal,1=reset */
1061#define E1000_CTRL_TME 0x00000010 /* Test mode. 0=normal,1=test */ 1364#define E1000_CTRL_TME 0x00000010 /* Test mode. 0=normal,1=test */
1062#define E1000_CTRL_SLE 0x00000020 /* Serial Link on 0=dis,1=en */ 1365#define E1000_CTRL_SLE 0x00000020 /* Serial Link on 0=dis,1=en */
@@ -1070,6 +1373,7 @@ struct e1000_hw {
1070#define E1000_CTRL_BEM32 0x00000400 /* Big Endian 32 mode */ 1373#define E1000_CTRL_BEM32 0x00000400 /* Big Endian 32 mode */
1071#define E1000_CTRL_FRCSPD 0x00000800 /* Force Speed */ 1374#define E1000_CTRL_FRCSPD 0x00000800 /* Force Speed */
1072#define E1000_CTRL_FRCDPX 0x00001000 /* Force Duplex */ 1375#define E1000_CTRL_FRCDPX 0x00001000 /* Force Duplex */
1376#define E1000_CTRL_D_UD_POLARITY 0x00004000 /* Defined polarity of Dock/Undock indication in SDP[0] */
1073#define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */ 1377#define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */
1074#define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */ 1378#define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */
1075#define E1000_CTRL_SWDPIN2 0x00100000 /* SWDPIN 2 value */ 1379#define E1000_CTRL_SWDPIN2 0x00100000 /* SWDPIN 2 value */
@@ -1089,6 +1393,7 @@ struct e1000_hw {
1089#define E1000_STATUS_FD 0x00000001 /* Full duplex.0=half,1=full */ 1393#define E1000_STATUS_FD 0x00000001 /* Full duplex.0=half,1=full */
1090#define E1000_STATUS_LU 0x00000002 /* Link up.0=no,1=link */ 1394#define E1000_STATUS_LU 0x00000002 /* Link up.0=no,1=link */
1091#define E1000_STATUS_FUNC_MASK 0x0000000C /* PCI Function Mask */ 1395#define E1000_STATUS_FUNC_MASK 0x0000000C /* PCI Function Mask */
1396#define E1000_STATUS_FUNC_SHIFT 2
1092#define E1000_STATUS_FUNC_0 0x00000000 /* Function 0 */ 1397#define E1000_STATUS_FUNC_0 0x00000000 /* Function 0 */
1093#define E1000_STATUS_FUNC_1 0x00000004 /* Function 1 */ 1398#define E1000_STATUS_FUNC_1 0x00000004 /* Function 1 */
1094#define E1000_STATUS_TXOFF 0x00000010 /* transmission paused */ 1399#define E1000_STATUS_TXOFF 0x00000010 /* transmission paused */
@@ -1098,6 +1403,8 @@ struct e1000_hw {
1098#define E1000_STATUS_SPEED_100 0x00000040 /* Speed 100Mb/s */ 1403#define E1000_STATUS_SPEED_100 0x00000040 /* Speed 100Mb/s */
1099#define E1000_STATUS_SPEED_1000 0x00000080 /* Speed 1000Mb/s */ 1404#define E1000_STATUS_SPEED_1000 0x00000080 /* Speed 1000Mb/s */
1100#define E1000_STATUS_ASDV 0x00000300 /* Auto speed detect value */ 1405#define E1000_STATUS_ASDV 0x00000300 /* Auto speed detect value */
1406#define E1000_STATUS_DOCK_CI 0x00000800 /* Change in Dock/Undock state. Clear on write '0'. */
1407#define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000 /* Status of Master requests. */
1101#define E1000_STATUS_MTXCKOK 0x00000400 /* MTX clock running OK */ 1408#define E1000_STATUS_MTXCKOK 0x00000400 /* MTX clock running OK */
1102#define E1000_STATUS_PCI66 0x00000800 /* In 66Mhz slot */ 1409#define E1000_STATUS_PCI66 0x00000800 /* In 66Mhz slot */
1103#define E1000_STATUS_BUS64 0x00001000 /* In 64 bit slot */ 1410#define E1000_STATUS_BUS64 0x00001000 /* In 64 bit slot */
@@ -1128,6 +1435,18 @@ struct e1000_hw {
1128#ifndef E1000_EEPROM_GRANT_ATTEMPTS 1435#ifndef E1000_EEPROM_GRANT_ATTEMPTS
1129#define E1000_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM # attempts to gain grant */ 1436#define E1000_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM # attempts to gain grant */
1130#endif 1437#endif
1438#define E1000_EECD_AUTO_RD 0x00000200 /* EEPROM Auto Read done */
1439#define E1000_EECD_SIZE_EX_MASK 0x00007800 /* EEprom Size */
1440#define E1000_EECD_SIZE_EX_SHIFT 11
1441#define E1000_EECD_NVADDS 0x00018000 /* NVM Address Size */
1442#define E1000_EECD_SELSHAD 0x00020000 /* Select Shadow RAM */
1443#define E1000_EECD_INITSRAM 0x00040000 /* Initialize Shadow RAM */
1444#define E1000_EECD_FLUPD 0x00080000 /* Update FLASH */
1445#define E1000_EECD_AUPDEN 0x00100000 /* Enable Autonomous FLASH update */
1446#define E1000_EECD_SHADV 0x00200000 /* Shadow RAM Data Valid */
1447#define E1000_EECD_SEC1VAL 0x00400000 /* Sector One Valid */
1448#define E1000_STM_OPCODE 0xDB00
1449#define E1000_HICR_FW_RESET 0xC0
1131 1450
1132/* EEPROM Read */ 1451/* EEPROM Read */
1133#define E1000_EERD_START 0x00000001 /* Start Read */ 1452#define E1000_EERD_START 0x00000001 /* Start Read */
@@ -1171,6 +1490,8 @@ struct e1000_hw {
1171#define E1000_CTRL_EXT_WR_WMARK_320 0x01000000 1490#define E1000_CTRL_EXT_WR_WMARK_320 0x01000000
1172#define E1000_CTRL_EXT_WR_WMARK_384 0x02000000 1491#define E1000_CTRL_EXT_WR_WMARK_384 0x02000000
1173#define E1000_CTRL_EXT_WR_WMARK_448 0x03000000 1492#define E1000_CTRL_EXT_WR_WMARK_448 0x03000000
1493#define E1000_CTRL_EXT_IAME 0x08000000 /* Interrupt acknowledge Auto-mask */
1494#define E1000_CTRL_EXT_INT_TIMER_CLR 0x20000000 /* Clear Interrupt timers after IMS clear */
1174 1495
1175/* MDI Control */ 1496/* MDI Control */
1176#define E1000_MDIC_DATA_MASK 0x0000FFFF 1497#define E1000_MDIC_DATA_MASK 0x0000FFFF
@@ -1187,14 +1508,17 @@ struct e1000_hw {
1187/* LED Control */ 1508/* LED Control */
1188#define E1000_LEDCTL_LED0_MODE_MASK 0x0000000F 1509#define E1000_LEDCTL_LED0_MODE_MASK 0x0000000F
1189#define E1000_LEDCTL_LED0_MODE_SHIFT 0 1510#define E1000_LEDCTL_LED0_MODE_SHIFT 0
1511#define E1000_LEDCTL_LED0_BLINK_RATE 0x0000020
1190#define E1000_LEDCTL_LED0_IVRT 0x00000040 1512#define E1000_LEDCTL_LED0_IVRT 0x00000040
1191#define E1000_LEDCTL_LED0_BLINK 0x00000080 1513#define E1000_LEDCTL_LED0_BLINK 0x00000080
1192#define E1000_LEDCTL_LED1_MODE_MASK 0x00000F00 1514#define E1000_LEDCTL_LED1_MODE_MASK 0x00000F00
1193#define E1000_LEDCTL_LED1_MODE_SHIFT 8 1515#define E1000_LEDCTL_LED1_MODE_SHIFT 8
1516#define E1000_LEDCTL_LED1_BLINK_RATE 0x0002000
1194#define E1000_LEDCTL_LED1_IVRT 0x00004000 1517#define E1000_LEDCTL_LED1_IVRT 0x00004000
1195#define E1000_LEDCTL_LED1_BLINK 0x00008000 1518#define E1000_LEDCTL_LED1_BLINK 0x00008000
1196#define E1000_LEDCTL_LED2_MODE_MASK 0x000F0000 1519#define E1000_LEDCTL_LED2_MODE_MASK 0x000F0000
1197#define E1000_LEDCTL_LED2_MODE_SHIFT 16 1520#define E1000_LEDCTL_LED2_MODE_SHIFT 16
1521#define E1000_LEDCTL_LED2_BLINK_RATE 0x00200000
1198#define E1000_LEDCTL_LED2_IVRT 0x00400000 1522#define E1000_LEDCTL_LED2_IVRT 0x00400000
1199#define E1000_LEDCTL_LED2_BLINK 0x00800000 1523#define E1000_LEDCTL_LED2_BLINK 0x00800000
1200#define E1000_LEDCTL_LED3_MODE_MASK 0x0F000000 1524#define E1000_LEDCTL_LED3_MODE_MASK 0x0F000000
@@ -1238,6 +1562,10 @@ struct e1000_hw {
1238#define E1000_ICR_GPI_EN3 0x00004000 /* GP Int 3 */ 1562#define E1000_ICR_GPI_EN3 0x00004000 /* GP Int 3 */
1239#define E1000_ICR_TXD_LOW 0x00008000 1563#define E1000_ICR_TXD_LOW 0x00008000
1240#define E1000_ICR_SRPD 0x00010000 1564#define E1000_ICR_SRPD 0x00010000
1565#define E1000_ICR_ACK 0x00020000 /* Receive Ack frame */
1566#define E1000_ICR_MNG 0x00040000 /* Manageability event */
1567#define E1000_ICR_DOCK 0x00080000 /* Dock/Undock */
1568#define E1000_ICR_INT_ASSERTED 0x80000000 /* If this bit asserted, the driver should claim the interrupt */
1241 1569
1242/* Interrupt Cause Set */ 1570/* Interrupt Cause Set */
1243#define E1000_ICS_TXDW E1000_ICR_TXDW /* Transmit desc written back */ 1571#define E1000_ICS_TXDW E1000_ICR_TXDW /* Transmit desc written back */
@@ -1255,6 +1583,9 @@ struct e1000_hw {
1255#define E1000_ICS_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */ 1583#define E1000_ICS_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */
1256#define E1000_ICS_TXD_LOW E1000_ICR_TXD_LOW 1584#define E1000_ICS_TXD_LOW E1000_ICR_TXD_LOW
1257#define E1000_ICS_SRPD E1000_ICR_SRPD 1585#define E1000_ICS_SRPD E1000_ICR_SRPD
1586#define E1000_ICS_ACK E1000_ICR_ACK /* Receive Ack frame */
1587#define E1000_ICS_MNG E1000_ICR_MNG /* Manageability event */
1588#define E1000_ICS_DOCK E1000_ICR_DOCK /* Dock/Undock */
1258 1589
1259/* Interrupt Mask Set */ 1590/* Interrupt Mask Set */
1260#define E1000_IMS_TXDW E1000_ICR_TXDW /* Transmit desc written back */ 1591#define E1000_IMS_TXDW E1000_ICR_TXDW /* Transmit desc written back */
@@ -1272,6 +1603,9 @@ struct e1000_hw {
1272#define E1000_IMS_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */ 1603#define E1000_IMS_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */
1273#define E1000_IMS_TXD_LOW E1000_ICR_TXD_LOW 1604#define E1000_IMS_TXD_LOW E1000_ICR_TXD_LOW
1274#define E1000_IMS_SRPD E1000_ICR_SRPD 1605#define E1000_IMS_SRPD E1000_ICR_SRPD
1606#define E1000_IMS_ACK E1000_ICR_ACK /* Receive Ack frame */
1607#define E1000_IMS_MNG E1000_ICR_MNG /* Manageability event */
1608#define E1000_IMS_DOCK E1000_ICR_DOCK /* Dock/Undock */
1275 1609
1276/* Interrupt Mask Clear */ 1610/* Interrupt Mask Clear */
1277#define E1000_IMC_TXDW E1000_ICR_TXDW /* Transmit desc written back */ 1611#define E1000_IMC_TXDW E1000_ICR_TXDW /* Transmit desc written back */
@@ -1289,6 +1623,9 @@ struct e1000_hw {
1289#define E1000_IMC_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */ 1623#define E1000_IMC_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */
1290#define E1000_IMC_TXD_LOW E1000_ICR_TXD_LOW 1624#define E1000_IMC_TXD_LOW E1000_ICR_TXD_LOW
1291#define E1000_IMC_SRPD E1000_ICR_SRPD 1625#define E1000_IMC_SRPD E1000_ICR_SRPD
1626#define E1000_IMC_ACK E1000_ICR_ACK /* Receive Ack frame */
1627#define E1000_IMC_MNG E1000_ICR_MNG /* Manageability event */
1628#define E1000_IMC_DOCK E1000_ICR_DOCK /* Dock/Undock */
1292 1629
1293/* Receive Control */ 1630/* Receive Control */
1294#define E1000_RCTL_RST 0x00000001 /* Software reset */ 1631#define E1000_RCTL_RST 0x00000001 /* Software reset */
@@ -1301,6 +1638,8 @@ struct e1000_hw {
1301#define E1000_RCTL_LBM_MAC 0x00000040 /* MAC loopback mode */ 1638#define E1000_RCTL_LBM_MAC 0x00000040 /* MAC loopback mode */
1302#define E1000_RCTL_LBM_SLP 0x00000080 /* serial link loopback mode */ 1639#define E1000_RCTL_LBM_SLP 0x00000080 /* serial link loopback mode */
1303#define E1000_RCTL_LBM_TCVR 0x000000C0 /* tcvr loopback mode */ 1640#define E1000_RCTL_LBM_TCVR 0x000000C0 /* tcvr loopback mode */
1641#define E1000_RCTL_DTYP_MASK 0x00000C00 /* Descriptor type mask */
1642#define E1000_RCTL_DTYP_PS 0x00000400 /* Packet Split descriptor */
1304#define E1000_RCTL_RDMTS_HALF 0x00000000 /* rx desc min threshold size */ 1643#define E1000_RCTL_RDMTS_HALF 0x00000000 /* rx desc min threshold size */
1305#define E1000_RCTL_RDMTS_QUAT 0x00000100 /* rx desc min threshold size */ 1644#define E1000_RCTL_RDMTS_QUAT 0x00000100 /* rx desc min threshold size */
1306#define E1000_RCTL_RDMTS_EIGTH 0x00000200 /* rx desc min threshold size */ 1645#define E1000_RCTL_RDMTS_EIGTH 0x00000200 /* rx desc min threshold size */
@@ -1327,6 +1666,34 @@ struct e1000_hw {
1327#define E1000_RCTL_PMCF 0x00800000 /* pass MAC control frames */ 1666#define E1000_RCTL_PMCF 0x00800000 /* pass MAC control frames */
1328#define E1000_RCTL_BSEX 0x02000000 /* Buffer size extension */ 1667#define E1000_RCTL_BSEX 0x02000000 /* Buffer size extension */
1329#define E1000_RCTL_SECRC 0x04000000 /* Strip Ethernet CRC */ 1668#define E1000_RCTL_SECRC 0x04000000 /* Strip Ethernet CRC */
1669#define E1000_RCTL_FLXBUF_MASK 0x78000000 /* Flexible buffer size */
1670#define E1000_RCTL_FLXBUF_SHIFT 27 /* Flexible buffer shift */
1671
1672/* Use byte values for the following shift parameters
1673 * Usage:
1674 * psrctl |= (((ROUNDUP(value0, 128) >> E1000_PSRCTL_BSIZE0_SHIFT) &
1675 * E1000_PSRCTL_BSIZE0_MASK) |
1676 * ((ROUNDUP(value1, 1024) >> E1000_PSRCTL_BSIZE1_SHIFT) &
1677 * E1000_PSRCTL_BSIZE1_MASK) |
1678 * ((ROUNDUP(value2, 1024) << E1000_PSRCTL_BSIZE2_SHIFT) &
1679 * E1000_PSRCTL_BSIZE2_MASK) |
1680 * ((ROUNDUP(value3, 1024) << E1000_PSRCTL_BSIZE3_SHIFT) |;
1681 * E1000_PSRCTL_BSIZE3_MASK))
1682 * where value0 = [128..16256], default=256
1683 * value1 = [1024..64512], default=4096
1684 * value2 = [0..64512], default=4096
1685 * value3 = [0..64512], default=0
1686 */
1687
1688#define E1000_PSRCTL_BSIZE0_MASK 0x0000007F
1689#define E1000_PSRCTL_BSIZE1_MASK 0x00003F00
1690#define E1000_PSRCTL_BSIZE2_MASK 0x003F0000
1691#define E1000_PSRCTL_BSIZE3_MASK 0x3F000000
1692
1693#define E1000_PSRCTL_BSIZE0_SHIFT 7 /* Shift _right_ 7 */
1694#define E1000_PSRCTL_BSIZE1_SHIFT 2 /* Shift _right_ 2 */
1695#define E1000_PSRCTL_BSIZE2_SHIFT 6 /* Shift _left_ 6 */
1696#define E1000_PSRCTL_BSIZE3_SHIFT 14 /* Shift _left_ 14 */
1330 1697
1331/* Receive Descriptor */ 1698/* Receive Descriptor */
1332#define E1000_RDT_DELAY 0x0000ffff /* Delay timer (1=1024us) */ 1699#define E1000_RDT_DELAY 0x0000ffff /* Delay timer (1=1024us) */
@@ -1341,6 +1708,23 @@ struct e1000_hw {
1341#define E1000_FCRTL_RTL 0x0000FFF8 /* Mask Bits[15:3] for RTL */ 1708#define E1000_FCRTL_RTL 0x0000FFF8 /* Mask Bits[15:3] for RTL */
1342#define E1000_FCRTL_XONE 0x80000000 /* Enable XON frame transmission */ 1709#define E1000_FCRTL_XONE 0x80000000 /* Enable XON frame transmission */
1343 1710
1711/* Header split receive */
1712#define E1000_RFCTL_ISCSI_DIS 0x00000001
1713#define E1000_RFCTL_ISCSI_DWC_MASK 0x0000003E
1714#define E1000_RFCTL_ISCSI_DWC_SHIFT 1
1715#define E1000_RFCTL_NFSW_DIS 0x00000040
1716#define E1000_RFCTL_NFSR_DIS 0x00000080
1717#define E1000_RFCTL_NFS_VER_MASK 0x00000300
1718#define E1000_RFCTL_NFS_VER_SHIFT 8
1719#define E1000_RFCTL_IPV6_DIS 0x00000400
1720#define E1000_RFCTL_IPV6_XSUM_DIS 0x00000800
1721#define E1000_RFCTL_ACK_DIS 0x00001000
1722#define E1000_RFCTL_ACKD_DIS 0x00002000
1723#define E1000_RFCTL_IPFRSP_DIS 0x00004000
1724#define E1000_RFCTL_EXTEN 0x00008000
1725#define E1000_RFCTL_IPV6_EX_DIS 0x00010000
1726#define E1000_RFCTL_NEW_IPV6_EXT_DIS 0x00020000
1727
1344/* Receive Descriptor Control */ 1728/* Receive Descriptor Control */
1345#define E1000_RXDCTL_PTHRESH 0x0000003F /* RXDCTL Prefetch Threshold */ 1729#define E1000_RXDCTL_PTHRESH 0x0000003F /* RXDCTL Prefetch Threshold */
1346#define E1000_RXDCTL_HTHRESH 0x00003F00 /* RXDCTL Host Threshold */ 1730#define E1000_RXDCTL_HTHRESH 0x00003F00 /* RXDCTL Host Threshold */
@@ -1354,6 +1738,8 @@ struct e1000_hw {
1354#define E1000_TXDCTL_GRAN 0x01000000 /* TXDCTL Granularity */ 1738#define E1000_TXDCTL_GRAN 0x01000000 /* TXDCTL Granularity */
1355#define E1000_TXDCTL_LWTHRESH 0xFE000000 /* TXDCTL Low Threshold */ 1739#define E1000_TXDCTL_LWTHRESH 0xFE000000 /* TXDCTL Low Threshold */
1356#define E1000_TXDCTL_FULL_TX_DESC_WB 0x01010000 /* GRAN=1, WTHRESH=1 */ 1740#define E1000_TXDCTL_FULL_TX_DESC_WB 0x01010000 /* GRAN=1, WTHRESH=1 */
1741#define E1000_TXDCTL_COUNT_DESC 0x00400000 /* Enable the counting of desc.
1742 still to be processed. */
1357 1743
1358/* Transmit Configuration Word */ 1744/* Transmit Configuration Word */
1359#define E1000_TXCW_FD 0x00000020 /* TXCW full duplex */ 1745#define E1000_TXCW_FD 0x00000020 /* TXCW full duplex */
@@ -1387,12 +1773,16 @@ struct e1000_hw {
1387#define E1000_TCTL_PBE 0x00800000 /* Packet Burst Enable */ 1773#define E1000_TCTL_PBE 0x00800000 /* Packet Burst Enable */
1388#define E1000_TCTL_RTLC 0x01000000 /* Re-transmit on late collision */ 1774#define E1000_TCTL_RTLC 0x01000000 /* Re-transmit on late collision */
1389#define E1000_TCTL_NRTU 0x02000000 /* No Re-transmit on underrun */ 1775#define E1000_TCTL_NRTU 0x02000000 /* No Re-transmit on underrun */
1776#define E1000_TCTL_MULR 0x10000000 /* Multiple request support */
1390 1777
1391/* Receive Checksum Control */ 1778/* Receive Checksum Control */
1392#define E1000_RXCSUM_PCSS_MASK 0x000000FF /* Packet Checksum Start */ 1779#define E1000_RXCSUM_PCSS_MASK 0x000000FF /* Packet Checksum Start */
1393#define E1000_RXCSUM_IPOFL 0x00000100 /* IPv4 checksum offload */ 1780#define E1000_RXCSUM_IPOFL 0x00000100 /* IPv4 checksum offload */
1394#define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */ 1781#define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */
1395#define E1000_RXCSUM_IPV6OFL 0x00000400 /* IPv6 checksum offload */ 1782#define E1000_RXCSUM_IPV6OFL 0x00000400 /* IPv6 checksum offload */
1783#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */
1784#define E1000_RXCSUM_PCSD 0x00002000 /* packet checksum disabled */
1785
1396 1786
1397/* Definitions for power management and wakeup registers */ 1787/* Definitions for power management and wakeup registers */
1398/* Wake Up Control */ 1788/* Wake Up Control */
@@ -1411,6 +1801,7 @@ struct e1000_hw {
1411#define E1000_WUFC_ARP 0x00000020 /* ARP Request Packet Wakeup Enable */ 1801#define E1000_WUFC_ARP 0x00000020 /* ARP Request Packet Wakeup Enable */
1412#define E1000_WUFC_IPV4 0x00000040 /* Directed IPv4 Packet Wakeup Enable */ 1802#define E1000_WUFC_IPV4 0x00000040 /* Directed IPv4 Packet Wakeup Enable */
1413#define E1000_WUFC_IPV6 0x00000080 /* Directed IPv6 Packet Wakeup Enable */ 1803#define E1000_WUFC_IPV6 0x00000080 /* Directed IPv6 Packet Wakeup Enable */
1804#define E1000_WUFC_IGNORE_TCO 0x00008000 /* Ignore WakeOn TCO packets */
1414#define E1000_WUFC_FLX0 0x00010000 /* Flexible Filter 0 Enable */ 1805#define E1000_WUFC_FLX0 0x00010000 /* Flexible Filter 0 Enable */
1415#define E1000_WUFC_FLX1 0x00020000 /* Flexible Filter 1 Enable */ 1806#define E1000_WUFC_FLX1 0x00020000 /* Flexible Filter 1 Enable */
1416#define E1000_WUFC_FLX2 0x00040000 /* Flexible Filter 2 Enable */ 1807#define E1000_WUFC_FLX2 0x00040000 /* Flexible Filter 2 Enable */
@@ -1446,13 +1837,19 @@ struct e1000_hw {
1446#define E1000_MANC_ARP_EN 0x00002000 /* Enable ARP Request Filtering */ 1837#define E1000_MANC_ARP_EN 0x00002000 /* Enable ARP Request Filtering */
1447#define E1000_MANC_NEIGHBOR_EN 0x00004000 /* Enable Neighbor Discovery 1838#define E1000_MANC_NEIGHBOR_EN 0x00004000 /* Enable Neighbor Discovery
1448 * Filtering */ 1839 * Filtering */
1840#define E1000_MANC_ARP_RES_EN 0x00008000 /* Enable ARP response Filtering */
1449#define E1000_MANC_TCO_RESET 0x00010000 /* TCO Reset Occurred */ 1841#define E1000_MANC_TCO_RESET 0x00010000 /* TCO Reset Occurred */
1450#define E1000_MANC_RCV_TCO_EN 0x00020000 /* Receive TCO Packets Enabled */ 1842#define E1000_MANC_RCV_TCO_EN 0x00020000 /* Receive TCO Packets Enabled */
1451#define E1000_MANC_REPORT_STATUS 0x00040000 /* Status Reporting Enabled */ 1843#define E1000_MANC_REPORT_STATUS 0x00040000 /* Status Reporting Enabled */
1844#define E1000_MANC_BLK_PHY_RST_ON_IDE 0x00040000 /* Block phy resets */
1452#define E1000_MANC_EN_MAC_ADDR_FILTER 0x00100000 /* Enable MAC address 1845#define E1000_MANC_EN_MAC_ADDR_FILTER 0x00100000 /* Enable MAC address
1453 * filtering */ 1846 * filtering */
1454#define E1000_MANC_EN_MNG2HOST 0x00200000 /* Enable MNG packets to host 1847#define E1000_MANC_EN_MNG2HOST 0x00200000 /* Enable MNG packets to host
1455 * memory */ 1848 * memory */
1849#define E1000_MANC_EN_IP_ADDR_FILTER 0x00400000 /* Enable IP address
1850 * filtering */
1851#define E1000_MANC_EN_XSUM_FILTER 0x00800000 /* Enable checksum filtering */
1852#define E1000_MANC_BR_EN 0x01000000 /* Enable broadcast filtering */
1456#define E1000_MANC_SMB_REQ 0x01000000 /* SMBus Request */ 1853#define E1000_MANC_SMB_REQ 0x01000000 /* SMBus Request */
1457#define E1000_MANC_SMB_GNT 0x02000000 /* SMBus Grant */ 1854#define E1000_MANC_SMB_GNT 0x02000000 /* SMBus Grant */
1458#define E1000_MANC_SMB_CLK_IN 0x04000000 /* SMBus Clock In */ 1855#define E1000_MANC_SMB_CLK_IN 0x04000000 /* SMBus Clock In */
@@ -1463,11 +1860,97 @@ struct e1000_hw {
1463#define E1000_MANC_SMB_DATA_OUT_SHIFT 28 /* SMBus Data Out Shift */ 1860#define E1000_MANC_SMB_DATA_OUT_SHIFT 28 /* SMBus Data Out Shift */
1464#define E1000_MANC_SMB_CLK_OUT_SHIFT 29 /* SMBus Clock Out Shift */ 1861#define E1000_MANC_SMB_CLK_OUT_SHIFT 29 /* SMBus Clock Out Shift */
1465 1862
1863/* SW Semaphore Register */
1864#define E1000_SWSM_SMBI 0x00000001 /* Driver Semaphore bit */
1865#define E1000_SWSM_SWESMBI 0x00000002 /* FW Semaphore bit */
1866#define E1000_SWSM_WMNG 0x00000004 /* Wake MNG Clock */
1867#define E1000_SWSM_DRV_LOAD 0x00000008 /* Driver Loaded Bit */
1868
1869/* FW Semaphore Register */
1870#define E1000_FWSM_MODE_MASK 0x0000000E /* FW mode */
1871#define E1000_FWSM_MODE_SHIFT 1
1872#define E1000_FWSM_FW_VALID 0x00008000 /* FW established a valid mode */
1873
1874/* FFLT Debug Register */
1875#define E1000_FFLT_DBG_INVC 0x00100000 /* Invalid /C/ code handling */
1876
1877typedef enum {
1878 e1000_mng_mode_none = 0,
1879 e1000_mng_mode_asf,
1880 e1000_mng_mode_pt,
1881 e1000_mng_mode_ipmi,
1882 e1000_mng_mode_host_interface_only
1883} e1000_mng_mode;
1884
1885/* Host Inteface Control Register */
1886#define E1000_HICR_EN 0x00000001 /* Enable Bit - RO */
1887#define E1000_HICR_C 0x00000002 /* Driver sets this bit when done
1888 * to put command in RAM */
1889#define E1000_HICR_SV 0x00000004 /* Status Validity */
1890#define E1000_HICR_FWR 0x00000080 /* FW reset. Set by the Host */
1891
1892/* Host Interface Command Interface - Address range 0x8800-0x8EFF */
1893#define E1000_HI_MAX_DATA_LENGTH 252 /* Host Interface data length */
1894#define E1000_HI_MAX_BLOCK_BYTE_LENGTH 1792 /* Number of bytes in range */
1895#define E1000_HI_MAX_BLOCK_DWORD_LENGTH 448 /* Number of dwords in range */
1896#define E1000_HI_COMMAND_TIMEOUT 500 /* Time in ms to process HI command */
1897
1898struct e1000_host_command_header {
1899 uint8_t command_id;
1900 uint8_t command_length;
1901 uint8_t command_options; /* I/F bits for command, status for return */
1902 uint8_t checksum;
1903};
1904struct e1000_host_command_info {
1905 struct e1000_host_command_header command_header; /* Command Head/Command Result Head has 4 bytes */
1906 uint8_t command_data[E1000_HI_MAX_DATA_LENGTH]; /* Command data can length 0..252 */
1907};
1908
1909/* Host SMB register #0 */
1910#define E1000_HSMC0R_CLKIN 0x00000001 /* SMB Clock in */
1911#define E1000_HSMC0R_DATAIN 0x00000002 /* SMB Data in */
1912#define E1000_HSMC0R_DATAOUT 0x00000004 /* SMB Data out */
1913#define E1000_HSMC0R_CLKOUT 0x00000008 /* SMB Clock out */
1914
1915/* Host SMB register #1 */
1916#define E1000_HSMC1R_CLKIN E1000_HSMC0R_CLKIN
1917#define E1000_HSMC1R_DATAIN E1000_HSMC0R_DATAIN
1918#define E1000_HSMC1R_DATAOUT E1000_HSMC0R_DATAOUT
1919#define E1000_HSMC1R_CLKOUT E1000_HSMC0R_CLKOUT
1920
1921/* FW Status Register */
1922#define E1000_FWSTS_FWS_MASK 0x000000FF /* FW Status */
1923
1466/* Wake Up Packet Length */ 1924/* Wake Up Packet Length */
1467#define E1000_WUPL_LENGTH_MASK 0x0FFF /* Only the lower 12 bits are valid */ 1925#define E1000_WUPL_LENGTH_MASK 0x0FFF /* Only the lower 12 bits are valid */
1468 1926
1469#define E1000_MDALIGN 4096 1927#define E1000_MDALIGN 4096
1470 1928
1929#define E1000_GCR_BEM32 0x00400000
1930/* Function Active and Power State to MNG */
1931#define E1000_FACTPS_FUNC0_POWER_STATE_MASK 0x00000003
1932#define E1000_FACTPS_LAN0_VALID 0x00000004
1933#define E1000_FACTPS_FUNC0_AUX_EN 0x00000008
1934#define E1000_FACTPS_FUNC1_POWER_STATE_MASK 0x000000C0
1935#define E1000_FACTPS_FUNC1_POWER_STATE_SHIFT 6
1936#define E1000_FACTPS_LAN1_VALID 0x00000100
1937#define E1000_FACTPS_FUNC1_AUX_EN 0x00000200
1938#define E1000_FACTPS_FUNC2_POWER_STATE_MASK 0x00003000
1939#define E1000_FACTPS_FUNC2_POWER_STATE_SHIFT 12
1940#define E1000_FACTPS_IDE_ENABLE 0x00004000
1941#define E1000_FACTPS_FUNC2_AUX_EN 0x00008000
1942#define E1000_FACTPS_FUNC3_POWER_STATE_MASK 0x000C0000
1943#define E1000_FACTPS_FUNC3_POWER_STATE_SHIFT 18
1944#define E1000_FACTPS_SP_ENABLE 0x00100000
1945#define E1000_FACTPS_FUNC3_AUX_EN 0x00200000
1946#define E1000_FACTPS_FUNC4_POWER_STATE_MASK 0x03000000
1947#define E1000_FACTPS_FUNC4_POWER_STATE_SHIFT 24
1948#define E1000_FACTPS_IPMI_ENABLE 0x04000000
1949#define E1000_FACTPS_FUNC4_AUX_EN 0x08000000
1950#define E1000_FACTPS_MNGCG 0x20000000
1951#define E1000_FACTPS_LAN_FUNC_SEL 0x40000000
1952#define E1000_FACTPS_PM_STATE_CHANGED 0x80000000
1953
1471/* EEPROM Commands - Microwire */ 1954/* EEPROM Commands - Microwire */
1472#define EEPROM_READ_OPCODE_MICROWIRE 0x6 /* EEPROM read opcode */ 1955#define EEPROM_READ_OPCODE_MICROWIRE 0x6 /* EEPROM read opcode */
1473#define EEPROM_WRITE_OPCODE_MICROWIRE 0x5 /* EEPROM write opcode */ 1956#define EEPROM_WRITE_OPCODE_MICROWIRE 0x5 /* EEPROM write opcode */
@@ -1477,22 +1960,20 @@ struct e1000_hw {
1477 1960
1478/* EEPROM Commands - SPI */ 1961/* EEPROM Commands - SPI */
1479#define EEPROM_MAX_RETRY_SPI 5000 /* Max wait of 5ms, for RDY signal */ 1962#define EEPROM_MAX_RETRY_SPI 5000 /* Max wait of 5ms, for RDY signal */
1480#define EEPROM_READ_OPCODE_SPI 0x3 /* EEPROM read opcode */ 1963#define EEPROM_READ_OPCODE_SPI 0x03 /* EEPROM read opcode */
1481#define EEPROM_WRITE_OPCODE_SPI 0x2 /* EEPROM write opcode */ 1964#define EEPROM_WRITE_OPCODE_SPI 0x02 /* EEPROM write opcode */
1482#define EEPROM_A8_OPCODE_SPI 0x8 /* opcode bit-3 = address bit-8 */ 1965#define EEPROM_A8_OPCODE_SPI 0x08 /* opcode bit-3 = address bit-8 */
1483#define EEPROM_WREN_OPCODE_SPI 0x6 /* EEPROM set Write Enable latch */ 1966#define EEPROM_WREN_OPCODE_SPI 0x06 /* EEPROM set Write Enable latch */
1484#define EEPROM_WRDI_OPCODE_SPI 0x4 /* EEPROM reset Write Enable latch */ 1967#define EEPROM_WRDI_OPCODE_SPI 0x04 /* EEPROM reset Write Enable latch */
1485#define EEPROM_RDSR_OPCODE_SPI 0x5 /* EEPROM read Status register */ 1968#define EEPROM_RDSR_OPCODE_SPI 0x05 /* EEPROM read Status register */
1486#define EEPROM_WRSR_OPCODE_SPI 0x1 /* EEPROM write Status register */ 1969#define EEPROM_WRSR_OPCODE_SPI 0x01 /* EEPROM write Status register */
1970#define EEPROM_ERASE4K_OPCODE_SPI 0x20 /* EEPROM ERASE 4KB */
1971#define EEPROM_ERASE64K_OPCODE_SPI 0xD8 /* EEPROM ERASE 64KB */
1972#define EEPROM_ERASE256_OPCODE_SPI 0xDB /* EEPROM ERASE 256B */
1487 1973
1488/* EEPROM Size definitions */ 1974/* EEPROM Size definitions */
1489#define EEPROM_SIZE_16KB 0x1800 1975#define EEPROM_WORD_SIZE_SHIFT 6
1490#define EEPROM_SIZE_8KB 0x1400 1976#define EEPROM_SIZE_SHIFT 10
1491#define EEPROM_SIZE_4KB 0x1000
1492#define EEPROM_SIZE_2KB 0x0C00
1493#define EEPROM_SIZE_1KB 0x0800
1494#define EEPROM_SIZE_512B 0x0400
1495#define EEPROM_SIZE_128B 0x0000
1496#define EEPROM_SIZE_MASK 0x1C00 1977#define EEPROM_SIZE_MASK 0x1C00
1497 1978
1498/* EEPROM Word Offsets */ 1979/* EEPROM Word Offsets */
@@ -1606,7 +2087,22 @@ struct e1000_hw {
1606#define IFS_MIN 40 2087#define IFS_MIN 40
1607#define IFS_RATIO 4 2088#define IFS_RATIO 4
1608 2089
2090/* Extended Configuration Control and Size */
2091#define E1000_EXTCNF_CTRL_PCIE_WRITE_ENABLE 0x00000001
2092#define E1000_EXTCNF_CTRL_PHY_WRITE_ENABLE 0x00000002
2093#define E1000_EXTCNF_CTRL_D_UD_ENABLE 0x00000004
2094#define E1000_EXTCNF_CTRL_D_UD_LATENCY 0x00000008
2095#define E1000_EXTCNF_CTRL_D_UD_OWNER 0x00000010
2096#define E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP 0x00000020
2097#define E1000_EXTCNF_CTRL_MDIO_HW_OWNERSHIP 0x00000040
2098#define E1000_EXTCNF_CTRL_EXT_CNF_POINTER 0x1FFF0000
2099
2100#define E1000_EXTCNF_SIZE_EXT_PHY_LENGTH 0x000000FF
2101#define E1000_EXTCNF_SIZE_EXT_DOCK_LENGTH 0x0000FF00
2102#define E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH 0x00FF0000
2103
1609/* PBA constants */ 2104/* PBA constants */
2105#define E1000_PBA_12K 0x000C /* 12KB, default Rx allocation */
1610#define E1000_PBA_16K 0x0010 /* 16KB, default TX allocation */ 2106#define E1000_PBA_16K 0x0010 /* 16KB, default TX allocation */
1611#define E1000_PBA_22K 0x0016 2107#define E1000_PBA_22K 0x0016
1612#define E1000_PBA_24K 0x0018 2108#define E1000_PBA_24K 0x0018
@@ -1663,6 +2159,13 @@ struct e1000_hw {
1663/* Number of milliseconds we wait for auto-negotiation to complete */ 2159/* Number of milliseconds we wait for auto-negotiation to complete */
1664#define LINK_UP_TIMEOUT 500 2160#define LINK_UP_TIMEOUT 500
1665 2161
2162/* Number of 100 microseconds we wait for PCI Express master disable */
2163#define MASTER_DISABLE_TIMEOUT 800
2164/* Number of milliseconds we wait for Eeprom auto read bit done after MAC reset */
2165#define AUTO_READ_DONE_TIMEOUT 10
2166/* Number of milliseconds we wait for PHY configuration done after MAC reset */
2167#define PHY_CFG_TIMEOUT 40
2168
1666#define E1000_TX_BUFFER_SIZE ((uint32_t)1514) 2169#define E1000_TX_BUFFER_SIZE ((uint32_t)1514)
1667 2170
1668/* The carrier extension symbol, as received by the NIC. */ 2171/* The carrier extension symbol, as received by the NIC. */
@@ -1763,6 +2266,7 @@ struct e1000_hw {
1763#define IGP01E1000_PHY_LINK_HEALTH 0x13 /* PHY Link Health Register */ 2266#define IGP01E1000_PHY_LINK_HEALTH 0x13 /* PHY Link Health Register */
1764#define IGP01E1000_GMII_FIFO 0x14 /* GMII FIFO Register */ 2267#define IGP01E1000_GMII_FIFO 0x14 /* GMII FIFO Register */
1765#define IGP01E1000_PHY_CHANNEL_QUALITY 0x15 /* PHY Channel Quality Register */ 2268#define IGP01E1000_PHY_CHANNEL_QUALITY 0x15 /* PHY Channel Quality Register */
2269#define IGP02E1000_PHY_POWER_MGMT 0x19
1766#define IGP01E1000_PHY_PAGE_SELECT 0x1F /* PHY Page Select Core Register */ 2270#define IGP01E1000_PHY_PAGE_SELECT 0x1F /* PHY Page Select Core Register */
1767 2271
1768/* IGP01E1000 AGC Registers - stores the cable length values*/ 2272/* IGP01E1000 AGC Registers - stores the cable length values*/
@@ -1771,12 +2275,20 @@ struct e1000_hw {
1771#define IGP01E1000_PHY_AGC_C 0x1472 2275#define IGP01E1000_PHY_AGC_C 0x1472
1772#define IGP01E1000_PHY_AGC_D 0x1872 2276#define IGP01E1000_PHY_AGC_D 0x1872
1773 2277
2278/* IGP02E1000 AGC Registers for cable length values */
2279#define IGP02E1000_PHY_AGC_A 0x11B1
2280#define IGP02E1000_PHY_AGC_B 0x12B1
2281#define IGP02E1000_PHY_AGC_C 0x14B1
2282#define IGP02E1000_PHY_AGC_D 0x18B1
2283
1774/* IGP01E1000 DSP Reset Register */ 2284/* IGP01E1000 DSP Reset Register */
1775#define IGP01E1000_PHY_DSP_RESET 0x1F33 2285#define IGP01E1000_PHY_DSP_RESET 0x1F33
1776#define IGP01E1000_PHY_DSP_SET 0x1F71 2286#define IGP01E1000_PHY_DSP_SET 0x1F71
1777#define IGP01E1000_PHY_DSP_FFE 0x1F35 2287#define IGP01E1000_PHY_DSP_FFE 0x1F35
1778 2288
1779#define IGP01E1000_PHY_CHANNEL_NUM 4 2289#define IGP01E1000_PHY_CHANNEL_NUM 4
2290#define IGP02E1000_PHY_CHANNEL_NUM 4
2291
1780#define IGP01E1000_PHY_AGC_PARAM_A 0x1171 2292#define IGP01E1000_PHY_AGC_PARAM_A 0x1171
1781#define IGP01E1000_PHY_AGC_PARAM_B 0x1271 2293#define IGP01E1000_PHY_AGC_PARAM_B 0x1271
1782#define IGP01E1000_PHY_AGC_PARAM_C 0x1471 2294#define IGP01E1000_PHY_AGC_PARAM_C 0x1471
@@ -2060,20 +2572,30 @@ struct e1000_hw {
2060#define IGP01E1000_MSE_CHANNEL_B 0x0F00 2572#define IGP01E1000_MSE_CHANNEL_B 0x0F00
2061#define IGP01E1000_MSE_CHANNEL_A 0xF000 2573#define IGP01E1000_MSE_CHANNEL_A 0xF000
2062 2574
2575#define IGP02E1000_PM_SPD 0x0001 /* Smart Power Down */
2576#define IGP02E1000_PM_D3_LPLU 0x0004 /* Enable LPLU in non-D0a modes */
2577#define IGP02E1000_PM_D0_LPLU 0x0002 /* Enable LPLU in D0a mode */
2578
2063/* IGP01E1000 DSP reset macros */ 2579/* IGP01E1000 DSP reset macros */
2064#define DSP_RESET_ENABLE 0x0 2580#define DSP_RESET_ENABLE 0x0
2065#define DSP_RESET_DISABLE 0x2 2581#define DSP_RESET_DISABLE 0x2
2066#define E1000_MAX_DSP_RESETS 10 2582#define E1000_MAX_DSP_RESETS 10
2067 2583
2068/* IGP01E1000 AGC Registers */ 2584/* IGP01E1000 & IGP02E1000 AGC Registers */
2069 2585
2070#define IGP01E1000_AGC_LENGTH_SHIFT 7 /* Coarse - 13:11, Fine - 10:7 */ 2586#define IGP01E1000_AGC_LENGTH_SHIFT 7 /* Coarse - 13:11, Fine - 10:7 */
2587#define IGP02E1000_AGC_LENGTH_SHIFT 9 /* Coarse - 15:13, Fine - 12:9 */
2588
2589/* IGP02E1000 AGC Register Length 9-bit mask */
2590#define IGP02E1000_AGC_LENGTH_MASK 0x7F
2071 2591
2072/* 7 bits (3 Coarse + 4 Fine) --> 128 optional values */ 2592/* 7 bits (3 Coarse + 4 Fine) --> 128 optional values */
2073#define IGP01E1000_AGC_LENGTH_TABLE_SIZE 128 2593#define IGP01E1000_AGC_LENGTH_TABLE_SIZE 128
2594#define IGP02E1000_AGC_LENGTH_TABLE_SIZE 128
2074 2595
2075/* The precision of the length is +/- 10 meters */ 2596/* The precision error of the cable length is +/- 10 meters */
2076#define IGP01E1000_AGC_RANGE 10 2597#define IGP01E1000_AGC_RANGE 10
2598#define IGP02E1000_AGC_RANGE 10
2077 2599
2078/* IGP01E1000 PCS Initialization register */ 2600/* IGP01E1000 PCS Initialization register */
2079/* bits 3:6 in the PCS registers stores the channels polarity */ 2601/* bits 3:6 in the PCS registers stores the channels polarity */
@@ -2113,6 +2635,8 @@ struct e1000_hw {
2113#define M88E1000_12_PHY_ID M88E1000_E_PHY_ID 2635#define M88E1000_12_PHY_ID M88E1000_E_PHY_ID
2114#define M88E1000_14_PHY_ID M88E1000_E_PHY_ID 2636#define M88E1000_14_PHY_ID M88E1000_E_PHY_ID
2115#define M88E1011_I_REV_4 0x04 2637#define M88E1011_I_REV_4 0x04
2638#define M88E1111_I_PHY_ID 0x01410CC0
2639#define L1LXT971A_PHY_ID 0x001378E0
2116 2640
2117/* Miscellaneous PHY bit definitions. */ 2641/* Miscellaneous PHY bit definitions. */
2118#define PHY_PREAMBLE 0xFFFFFFFF 2642#define PHY_PREAMBLE 0xFFFFFFFF
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 82549a6fcfb3..325495b8b60c 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -29,33 +29,9 @@
29#include "e1000.h" 29#include "e1000.h"
30 30
31/* Change Log 31/* Change Log
32 * 5.3.12 6/7/04 32 * 6.0.44+ 2/15/05
33 * - kcompat NETIF_MSG for older kernels (2.4.9) <sean.p.mcdermott@intel.com> 33 * o applied Anton's patch to resolve tx hang in hardware
34 * - if_mii support and associated kcompat for older kernels 34 * o Applied Andrew Mortons patch - e1000 stops working after resume
35 * - More errlogging support from Jon Mason <jonmason@us.ibm.com>
36 * - Fix TSO issues on PPC64 machines -- Jon Mason <jonmason@us.ibm.com>
37 *
38 * 5.7.1 12/16/04
39 * - Resurrect 82547EI/GI related fix in e1000_intr to avoid deadlocks. This
40 * fix was removed as it caused system instability. The suspected cause of
41 * this is the called to e1000_irq_disable in e1000_intr. Inlined the
42 * required piece of e1000_irq_disable into e1000_intr - Anton Blanchard
43 * 5.7.0 12/10/04
44 * - include fix to the condition that determines when to quit NAPI - Robert Olsson
45 * - use netif_poll_{disable/enable} to synchronize between NAPI and i/f up/down
46 * 5.6.5 11/01/04
47 * - Enabling NETIF_F_SG without checksum offload is illegal -
48 John Mason <jdmason@us.ibm.com>
49 * 5.6.3 10/26/04
50 * - Remove redundant initialization - Jamal Hadi
51 * - Reset buffer_info->dma in tx resource cleanup logic
52 * 5.6.2 10/12/04
53 * - Avoid filling tx_ring completely - shemminger@osdl.org
54 * - Replace schedule_timeout() with msleep()/msleep_interruptible() -
55 * nacc@us.ibm.com
56 * - Sparse cleanup - shemminger@osdl.org
57 * - Fix tx resource cleanup logic
58 * - LLTX support - ak@suse.de and hadi@cyberus.ca
59 */ 35 */
60 36
61char e1000_driver_name[] = "e1000"; 37char e1000_driver_name[] = "e1000";
@@ -65,7 +41,7 @@ char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
65#else 41#else
66#define DRIVERNAPI "-NAPI" 42#define DRIVERNAPI "-NAPI"
67#endif 43#endif
68#define DRV_VERSION "5.7.6-k2"DRIVERNAPI 44#define DRV_VERSION "6.0.54-k2"DRIVERNAPI
69char e1000_driver_version[] = DRV_VERSION; 45char e1000_driver_version[] = DRV_VERSION;
70char e1000_copyright[] = "Copyright (c) 1999-2004 Intel Corporation."; 46char e1000_copyright[] = "Copyright (c) 1999-2004 Intel Corporation.";
71 47
@@ -96,6 +72,7 @@ static struct pci_device_id e1000_pci_tbl[] = {
96 INTEL_E1000_ETHERNET_DEVICE(0x1017), 72 INTEL_E1000_ETHERNET_DEVICE(0x1017),
97 INTEL_E1000_ETHERNET_DEVICE(0x1018), 73 INTEL_E1000_ETHERNET_DEVICE(0x1018),
98 INTEL_E1000_ETHERNET_DEVICE(0x1019), 74 INTEL_E1000_ETHERNET_DEVICE(0x1019),
75 INTEL_E1000_ETHERNET_DEVICE(0x101A),
99 INTEL_E1000_ETHERNET_DEVICE(0x101D), 76 INTEL_E1000_ETHERNET_DEVICE(0x101D),
100 INTEL_E1000_ETHERNET_DEVICE(0x101E), 77 INTEL_E1000_ETHERNET_DEVICE(0x101E),
101 INTEL_E1000_ETHERNET_DEVICE(0x1026), 78 INTEL_E1000_ETHERNET_DEVICE(0x1026),
@@ -110,6 +87,9 @@ static struct pci_device_id e1000_pci_tbl[] = {
110 INTEL_E1000_ETHERNET_DEVICE(0x107B), 87 INTEL_E1000_ETHERNET_DEVICE(0x107B),
111 INTEL_E1000_ETHERNET_DEVICE(0x107C), 88 INTEL_E1000_ETHERNET_DEVICE(0x107C),
112 INTEL_E1000_ETHERNET_DEVICE(0x108A), 89 INTEL_E1000_ETHERNET_DEVICE(0x108A),
90 INTEL_E1000_ETHERNET_DEVICE(0x108B),
91 INTEL_E1000_ETHERNET_DEVICE(0x108C),
92 INTEL_E1000_ETHERNET_DEVICE(0x1099),
113 /* required last entry */ 93 /* required last entry */
114 {0,} 94 {0,}
115}; 95};
@@ -155,10 +135,14 @@ static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter);
155static int e1000_clean(struct net_device *netdev, int *budget); 135static int e1000_clean(struct net_device *netdev, int *budget);
156static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter, 136static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter,
157 int *work_done, int work_to_do); 137 int *work_done, int work_to_do);
138static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
139 int *work_done, int work_to_do);
158#else 140#else
159static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter); 141static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter);
142static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter);
160#endif 143#endif
161static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter); 144static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter);
145static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter);
162static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); 146static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
163static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, 147static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
164 int cmd); 148 int cmd);
@@ -286,7 +270,29 @@ e1000_irq_enable(struct e1000_adapter *adapter)
286 E1000_WRITE_FLUSH(&adapter->hw); 270 E1000_WRITE_FLUSH(&adapter->hw);
287 } 271 }
288} 272}
289 273void
274e1000_update_mng_vlan(struct e1000_adapter *adapter)
275{
276 struct net_device *netdev = adapter->netdev;
277 uint16_t vid = adapter->hw.mng_cookie.vlan_id;
278 uint16_t old_vid = adapter->mng_vlan_id;
279 if(adapter->vlgrp) {
280 if(!adapter->vlgrp->vlan_devices[vid]) {
281 if(adapter->hw.mng_cookie.status &
282 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
283 e1000_vlan_rx_add_vid(netdev, vid);
284 adapter->mng_vlan_id = vid;
285 } else
286 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
287
288 if((old_vid != (uint16_t)E1000_MNG_VLAN_NONE) &&
289 (vid != old_vid) &&
290 !adapter->vlgrp->vlan_devices[old_vid])
291 e1000_vlan_rx_kill_vid(netdev, old_vid);
292 }
293 }
294}
295
290int 296int
291e1000_up(struct e1000_adapter *adapter) 297e1000_up(struct e1000_adapter *adapter)
292{ 298{
@@ -310,19 +316,33 @@ e1000_up(struct e1000_adapter *adapter)
310 e1000_configure_tx(adapter); 316 e1000_configure_tx(adapter);
311 e1000_setup_rctl(adapter); 317 e1000_setup_rctl(adapter);
312 e1000_configure_rx(adapter); 318 e1000_configure_rx(adapter);
313 e1000_alloc_rx_buffers(adapter); 319 adapter->alloc_rx_buf(adapter);
314 320
321#ifdef CONFIG_PCI_MSI
322 if(adapter->hw.mac_type > e1000_82547_rev_2) {
323 adapter->have_msi = TRUE;
324 if((err = pci_enable_msi(adapter->pdev))) {
325 DPRINTK(PROBE, ERR,
326 "Unable to allocate MSI interrupt Error: %d\n", err);
327 adapter->have_msi = FALSE;
328 }
329 }
330#endif
315 if((err = request_irq(adapter->pdev->irq, &e1000_intr, 331 if((err = request_irq(adapter->pdev->irq, &e1000_intr,
316 SA_SHIRQ | SA_SAMPLE_RANDOM, 332 SA_SHIRQ | SA_SAMPLE_RANDOM,
317 netdev->name, netdev))) 333 netdev->name, netdev))) {
334 DPRINTK(PROBE, ERR,
335 "Unable to allocate interrupt Error: %d\n", err);
318 return err; 336 return err;
337 }
319 338
320 mod_timer(&adapter->watchdog_timer, jiffies); 339 mod_timer(&adapter->watchdog_timer, jiffies);
321 e1000_irq_enable(adapter);
322 340
323#ifdef CONFIG_E1000_NAPI 341#ifdef CONFIG_E1000_NAPI
324 netif_poll_enable(netdev); 342 netif_poll_enable(netdev);
325#endif 343#endif
344 e1000_irq_enable(adapter);
345
326 return 0; 346 return 0;
327} 347}
328 348
@@ -333,6 +353,11 @@ e1000_down(struct e1000_adapter *adapter)
333 353
334 e1000_irq_disable(adapter); 354 e1000_irq_disable(adapter);
335 free_irq(adapter->pdev->irq, netdev); 355 free_irq(adapter->pdev->irq, netdev);
356#ifdef CONFIG_PCI_MSI
357 if(adapter->hw.mac_type > e1000_82547_rev_2 &&
358 adapter->have_msi == TRUE)
359 pci_disable_msi(adapter->pdev);
360#endif
336 del_timer_sync(&adapter->tx_fifo_stall_timer); 361 del_timer_sync(&adapter->tx_fifo_stall_timer);
337 del_timer_sync(&adapter->watchdog_timer); 362 del_timer_sync(&adapter->watchdog_timer);
338 del_timer_sync(&adapter->phy_info_timer); 363 del_timer_sync(&adapter->phy_info_timer);
@@ -350,62 +375,93 @@ e1000_down(struct e1000_adapter *adapter)
350 e1000_clean_rx_ring(adapter); 375 e1000_clean_rx_ring(adapter);
351 376
352 /* If WoL is not enabled 377 /* If WoL is not enabled
378 * and management mode is not IAMT
353 * Power down the PHY so no link is implied when interface is down */ 379 * Power down the PHY so no link is implied when interface is down */
354 if(!adapter->wol && adapter->hw.media_type == e1000_media_type_copper) { 380 if(!adapter->wol && adapter->hw.mac_type >= e1000_82540 &&
381 adapter->hw.media_type == e1000_media_type_copper &&
382 !e1000_check_mng_mode(&adapter->hw) &&
383 !(E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN)) {
355 uint16_t mii_reg; 384 uint16_t mii_reg;
356 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg); 385 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
357 mii_reg |= MII_CR_POWER_DOWN; 386 mii_reg |= MII_CR_POWER_DOWN;
358 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg); 387 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg);
388 mdelay(1);
359 } 389 }
360} 390}
361 391
362void 392void
363e1000_reset(struct e1000_adapter *adapter) 393e1000_reset(struct e1000_adapter *adapter)
364{ 394{
365 uint32_t pba; 395 struct net_device *netdev = adapter->netdev;
396 uint32_t pba, manc;
397 uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF;
398 uint16_t fc_low_water_mark = E1000_FC_LOW_DIFF;
366 399
367 /* Repartition Pba for greater than 9k mtu 400 /* Repartition Pba for greater than 9k mtu
368 * To take effect CTRL.RST is required. 401 * To take effect CTRL.RST is required.
369 */ 402 */
370 403
371 if(adapter->hw.mac_type < e1000_82547) { 404 switch (adapter->hw.mac_type) {
372 if(adapter->rx_buffer_len > E1000_RXBUFFER_8192) 405 case e1000_82547:
373 pba = E1000_PBA_40K; 406 case e1000_82547_rev_2:
374 else 407 pba = E1000_PBA_30K;
375 pba = E1000_PBA_48K; 408 break;
376 } else { 409 case e1000_82573:
377 if(adapter->rx_buffer_len > E1000_RXBUFFER_8192) 410 pba = E1000_PBA_12K;
378 pba = E1000_PBA_22K; 411 break;
379 else 412 default:
380 pba = E1000_PBA_30K; 413 pba = E1000_PBA_48K;
414 break;
415 }
416
417 if((adapter->hw.mac_type != e1000_82573) &&
418 (adapter->rx_buffer_len > E1000_RXBUFFER_8192)) {
419 pba -= 8; /* allocate more FIFO for Tx */
420 /* send an XOFF when there is enough space in the
421 * Rx FIFO to hold one extra full size Rx packet
422 */
423 fc_high_water_mark = netdev->mtu + ENET_HEADER_SIZE +
424 ETHERNET_FCS_SIZE + 1;
425 fc_low_water_mark = fc_high_water_mark + 8;
426 }
427
428
429 if(adapter->hw.mac_type == e1000_82547) {
381 adapter->tx_fifo_head = 0; 430 adapter->tx_fifo_head = 0;
382 adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT; 431 adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
383 adapter->tx_fifo_size = 432 adapter->tx_fifo_size =
384 (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT; 433 (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
385 atomic_set(&adapter->tx_fifo_stall, 0); 434 atomic_set(&adapter->tx_fifo_stall, 0);
386 } 435 }
436
387 E1000_WRITE_REG(&adapter->hw, PBA, pba); 437 E1000_WRITE_REG(&adapter->hw, PBA, pba);
388 438
389 /* flow control settings */ 439 /* flow control settings */
390 adapter->hw.fc_high_water = (pba << E1000_PBA_BYTES_SHIFT) - 440 adapter->hw.fc_high_water = (pba << E1000_PBA_BYTES_SHIFT) -
391 E1000_FC_HIGH_DIFF; 441 fc_high_water_mark;
392 adapter->hw.fc_low_water = (pba << E1000_PBA_BYTES_SHIFT) - 442 adapter->hw.fc_low_water = (pba << E1000_PBA_BYTES_SHIFT) -
393 E1000_FC_LOW_DIFF; 443 fc_low_water_mark;
394 adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME; 444 adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME;
395 adapter->hw.fc_send_xon = 1; 445 adapter->hw.fc_send_xon = 1;
396 adapter->hw.fc = adapter->hw.original_fc; 446 adapter->hw.fc = adapter->hw.original_fc;
397 447
448 /* Allow time for pending master requests to run */
398 e1000_reset_hw(&adapter->hw); 449 e1000_reset_hw(&adapter->hw);
399 if(adapter->hw.mac_type >= e1000_82544) 450 if(adapter->hw.mac_type >= e1000_82544)
400 E1000_WRITE_REG(&adapter->hw, WUC, 0); 451 E1000_WRITE_REG(&adapter->hw, WUC, 0);
401 if(e1000_init_hw(&adapter->hw)) 452 if(e1000_init_hw(&adapter->hw))
402 DPRINTK(PROBE, ERR, "Hardware Error\n"); 453 DPRINTK(PROBE, ERR, "Hardware Error\n");
403 454 e1000_update_mng_vlan(adapter);
404 /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */ 455 /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
405 E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE); 456 E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE);
406 457
407 e1000_reset_adaptive(&adapter->hw); 458 e1000_reset_adaptive(&adapter->hw);
408 e1000_phy_get_info(&adapter->hw, &adapter->phy_info); 459 e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
460 if (adapter->en_mng_pt) {
461 manc = E1000_READ_REG(&adapter->hw, MANC);
462 manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST);
463 E1000_WRITE_REG(&adapter->hw, MANC, manc);
464 }
409} 465}
410 466
411/** 467/**
@@ -426,15 +482,13 @@ e1000_probe(struct pci_dev *pdev,
426{ 482{
427 struct net_device *netdev; 483 struct net_device *netdev;
428 struct e1000_adapter *adapter; 484 struct e1000_adapter *adapter;
485 unsigned long mmio_start, mmio_len;
486 uint32_t swsm;
487
429 static int cards_found = 0; 488 static int cards_found = 0;
430 unsigned long mmio_start; 489 int i, err, pci_using_dac;
431 int mmio_len;
432 int pci_using_dac;
433 int i;
434 int err;
435 uint16_t eeprom_data; 490 uint16_t eeprom_data;
436 uint16_t eeprom_apme_mask = E1000_EEPROM_APME; 491 uint16_t eeprom_apme_mask = E1000_EEPROM_APME;
437
438 if((err = pci_enable_device(pdev))) 492 if((err = pci_enable_device(pdev)))
439 return err; 493 return err;
440 494
@@ -521,6 +575,9 @@ e1000_probe(struct pci_dev *pdev,
521 if((err = e1000_sw_init(adapter))) 575 if((err = e1000_sw_init(adapter)))
522 goto err_sw_init; 576 goto err_sw_init;
523 577
578 if((err = e1000_check_phy_reset_block(&adapter->hw)))
579 DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
580
524 if(adapter->hw.mac_type >= e1000_82543) { 581 if(adapter->hw.mac_type >= e1000_82543) {
525 netdev->features = NETIF_F_SG | 582 netdev->features = NETIF_F_SG |
526 NETIF_F_HW_CSUM | 583 NETIF_F_HW_CSUM |
@@ -533,6 +590,11 @@ e1000_probe(struct pci_dev *pdev,
533 if((adapter->hw.mac_type >= e1000_82544) && 590 if((adapter->hw.mac_type >= e1000_82544) &&
534 (adapter->hw.mac_type != e1000_82547)) 591 (adapter->hw.mac_type != e1000_82547))
535 netdev->features |= NETIF_F_TSO; 592 netdev->features |= NETIF_F_TSO;
593
594#ifdef NETIF_F_TSO_IPV6
595 if(adapter->hw.mac_type > e1000_82547_rev_2)
596 netdev->features |= NETIF_F_TSO_IPV6;
597#endif
536#endif 598#endif
537 if(pci_using_dac) 599 if(pci_using_dac)
538 netdev->features |= NETIF_F_HIGHDMA; 600 netdev->features |= NETIF_F_HIGHDMA;
@@ -540,6 +602,8 @@ e1000_probe(struct pci_dev *pdev,
540 /* hard_start_xmit is safe against parallel locking */ 602 /* hard_start_xmit is safe against parallel locking */
541 netdev->features |= NETIF_F_LLTX; 603 netdev->features |= NETIF_F_LLTX;
542 604
605 adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw);
606
543 /* before reading the EEPROM, reset the controller to 607 /* before reading the EEPROM, reset the controller to
544 * put the device in a known good starting state */ 608 * put the device in a known good starting state */
545 609
@@ -555,7 +619,7 @@ e1000_probe(struct pci_dev *pdev,
555 619
556 /* copy the MAC address out of the EEPROM */ 620 /* copy the MAC address out of the EEPROM */
557 621
558 if (e1000_read_mac_addr(&adapter->hw)) 622 if(e1000_read_mac_addr(&adapter->hw))
559 DPRINTK(PROBE, ERR, "EEPROM Read Error\n"); 623 DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
560 memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len); 624 memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
561 625
@@ -629,6 +693,17 @@ e1000_probe(struct pci_dev *pdev,
629 /* reset the hardware with the new settings */ 693 /* reset the hardware with the new settings */
630 e1000_reset(adapter); 694 e1000_reset(adapter);
631 695
696 /* Let firmware know the driver has taken over */
697 switch(adapter->hw.mac_type) {
698 case e1000_82573:
699 swsm = E1000_READ_REG(&adapter->hw, SWSM);
700 E1000_WRITE_REG(&adapter->hw, SWSM,
701 swsm | E1000_SWSM_DRV_LOAD);
702 break;
703 default:
704 break;
705 }
706
632 strcpy(netdev->name, "eth%d"); 707 strcpy(netdev->name, "eth%d");
633 if((err = register_netdev(netdev))) 708 if((err = register_netdev(netdev)))
634 goto err_register; 709 goto err_register;
@@ -664,7 +739,7 @@ e1000_remove(struct pci_dev *pdev)
664{ 739{
665 struct net_device *netdev = pci_get_drvdata(pdev); 740 struct net_device *netdev = pci_get_drvdata(pdev);
666 struct e1000_adapter *adapter = netdev->priv; 741 struct e1000_adapter *adapter = netdev->priv;
667 uint32_t manc; 742 uint32_t manc, swsm;
668 743
669 flush_scheduled_work(); 744 flush_scheduled_work();
670 745
@@ -677,9 +752,21 @@ e1000_remove(struct pci_dev *pdev)
677 } 752 }
678 } 753 }
679 754
755 switch(adapter->hw.mac_type) {
756 case e1000_82573:
757 swsm = E1000_READ_REG(&adapter->hw, SWSM);
758 E1000_WRITE_REG(&adapter->hw, SWSM,
759 swsm & ~E1000_SWSM_DRV_LOAD);
760 break;
761
762 default:
763 break;
764 }
765
680 unregister_netdev(netdev); 766 unregister_netdev(netdev);
681 767
682 e1000_phy_hw_reset(&adapter->hw); 768 if(!e1000_check_phy_reset_block(&adapter->hw))
769 e1000_phy_hw_reset(&adapter->hw);
683 770
684 iounmap(adapter->hw.hw_addr); 771 iounmap(adapter->hw.hw_addr);
685 pci_release_regions(pdev); 772 pci_release_regions(pdev);
@@ -717,6 +804,7 @@ e1000_sw_init(struct e1000_adapter *adapter)
717 pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word); 804 pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
718 805
719 adapter->rx_buffer_len = E1000_RXBUFFER_2048; 806 adapter->rx_buffer_len = E1000_RXBUFFER_2048;
807 adapter->rx_ps_bsize0 = E1000_RXBUFFER_256;
720 hw->max_frame_size = netdev->mtu + 808 hw->max_frame_size = netdev->mtu +
721 ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; 809 ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
722 hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE; 810 hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
@@ -730,7 +818,10 @@ e1000_sw_init(struct e1000_adapter *adapter)
730 818
731 /* initialize eeprom parameters */ 819 /* initialize eeprom parameters */
732 820
733 e1000_init_eeprom_params(hw); 821 if(e1000_init_eeprom_params(hw)) {
822 E1000_ERR("EEPROM initialization failed\n");
823 return -EIO;
824 }
734 825
735 switch(hw->mac_type) { 826 switch(hw->mac_type) {
736 default: 827 default:
@@ -795,6 +886,11 @@ e1000_open(struct net_device *netdev)
795 886
796 if((err = e1000_up(adapter))) 887 if((err = e1000_up(adapter)))
797 goto err_up; 888 goto err_up;
889 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
890 if((adapter->hw.mng_cookie.status &
891 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
892 e1000_update_mng_vlan(adapter);
893 }
798 894
799 return E1000_SUCCESS; 895 return E1000_SUCCESS;
800 896
@@ -830,14 +926,18 @@ e1000_close(struct net_device *netdev)
830 e1000_free_tx_resources(adapter); 926 e1000_free_tx_resources(adapter);
831 e1000_free_rx_resources(adapter); 927 e1000_free_rx_resources(adapter);
832 928
929 if((adapter->hw.mng_cookie.status &
930 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
931 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
932 }
833 return 0; 933 return 0;
834} 934}
835 935
836/** 936/**
837 * e1000_check_64k_bound - check that memory doesn't cross 64kB boundary 937 * e1000_check_64k_bound - check that memory doesn't cross 64kB boundary
838 * @adapter: address of board private structure 938 * @adapter: address of board private structure
839 * @begin: address of beginning of memory 939 * @start: address of beginning of memory
840 * @end: address of end of memory 940 * @len: length of memory
841 **/ 941 **/
842static inline boolean_t 942static inline boolean_t
843e1000_check_64k_bound(struct e1000_adapter *adapter, 943e1000_check_64k_bound(struct e1000_adapter *adapter,
@@ -846,12 +946,10 @@ e1000_check_64k_bound(struct e1000_adapter *adapter,
846 unsigned long begin = (unsigned long) start; 946 unsigned long begin = (unsigned long) start;
847 unsigned long end = begin + len; 947 unsigned long end = begin + len;
848 948
849 /* first rev 82545 and 82546 need to not allow any memory 949 /* First rev 82545 and 82546 need to not allow any memory
850 * write location to cross a 64k boundary due to errata 23 */ 950 * write location to cross 64k boundary due to errata 23 */
851 if (adapter->hw.mac_type == e1000_82545 || 951 if (adapter->hw.mac_type == e1000_82545 ||
852 adapter->hw.mac_type == e1000_82546 ) { 952 adapter->hw.mac_type == e1000_82546) {
853
854 /* check buffer doesn't cross 64kB */
855 return ((begin ^ (end - 1)) >> 16) != 0 ? FALSE : TRUE; 953 return ((begin ^ (end - 1)) >> 16) != 0 ? FALSE : TRUE;
856 } 954 }
857 955
@@ -875,8 +973,8 @@ e1000_setup_tx_resources(struct e1000_adapter *adapter)
875 size = sizeof(struct e1000_buffer) * txdr->count; 973 size = sizeof(struct e1000_buffer) * txdr->count;
876 txdr->buffer_info = vmalloc(size); 974 txdr->buffer_info = vmalloc(size);
877 if(!txdr->buffer_info) { 975 if(!txdr->buffer_info) {
878 DPRINTK(PROBE, ERR, 976 DPRINTK(PROBE, ERR,
879 "Unable to Allocate Memory for the Transmit descriptor ring\n"); 977 "Unable to allocate memory for the transmit descriptor ring\n");
880 return -ENOMEM; 978 return -ENOMEM;
881 } 979 }
882 memset(txdr->buffer_info, 0, size); 980 memset(txdr->buffer_info, 0, size);
@@ -889,38 +987,38 @@ e1000_setup_tx_resources(struct e1000_adapter *adapter)
889 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma); 987 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
890 if(!txdr->desc) { 988 if(!txdr->desc) {
891setup_tx_desc_die: 989setup_tx_desc_die:
892 DPRINTK(PROBE, ERR,
893 "Unable to Allocate Memory for the Transmit descriptor ring\n");
894 vfree(txdr->buffer_info); 990 vfree(txdr->buffer_info);
991 DPRINTK(PROBE, ERR,
992 "Unable to allocate memory for the transmit descriptor ring\n");
895 return -ENOMEM; 993 return -ENOMEM;
896 } 994 }
897 995
898 /* fix for errata 23, cant cross 64kB boundary */ 996 /* Fix for errata 23, can't cross 64kB boundary */
899 if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) { 997 if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) {
900 void *olddesc = txdr->desc; 998 void *olddesc = txdr->desc;
901 dma_addr_t olddma = txdr->dma; 999 dma_addr_t olddma = txdr->dma;
902 DPRINTK(TX_ERR,ERR,"txdr align check failed: %u bytes at %p\n", 1000 DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
903 txdr->size, txdr->desc); 1001 "at %p\n", txdr->size, txdr->desc);
904 /* try again, without freeing the previous */ 1002 /* Try again, without freeing the previous */
905 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma); 1003 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
906 /* failed allocation, critial failure */
907 if(!txdr->desc) { 1004 if(!txdr->desc) {
1005 /* Failed allocation, critical failure */
908 pci_free_consistent(pdev, txdr->size, olddesc, olddma); 1006 pci_free_consistent(pdev, txdr->size, olddesc, olddma);
909 goto setup_tx_desc_die; 1007 goto setup_tx_desc_die;
910 } 1008 }
911 1009
912 if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) { 1010 if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) {
913 /* give up */ 1011 /* give up */
914 pci_free_consistent(pdev, txdr->size, 1012 pci_free_consistent(pdev, txdr->size, txdr->desc,
915 txdr->desc, txdr->dma); 1013 txdr->dma);
916 pci_free_consistent(pdev, txdr->size, olddesc, olddma); 1014 pci_free_consistent(pdev, txdr->size, olddesc, olddma);
917 DPRINTK(PROBE, ERR, 1015 DPRINTK(PROBE, ERR,
918 "Unable to Allocate aligned Memory for the Transmit" 1016 "Unable to allocate aligned memory "
919 " descriptor ring\n"); 1017 "for the transmit descriptor ring\n");
920 vfree(txdr->buffer_info); 1018 vfree(txdr->buffer_info);
921 return -ENOMEM; 1019 return -ENOMEM;
922 } else { 1020 } else {
923 /* free old, move on with the new one since its okay */ 1021 /* Free old allocation, new allocation was successful */
924 pci_free_consistent(pdev, txdr->size, olddesc, olddma); 1022 pci_free_consistent(pdev, txdr->size, olddesc, olddma);
925 } 1023 }
926 } 1024 }
@@ -1022,59 +1120,88 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter)
1022{ 1120{
1023 struct e1000_desc_ring *rxdr = &adapter->rx_ring; 1121 struct e1000_desc_ring *rxdr = &adapter->rx_ring;
1024 struct pci_dev *pdev = adapter->pdev; 1122 struct pci_dev *pdev = adapter->pdev;
1025 int size; 1123 int size, desc_len;
1026 1124
1027 size = sizeof(struct e1000_buffer) * rxdr->count; 1125 size = sizeof(struct e1000_buffer) * rxdr->count;
1028 rxdr->buffer_info = vmalloc(size); 1126 rxdr->buffer_info = vmalloc(size);
1029 if(!rxdr->buffer_info) { 1127 if(!rxdr->buffer_info) {
1030 DPRINTK(PROBE, ERR, 1128 DPRINTK(PROBE, ERR,
1031 "Unable to Allocate Memory for the Recieve descriptor ring\n"); 1129 "Unable to allocate memory for the receive descriptor ring\n");
1032 return -ENOMEM; 1130 return -ENOMEM;
1033 } 1131 }
1034 memset(rxdr->buffer_info, 0, size); 1132 memset(rxdr->buffer_info, 0, size);
1035 1133
1134 size = sizeof(struct e1000_ps_page) * rxdr->count;
1135 rxdr->ps_page = kmalloc(size, GFP_KERNEL);
1136 if(!rxdr->ps_page) {
1137 vfree(rxdr->buffer_info);
1138 DPRINTK(PROBE, ERR,
1139 "Unable to allocate memory for the receive descriptor ring\n");
1140 return -ENOMEM;
1141 }
1142 memset(rxdr->ps_page, 0, size);
1143
1144 size = sizeof(struct e1000_ps_page_dma) * rxdr->count;
1145 rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL);
1146 if(!rxdr->ps_page_dma) {
1147 vfree(rxdr->buffer_info);
1148 kfree(rxdr->ps_page);
1149 DPRINTK(PROBE, ERR,
1150 "Unable to allocate memory for the receive descriptor ring\n");
1151 return -ENOMEM;
1152 }
1153 memset(rxdr->ps_page_dma, 0, size);
1154
1155 if(adapter->hw.mac_type <= e1000_82547_rev_2)
1156 desc_len = sizeof(struct e1000_rx_desc);
1157 else
1158 desc_len = sizeof(union e1000_rx_desc_packet_split);
1159
1036 /* Round up to nearest 4K */ 1160 /* Round up to nearest 4K */
1037 1161
1038 rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc); 1162 rxdr->size = rxdr->count * desc_len;
1039 E1000_ROUNDUP(rxdr->size, 4096); 1163 E1000_ROUNDUP(rxdr->size, 4096);
1040 1164
1041 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma); 1165 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
1042 1166
1043 if(!rxdr->desc) { 1167 if(!rxdr->desc) {
1044setup_rx_desc_die: 1168setup_rx_desc_die:
1045 DPRINTK(PROBE, ERR,
1046 "Unble to Allocate Memory for the Recieve descriptor ring\n");
1047 vfree(rxdr->buffer_info); 1169 vfree(rxdr->buffer_info);
1170 kfree(rxdr->ps_page);
1171 kfree(rxdr->ps_page_dma);
1172 DPRINTK(PROBE, ERR,
1173 "Unable to allocate memory for the receive descriptor ring\n");
1048 return -ENOMEM; 1174 return -ENOMEM;
1049 } 1175 }
1050 1176
1051 /* fix for errata 23, cant cross 64kB boundary */ 1177 /* Fix for errata 23, can't cross 64kB boundary */
1052 if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) { 1178 if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
1053 void *olddesc = rxdr->desc; 1179 void *olddesc = rxdr->desc;
1054 dma_addr_t olddma = rxdr->dma; 1180 dma_addr_t olddma = rxdr->dma;
1055 DPRINTK(RX_ERR,ERR, 1181 DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
1056 "rxdr align check failed: %u bytes at %p\n", 1182 "at %p\n", rxdr->size, rxdr->desc);
1057 rxdr->size, rxdr->desc); 1183 /* Try again, without freeing the previous */
1058 /* try again, without freeing the previous */
1059 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma); 1184 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
1060 /* failed allocation, critial failure */
1061 if(!rxdr->desc) { 1185 if(!rxdr->desc) {
1186 /* Failed allocation, critical failure */
1062 pci_free_consistent(pdev, rxdr->size, olddesc, olddma); 1187 pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
1063 goto setup_rx_desc_die; 1188 goto setup_rx_desc_die;
1064 } 1189 }
1065 1190
1066 if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) { 1191 if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
1067 /* give up */ 1192 /* give up */
1068 pci_free_consistent(pdev, rxdr->size, 1193 pci_free_consistent(pdev, rxdr->size, rxdr->desc,
1069 rxdr->desc, rxdr->dma); 1194 rxdr->dma);
1070 pci_free_consistent(pdev, rxdr->size, olddesc, olddma); 1195 pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
1071 DPRINTK(PROBE, ERR, 1196 DPRINTK(PROBE, ERR,
1072 "Unable to Allocate aligned Memory for the" 1197 "Unable to allocate aligned memory "
1073 " Receive descriptor ring\n"); 1198 "for the receive descriptor ring\n");
1074 vfree(rxdr->buffer_info); 1199 vfree(rxdr->buffer_info);
1200 kfree(rxdr->ps_page);
1201 kfree(rxdr->ps_page_dma);
1075 return -ENOMEM; 1202 return -ENOMEM;
1076 } else { 1203 } else {
1077 /* free old, move on with the new one since its okay */ 1204 /* Free old allocation, new allocation was successful */
1078 pci_free_consistent(pdev, rxdr->size, olddesc, olddma); 1205 pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
1079 } 1206 }
1080 } 1207 }
@@ -1087,14 +1214,15 @@ setup_rx_desc_die:
1087} 1214}
1088 1215
1089/** 1216/**
1090 * e1000_setup_rctl - configure the receive control register 1217 * e1000_setup_rctl - configure the receive control registers
1091 * @adapter: Board private structure 1218 * @adapter: Board private structure
1092 **/ 1219 **/
1093 1220
1094static void 1221static void
1095e1000_setup_rctl(struct e1000_adapter *adapter) 1222e1000_setup_rctl(struct e1000_adapter *adapter)
1096{ 1223{
1097 uint32_t rctl; 1224 uint32_t rctl, rfctl;
1225 uint32_t psrctl = 0;
1098 1226
1099 rctl = E1000_READ_REG(&adapter->hw, RCTL); 1227 rctl = E1000_READ_REG(&adapter->hw, RCTL);
1100 1228
@@ -1109,24 +1237,69 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1109 else 1237 else
1110 rctl &= ~E1000_RCTL_SBP; 1238 rctl &= ~E1000_RCTL_SBP;
1111 1239
1240 if (adapter->netdev->mtu <= ETH_DATA_LEN)
1241 rctl &= ~E1000_RCTL_LPE;
1242 else
1243 rctl |= E1000_RCTL_LPE;
1244
1112 /* Setup buffer sizes */ 1245 /* Setup buffer sizes */
1113 rctl &= ~(E1000_RCTL_SZ_4096); 1246 if(adapter->hw.mac_type == e1000_82573) {
1114 rctl |= (E1000_RCTL_BSEX | E1000_RCTL_LPE); 1247 /* We can now specify buffers in 1K increments.
1115 switch (adapter->rx_buffer_len) { 1248 * BSIZE and BSEX are ignored in this case. */
1116 case E1000_RXBUFFER_2048: 1249 rctl |= adapter->rx_buffer_len << 0x11;
1117 default: 1250 } else {
1118 rctl |= E1000_RCTL_SZ_2048; 1251 rctl &= ~E1000_RCTL_SZ_4096;
1119 rctl &= ~(E1000_RCTL_BSEX | E1000_RCTL_LPE); 1252 rctl |= E1000_RCTL_BSEX;
1120 break; 1253 switch (adapter->rx_buffer_len) {
1121 case E1000_RXBUFFER_4096: 1254 case E1000_RXBUFFER_2048:
1122 rctl |= E1000_RCTL_SZ_4096; 1255 default:
1123 break; 1256 rctl |= E1000_RCTL_SZ_2048;
1124 case E1000_RXBUFFER_8192: 1257 rctl &= ~E1000_RCTL_BSEX;
1125 rctl |= E1000_RCTL_SZ_8192; 1258 break;
1126 break; 1259 case E1000_RXBUFFER_4096:
1127 case E1000_RXBUFFER_16384: 1260 rctl |= E1000_RCTL_SZ_4096;
1128 rctl |= E1000_RCTL_SZ_16384; 1261 break;
1129 break; 1262 case E1000_RXBUFFER_8192:
1263 rctl |= E1000_RCTL_SZ_8192;
1264 break;
1265 case E1000_RXBUFFER_16384:
1266 rctl |= E1000_RCTL_SZ_16384;
1267 break;
1268 }
1269 }
1270
1271#ifdef CONFIG_E1000_PACKET_SPLIT
1272 /* 82571 and greater support packet-split where the protocol
1273 * header is placed in skb->data and the packet data is
1274 * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
1275 * In the case of a non-split, skb->data is linearly filled,
1276 * followed by the page buffers. Therefore, skb->data is
1277 * sized to hold the largest protocol header.
1278 */
1279 adapter->rx_ps = (adapter->hw.mac_type > e1000_82547_rev_2)
1280 && (adapter->netdev->mtu
1281 < ((3 * PAGE_SIZE) + adapter->rx_ps_bsize0));
1282#endif
1283 if(adapter->rx_ps) {
1284 /* Configure extra packet-split registers */
1285 rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
1286 rfctl |= E1000_RFCTL_EXTEN;
1287 /* disable IPv6 packet split support */
1288 rfctl |= E1000_RFCTL_IPV6_DIS;
1289 E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl);
1290
1291 rctl |= E1000_RCTL_DTYP_PS | E1000_RCTL_SECRC;
1292
1293 psrctl |= adapter->rx_ps_bsize0 >>
1294 E1000_PSRCTL_BSIZE0_SHIFT;
1295 psrctl |= PAGE_SIZE >>
1296 E1000_PSRCTL_BSIZE1_SHIFT;
1297 psrctl |= PAGE_SIZE <<
1298 E1000_PSRCTL_BSIZE2_SHIFT;
1299 psrctl |= PAGE_SIZE <<
1300 E1000_PSRCTL_BSIZE3_SHIFT;
1301
1302 E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl);
1130 } 1303 }
1131 1304
1132 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 1305 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
@@ -1143,9 +1316,18 @@ static void
1143e1000_configure_rx(struct e1000_adapter *adapter) 1316e1000_configure_rx(struct e1000_adapter *adapter)
1144{ 1317{
1145 uint64_t rdba = adapter->rx_ring.dma; 1318 uint64_t rdba = adapter->rx_ring.dma;
1146 uint32_t rdlen = adapter->rx_ring.count * sizeof(struct e1000_rx_desc); 1319 uint32_t rdlen, rctl, rxcsum;
1147 uint32_t rctl; 1320
1148 uint32_t rxcsum; 1321 if(adapter->rx_ps) {
1322 rdlen = adapter->rx_ring.count *
1323 sizeof(union e1000_rx_desc_packet_split);
1324 adapter->clean_rx = e1000_clean_rx_irq_ps;
1325 adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
1326 } else {
1327 rdlen = adapter->rx_ring.count * sizeof(struct e1000_rx_desc);
1328 adapter->clean_rx = e1000_clean_rx_irq;
1329 adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
1330 }
1149 1331
1150 /* disable receives while setting up the descriptors */ 1332 /* disable receives while setting up the descriptors */
1151 rctl = E1000_READ_REG(&adapter->hw, RCTL); 1333 rctl = E1000_READ_REG(&adapter->hw, RCTL);
@@ -1172,13 +1354,27 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1172 E1000_WRITE_REG(&adapter->hw, RDT, 0); 1354 E1000_WRITE_REG(&adapter->hw, RDT, 0);
1173 1355
1174 /* Enable 82543 Receive Checksum Offload for TCP and UDP */ 1356 /* Enable 82543 Receive Checksum Offload for TCP and UDP */
1175 if((adapter->hw.mac_type >= e1000_82543) && 1357 if(adapter->hw.mac_type >= e1000_82543) {
1176 (adapter->rx_csum == TRUE)) {
1177 rxcsum = E1000_READ_REG(&adapter->hw, RXCSUM); 1358 rxcsum = E1000_READ_REG(&adapter->hw, RXCSUM);
1178 rxcsum |= E1000_RXCSUM_TUOFL; 1359 if(adapter->rx_csum == TRUE) {
1360 rxcsum |= E1000_RXCSUM_TUOFL;
1361
1362 /* Enable 82573 IPv4 payload checksum for UDP fragments
1363 * Must be used in conjunction with packet-split. */
1364 if((adapter->hw.mac_type > e1000_82547_rev_2) &&
1365 (adapter->rx_ps)) {
1366 rxcsum |= E1000_RXCSUM_IPPCSE;
1367 }
1368 } else {
1369 rxcsum &= ~E1000_RXCSUM_TUOFL;
1370 /* don't need to clear IPPCSE as it defaults to 0 */
1371 }
1179 E1000_WRITE_REG(&adapter->hw, RXCSUM, rxcsum); 1372 E1000_WRITE_REG(&adapter->hw, RXCSUM, rxcsum);
1180 } 1373 }
1181 1374
1375 if (adapter->hw.mac_type == e1000_82573)
1376 E1000_WRITE_REG(&adapter->hw, ERT, 0x0100);
1377
1182 /* Enable Receives */ 1378 /* Enable Receives */
1183 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 1379 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
1184} 1380}
@@ -1210,13 +1406,11 @@ static inline void
1210e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter, 1406e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter,
1211 struct e1000_buffer *buffer_info) 1407 struct e1000_buffer *buffer_info)
1212{ 1408{
1213 struct pci_dev *pdev = adapter->pdev;
1214
1215 if(buffer_info->dma) { 1409 if(buffer_info->dma) {
1216 pci_unmap_page(pdev, 1410 pci_unmap_page(adapter->pdev,
1217 buffer_info->dma, 1411 buffer_info->dma,
1218 buffer_info->length, 1412 buffer_info->length,
1219 PCI_DMA_TODEVICE); 1413 PCI_DMA_TODEVICE);
1220 buffer_info->dma = 0; 1414 buffer_info->dma = 0;
1221 } 1415 }
1222 if(buffer_info->skb) { 1416 if(buffer_info->skb) {
@@ -1241,7 +1435,7 @@ e1000_clean_tx_ring(struct e1000_adapter *adapter)
1241 /* Free all the Tx ring sk_buffs */ 1435 /* Free all the Tx ring sk_buffs */
1242 1436
1243 if (likely(adapter->previous_buffer_info.skb != NULL)) { 1437 if (likely(adapter->previous_buffer_info.skb != NULL)) {
1244 e1000_unmap_and_free_tx_resource(adapter, 1438 e1000_unmap_and_free_tx_resource(adapter,
1245 &adapter->previous_buffer_info); 1439 &adapter->previous_buffer_info);
1246 } 1440 }
1247 1441
@@ -1281,6 +1475,10 @@ e1000_free_rx_resources(struct e1000_adapter *adapter)
1281 1475
1282 vfree(rx_ring->buffer_info); 1476 vfree(rx_ring->buffer_info);
1283 rx_ring->buffer_info = NULL; 1477 rx_ring->buffer_info = NULL;
1478 kfree(rx_ring->ps_page);
1479 rx_ring->ps_page = NULL;
1480 kfree(rx_ring->ps_page_dma);
1481 rx_ring->ps_page_dma = NULL;
1284 1482
1285 pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma); 1483 pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
1286 1484
@@ -1297,16 +1495,19 @@ e1000_clean_rx_ring(struct e1000_adapter *adapter)
1297{ 1495{
1298 struct e1000_desc_ring *rx_ring = &adapter->rx_ring; 1496 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
1299 struct e1000_buffer *buffer_info; 1497 struct e1000_buffer *buffer_info;
1498 struct e1000_ps_page *ps_page;
1499 struct e1000_ps_page_dma *ps_page_dma;
1300 struct pci_dev *pdev = adapter->pdev; 1500 struct pci_dev *pdev = adapter->pdev;
1301 unsigned long size; 1501 unsigned long size;
1302 unsigned int i; 1502 unsigned int i, j;
1303 1503
1304 /* Free all the Rx ring sk_buffs */ 1504 /* Free all the Rx ring sk_buffs */
1305 1505
1306 for(i = 0; i < rx_ring->count; i++) { 1506 for(i = 0; i < rx_ring->count; i++) {
1307 buffer_info = &rx_ring->buffer_info[i]; 1507 buffer_info = &rx_ring->buffer_info[i];
1308 if(buffer_info->skb) { 1508 if(buffer_info->skb) {
1309 1509 ps_page = &rx_ring->ps_page[i];
1510 ps_page_dma = &rx_ring->ps_page_dma[i];
1310 pci_unmap_single(pdev, 1511 pci_unmap_single(pdev,
1311 buffer_info->dma, 1512 buffer_info->dma,
1312 buffer_info->length, 1513 buffer_info->length,
@@ -1314,11 +1515,25 @@ e1000_clean_rx_ring(struct e1000_adapter *adapter)
1314 1515
1315 dev_kfree_skb(buffer_info->skb); 1516 dev_kfree_skb(buffer_info->skb);
1316 buffer_info->skb = NULL; 1517 buffer_info->skb = NULL;
1518
1519 for(j = 0; j < PS_PAGE_BUFFERS; j++) {
1520 if(!ps_page->ps_page[j]) break;
1521 pci_unmap_single(pdev,
1522 ps_page_dma->ps_page_dma[j],
1523 PAGE_SIZE, PCI_DMA_FROMDEVICE);
1524 ps_page_dma->ps_page_dma[j] = 0;
1525 put_page(ps_page->ps_page[j]);
1526 ps_page->ps_page[j] = NULL;
1527 }
1317 } 1528 }
1318 } 1529 }
1319 1530
1320 size = sizeof(struct e1000_buffer) * rx_ring->count; 1531 size = sizeof(struct e1000_buffer) * rx_ring->count;
1321 memset(rx_ring->buffer_info, 0, size); 1532 memset(rx_ring->buffer_info, 0, size);
1533 size = sizeof(struct e1000_ps_page) * rx_ring->count;
1534 memset(rx_ring->ps_page, 0, size);
1535 size = sizeof(struct e1000_ps_page_dma) * rx_ring->count;
1536 memset(rx_ring->ps_page_dma, 0, size);
1322 1537
1323 /* Zero out the descriptor ring */ 1538 /* Zero out the descriptor ring */
1324 1539
@@ -1422,15 +1637,15 @@ e1000_set_multi(struct net_device *netdev)
1422 struct e1000_adapter *adapter = netdev->priv; 1637 struct e1000_adapter *adapter = netdev->priv;
1423 struct e1000_hw *hw = &adapter->hw; 1638 struct e1000_hw *hw = &adapter->hw;
1424 struct dev_mc_list *mc_ptr; 1639 struct dev_mc_list *mc_ptr;
1640 unsigned long flags;
1425 uint32_t rctl; 1641 uint32_t rctl;
1426 uint32_t hash_value; 1642 uint32_t hash_value;
1427 int i; 1643 int i;
1428 unsigned long flags;
1429
1430 /* Check for Promiscuous and All Multicast modes */
1431 1644
1432 spin_lock_irqsave(&adapter->tx_lock, flags); 1645 spin_lock_irqsave(&adapter->tx_lock, flags);
1433 1646
1647 /* Check for Promiscuous and All Multicast modes */
1648
1434 rctl = E1000_READ_REG(hw, RCTL); 1649 rctl = E1000_READ_REG(hw, RCTL);
1435 1650
1436 if(netdev->flags & IFF_PROMISC) { 1651 if(netdev->flags & IFF_PROMISC) {
@@ -1556,6 +1771,11 @@ e1000_watchdog_task(struct e1000_adapter *adapter)
1556 uint32_t link; 1771 uint32_t link;
1557 1772
1558 e1000_check_for_link(&adapter->hw); 1773 e1000_check_for_link(&adapter->hw);
1774 if (adapter->hw.mac_type == e1000_82573) {
1775 e1000_enable_tx_pkt_filtering(&adapter->hw);
1776 if(adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id)
1777 e1000_update_mng_vlan(adapter);
1778 }
1559 1779
1560 if((adapter->hw.media_type == e1000_media_type_internal_serdes) && 1780 if((adapter->hw.media_type == e1000_media_type_internal_serdes) &&
1561 !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE)) 1781 !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE))
@@ -1632,7 +1852,7 @@ e1000_watchdog_task(struct e1000_adapter *adapter)
1632 /* Cause software interrupt to ensure rx ring is cleaned */ 1852 /* Cause software interrupt to ensure rx ring is cleaned */
1633 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0); 1853 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
1634 1854
1635 /* Force detection of hung controller every watchdog period*/ 1855 /* Force detection of hung controller every watchdog period */
1636 adapter->detect_tx_hung = TRUE; 1856 adapter->detect_tx_hung = TRUE;
1637 1857
1638 /* Reset the timer */ 1858 /* Reset the timer */
@@ -1642,6 +1862,7 @@ e1000_watchdog_task(struct e1000_adapter *adapter)
1642#define E1000_TX_FLAGS_CSUM 0x00000001 1862#define E1000_TX_FLAGS_CSUM 0x00000001
1643#define E1000_TX_FLAGS_VLAN 0x00000002 1863#define E1000_TX_FLAGS_VLAN 0x00000002
1644#define E1000_TX_FLAGS_TSO 0x00000004 1864#define E1000_TX_FLAGS_TSO 0x00000004
1865#define E1000_TX_FLAGS_IPV4 0x00000008
1645#define E1000_TX_FLAGS_VLAN_MASK 0xffff0000 1866#define E1000_TX_FLAGS_VLAN_MASK 0xffff0000
1646#define E1000_TX_FLAGS_VLAN_SHIFT 16 1867#define E1000_TX_FLAGS_VLAN_SHIFT 16
1647 1868
@@ -1652,7 +1873,7 @@ e1000_tso(struct e1000_adapter *adapter, struct sk_buff *skb)
1652 struct e1000_context_desc *context_desc; 1873 struct e1000_context_desc *context_desc;
1653 unsigned int i; 1874 unsigned int i;
1654 uint32_t cmd_length = 0; 1875 uint32_t cmd_length = 0;
1655 uint16_t ipcse, tucse, mss; 1876 uint16_t ipcse = 0, tucse, mss;
1656 uint8_t ipcss, ipcso, tucss, tucso, hdr_len; 1877 uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
1657 int err; 1878 int err;
1658 1879
@@ -1665,23 +1886,37 @@ e1000_tso(struct e1000_adapter *adapter, struct sk_buff *skb)
1665 1886
1666 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); 1887 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
1667 mss = skb_shinfo(skb)->tso_size; 1888 mss = skb_shinfo(skb)->tso_size;
1668 skb->nh.iph->tot_len = 0; 1889 if(skb->protocol == ntohs(ETH_P_IP)) {
1669 skb->nh.iph->check = 0; 1890 skb->nh.iph->tot_len = 0;
1670 skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr, 1891 skb->nh.iph->check = 0;
1671 skb->nh.iph->daddr, 1892 skb->h.th->check =
1672 0, 1893 ~csum_tcpudp_magic(skb->nh.iph->saddr,
1673 IPPROTO_TCP, 1894 skb->nh.iph->daddr,
1674 0); 1895 0,
1896 IPPROTO_TCP,
1897 0);
1898 cmd_length = E1000_TXD_CMD_IP;
1899 ipcse = skb->h.raw - skb->data - 1;
1900#ifdef NETIF_F_TSO_IPV6
1901 } else if(skb->protocol == ntohs(ETH_P_IPV6)) {
1902 skb->nh.ipv6h->payload_len = 0;
1903 skb->h.th->check =
1904 ~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
1905 &skb->nh.ipv6h->daddr,
1906 0,
1907 IPPROTO_TCP,
1908 0);
1909 ipcse = 0;
1910#endif
1911 }
1675 ipcss = skb->nh.raw - skb->data; 1912 ipcss = skb->nh.raw - skb->data;
1676 ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data; 1913 ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
1677 ipcse = skb->h.raw - skb->data - 1;
1678 tucss = skb->h.raw - skb->data; 1914 tucss = skb->h.raw - skb->data;
1679 tucso = (void *)&(skb->h.th->check) - (void *)skb->data; 1915 tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
1680 tucse = 0; 1916 tucse = 0;
1681 1917
1682 cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE | 1918 cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
1683 E1000_TXD_CMD_IP | E1000_TXD_CMD_TCP | 1919 E1000_TXD_CMD_TCP | (skb->len - (hdr_len)));
1684 (skb->len - (hdr_len)));
1685 1920
1686 i = adapter->tx_ring.next_to_use; 1921 i = adapter->tx_ring.next_to_use;
1687 context_desc = E1000_CONTEXT_DESC(adapter->tx_ring, i); 1922 context_desc = E1000_CONTEXT_DESC(adapter->tx_ring, i);
@@ -1760,6 +1995,15 @@ e1000_tx_map(struct e1000_adapter *adapter, struct sk_buff *skb,
1760 if(unlikely(mss && !nr_frags && size == len && size > 8)) 1995 if(unlikely(mss && !nr_frags && size == len && size > 8))
1761 size -= 4; 1996 size -= 4;
1762#endif 1997#endif
1998 /* work-around for errata 10 and it applies
1999 * to all controllers in PCI-X mode
2000 * The fix is to make sure that the first descriptor of a
2001 * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
2002 */
2003 if(unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) &&
2004 (size > 2015) && count == 0))
2005 size = 2015;
2006
1763 /* Workaround for potential 82544 hang in PCI-X. Avoid 2007 /* Workaround for potential 82544 hang in PCI-X. Avoid
1764 * terminating buffers within evenly-aligned dwords. */ 2008 * terminating buffers within evenly-aligned dwords. */
1765 if(unlikely(adapter->pcix_82544 && 2009 if(unlikely(adapter->pcix_82544 &&
@@ -1840,7 +2084,10 @@ e1000_tx_queue(struct e1000_adapter *adapter, int count, int tx_flags)
1840 if(likely(tx_flags & E1000_TX_FLAGS_TSO)) { 2084 if(likely(tx_flags & E1000_TX_FLAGS_TSO)) {
1841 txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D | 2085 txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
1842 E1000_TXD_CMD_TSE; 2086 E1000_TXD_CMD_TSE;
1843 txd_upper |= (E1000_TXD_POPTS_IXSM | E1000_TXD_POPTS_TXSM) << 8; 2087 txd_upper |= E1000_TXD_POPTS_TXSM << 8;
2088
2089 if(likely(tx_flags & E1000_TX_FLAGS_IPV4))
2090 txd_upper |= E1000_TXD_POPTS_IXSM << 8;
1844 } 2091 }
1845 2092
1846 if(likely(tx_flags & E1000_TX_FLAGS_CSUM)) { 2093 if(likely(tx_flags & E1000_TX_FLAGS_CSUM)) {
@@ -1915,6 +2162,53 @@ no_fifo_stall_required:
1915 return 0; 2162 return 0;
1916} 2163}
1917 2164
2165#define MINIMUM_DHCP_PACKET_SIZE 282
2166static inline int
2167e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)
2168{
2169 struct e1000_hw *hw = &adapter->hw;
2170 uint16_t length, offset;
2171 if(vlan_tx_tag_present(skb)) {
2172 if(!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
2173 ( adapter->hw.mng_cookie.status &
2174 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
2175 return 0;
2176 }
2177 if(htons(ETH_P_IP) == skb->protocol) {
2178 const struct iphdr *ip = skb->nh.iph;
2179 if(IPPROTO_UDP == ip->protocol) {
2180 struct udphdr *udp = (struct udphdr *)(skb->h.uh);
2181 if(ntohs(udp->dest) == 67) {
2182 offset = (uint8_t *)udp + 8 - skb->data;
2183 length = skb->len - offset;
2184
2185 return e1000_mng_write_dhcp_info(hw,
2186 (uint8_t *)udp + 8, length);
2187 }
2188 }
2189 } else if((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) {
2190 struct ethhdr *eth = (struct ethhdr *) skb->data;
2191 if((htons(ETH_P_IP) == eth->h_proto)) {
2192 const struct iphdr *ip =
2193 (struct iphdr *)((uint8_t *)skb->data+14);
2194 if(IPPROTO_UDP == ip->protocol) {
2195 struct udphdr *udp =
2196 (struct udphdr *)((uint8_t *)ip +
2197 (ip->ihl << 2));
2198 if(ntohs(udp->dest) == 67) {
2199 offset = (uint8_t *)udp + 8 - skb->data;
2200 length = skb->len - offset;
2201
2202 return e1000_mng_write_dhcp_info(hw,
2203 (uint8_t *)udp + 8,
2204 length);
2205 }
2206 }
2207 }
2208 }
2209 return 0;
2210}
2211
1918#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 ) 2212#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
1919static int 2213static int
1920e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) 2214e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
@@ -1939,7 +2233,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1939 2233
1940#ifdef NETIF_F_TSO 2234#ifdef NETIF_F_TSO
1941 mss = skb_shinfo(skb)->tso_size; 2235 mss = skb_shinfo(skb)->tso_size;
1942 /* The controller does a simple calculation to 2236 /* The controller does a simple calculation to
1943 * make sure there is enough room in the FIFO before 2237 * make sure there is enough room in the FIFO before
1944 * initiating the DMA for each buffer. The calc is: 2238 * initiating the DMA for each buffer. The calc is:
1945 * 4 = ceil(buffer len/mss). To make sure we don't 2239 * 4 = ceil(buffer len/mss). To make sure we don't
@@ -1952,7 +2246,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1952 2246
1953 if((mss) || (skb->ip_summed == CHECKSUM_HW)) 2247 if((mss) || (skb->ip_summed == CHECKSUM_HW))
1954 count++; 2248 count++;
1955 count++; /* for sentinel desc */ 2249 count++;
1956#else 2250#else
1957 if(skb->ip_summed == CHECKSUM_HW) 2251 if(skb->ip_summed == CHECKSUM_HW)
1958 count++; 2252 count++;
@@ -1962,6 +2256,13 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1962 if(adapter->pcix_82544) 2256 if(adapter->pcix_82544)
1963 count++; 2257 count++;
1964 2258
2259 /* work-around for errata 10 and it applies to all controllers
2260 * in PCI-X mode, so add one more descriptor to the count
2261 */
2262 if(unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) &&
2263 (len > 2015)))
2264 count++;
2265
1965 nr_frags = skb_shinfo(skb)->nr_frags; 2266 nr_frags = skb_shinfo(skb)->nr_frags;
1966 for(f = 0; f < nr_frags; f++) 2267 for(f = 0; f < nr_frags; f++)
1967 count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size, 2268 count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
@@ -1975,6 +2276,9 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1975 local_irq_restore(flags); 2276 local_irq_restore(flags);
1976 return NETDEV_TX_LOCKED; 2277 return NETDEV_TX_LOCKED;
1977 } 2278 }
2279 if(adapter->hw.tx_pkt_filtering && (adapter->hw.mac_type == e1000_82573) )
2280 e1000_transfer_dhcp_info(adapter, skb);
2281
1978 2282
1979 /* need: count + 2 desc gap to keep tail from touching 2283 /* need: count + 2 desc gap to keep tail from touching
1980 * head, otherwise try next time */ 2284 * head, otherwise try next time */
@@ -2011,6 +2315,12 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2011 else if(likely(e1000_tx_csum(adapter, skb))) 2315 else if(likely(e1000_tx_csum(adapter, skb)))
2012 tx_flags |= E1000_TX_FLAGS_CSUM; 2316 tx_flags |= E1000_TX_FLAGS_CSUM;
2013 2317
2318 /* Old method was to assume IPv4 packet by default if TSO was enabled.
2319 * 82573 hardware supports TSO capabilities for IPv6 as well...
2320 * no longer assume, we must. */
2321 if(likely(skb->protocol == ntohs(ETH_P_IP)))
2322 tx_flags |= E1000_TX_FLAGS_IPV4;
2323
2014 e1000_tx_queue(adapter, 2324 e1000_tx_queue(adapter,
2015 e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss), 2325 e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss),
2016 tx_flags); 2326 tx_flags);
@@ -2077,7 +2387,6 @@ static int
2077e1000_change_mtu(struct net_device *netdev, int new_mtu) 2387e1000_change_mtu(struct net_device *netdev, int new_mtu)
2078{ 2388{
2079 struct e1000_adapter *adapter = netdev->priv; 2389 struct e1000_adapter *adapter = netdev->priv;
2080 int old_mtu = adapter->rx_buffer_len;
2081 int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; 2390 int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
2082 2391
2083 if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) || 2392 if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
@@ -2086,29 +2395,45 @@ e1000_change_mtu(struct net_device *netdev, int new_mtu)
2086 return -EINVAL; 2395 return -EINVAL;
2087 } 2396 }
2088 2397
2089 if(max_frame <= MAXIMUM_ETHERNET_FRAME_SIZE) { 2398#define MAX_STD_JUMBO_FRAME_SIZE 9216
2090 adapter->rx_buffer_len = E1000_RXBUFFER_2048; 2399 /* might want this to be bigger enum check... */
2091 2400 if (adapter->hw.mac_type == e1000_82573 &&
2092 } else if(adapter->hw.mac_type < e1000_82543) { 2401 max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
2093 DPRINTK(PROBE, ERR, "Jumbo Frames not supported on 82542\n"); 2402 DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
2403 "on 82573\n");
2094 return -EINVAL; 2404 return -EINVAL;
2405 }
2095 2406
2096 } else if(max_frame <= E1000_RXBUFFER_4096) { 2407 if(adapter->hw.mac_type > e1000_82547_rev_2) {
2097 adapter->rx_buffer_len = E1000_RXBUFFER_4096; 2408 adapter->rx_buffer_len = max_frame;
2098 2409 E1000_ROUNDUP(adapter->rx_buffer_len, 1024);
2099 } else if(max_frame <= E1000_RXBUFFER_8192) {
2100 adapter->rx_buffer_len = E1000_RXBUFFER_8192;
2101
2102 } else { 2410 } else {
2103 adapter->rx_buffer_len = E1000_RXBUFFER_16384; 2411 if(unlikely((adapter->hw.mac_type < e1000_82543) &&
2412 (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE))) {
2413 DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
2414 "on 82542\n");
2415 return -EINVAL;
2416
2417 } else {
2418 if(max_frame <= E1000_RXBUFFER_2048) {
2419 adapter->rx_buffer_len = E1000_RXBUFFER_2048;
2420 } else if(max_frame <= E1000_RXBUFFER_4096) {
2421 adapter->rx_buffer_len = E1000_RXBUFFER_4096;
2422 } else if(max_frame <= E1000_RXBUFFER_8192) {
2423 adapter->rx_buffer_len = E1000_RXBUFFER_8192;
2424 } else if(max_frame <= E1000_RXBUFFER_16384) {
2425 adapter->rx_buffer_len = E1000_RXBUFFER_16384;
2426 }
2427 }
2104 } 2428 }
2105 2429
2106 if(old_mtu != adapter->rx_buffer_len && netif_running(netdev)) { 2430 netdev->mtu = new_mtu;
2431
2432 if(netif_running(netdev)) {
2107 e1000_down(adapter); 2433 e1000_down(adapter);
2108 e1000_up(adapter); 2434 e1000_up(adapter);
2109 } 2435 }
2110 2436
2111 netdev->mtu = new_mtu;
2112 adapter->hw.max_frame_size = max_frame; 2437 adapter->hw.max_frame_size = max_frame;
2113 2438
2114 return 0; 2439 return 0;
@@ -2199,6 +2524,17 @@ e1000_update_stats(struct e1000_adapter *adapter)
2199 adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC); 2524 adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC);
2200 adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC); 2525 adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC);
2201 } 2526 }
2527 if(hw->mac_type > e1000_82547_rev_2) {
2528 adapter->stats.iac += E1000_READ_REG(hw, IAC);
2529 adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
2530 adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
2531 adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
2532 adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
2533 adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
2534 adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
2535 adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
2536 adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
2537 }
2202 2538
2203 /* Fill out the OS statistics structure */ 2539 /* Fill out the OS statistics structure */
2204 2540
@@ -2213,9 +2549,9 @@ e1000_update_stats(struct e1000_adapter *adapter)
2213 2549
2214 adapter->net_stats.rx_errors = adapter->stats.rxerrc + 2550 adapter->net_stats.rx_errors = adapter->stats.rxerrc +
2215 adapter->stats.crcerrs + adapter->stats.algnerrc + 2551 adapter->stats.crcerrs + adapter->stats.algnerrc +
2216 adapter->stats.rlec + adapter->stats.rnbc + 2552 adapter->stats.rlec + adapter->stats.mpc +
2217 adapter->stats.mpc + adapter->stats.cexterr; 2553 adapter->stats.cexterr;
2218 adapter->net_stats.rx_dropped = adapter->stats.rnbc; 2554 adapter->net_stats.rx_dropped = adapter->stats.mpc;
2219 adapter->net_stats.rx_length_errors = adapter->stats.rlec; 2555 adapter->net_stats.rx_length_errors = adapter->stats.rlec;
2220 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs; 2556 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
2221 adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc; 2557 adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
@@ -2300,11 +2636,11 @@ e1000_intr(int irq, void *data, struct pt_regs *regs)
2300 */ 2636 */
2301 if(hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2){ 2637 if(hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2){
2302 atomic_inc(&adapter->irq_sem); 2638 atomic_inc(&adapter->irq_sem);
2303 E1000_WRITE_REG(&adapter->hw, IMC, ~0); 2639 E1000_WRITE_REG(hw, IMC, ~0);
2304 } 2640 }
2305 2641
2306 for(i = 0; i < E1000_MAX_INTR; i++) 2642 for(i = 0; i < E1000_MAX_INTR; i++)
2307 if(unlikely(!e1000_clean_rx_irq(adapter) & 2643 if(unlikely(!adapter->clean_rx(adapter) &
2308 !e1000_clean_tx_irq(adapter))) 2644 !e1000_clean_tx_irq(adapter)))
2309 break; 2645 break;
2310 2646
@@ -2328,16 +2664,15 @@ e1000_clean(struct net_device *netdev, int *budget)
2328 int work_to_do = min(*budget, netdev->quota); 2664 int work_to_do = min(*budget, netdev->quota);
2329 int tx_cleaned; 2665 int tx_cleaned;
2330 int work_done = 0; 2666 int work_done = 0;
2331 2667
2332 tx_cleaned = e1000_clean_tx_irq(adapter); 2668 tx_cleaned = e1000_clean_tx_irq(adapter);
2333 e1000_clean_rx_irq(adapter, &work_done, work_to_do); 2669 adapter->clean_rx(adapter, &work_done, work_to_do);
2334 2670
2335 *budget -= work_done; 2671 *budget -= work_done;
2336 netdev->quota -= work_done; 2672 netdev->quota -= work_done;
2337 2673
2338 /* if no Tx and not enough Rx work done, exit the polling mode */ 2674 /* If no Tx and no Rx work done, exit the polling mode */
2339 if((!tx_cleaned && (work_done < work_to_do)) || 2675 if ((!tx_cleaned && (work_done == 0)) || !netif_running(netdev)) {
2340 !netif_running(netdev)) {
2341 netif_rx_complete(netdev); 2676 netif_rx_complete(netdev);
2342 e1000_irq_enable(adapter); 2677 e1000_irq_enable(adapter);
2343 return 0; 2678 return 0;
@@ -2367,11 +2702,10 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
2367 eop_desc = E1000_TX_DESC(*tx_ring, eop); 2702 eop_desc = E1000_TX_DESC(*tx_ring, eop);
2368 2703
2369 while(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) { 2704 while(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
2370 /* pre-mature writeback of Tx descriptors */ 2705 /* Premature writeback of Tx descriptors clear (free buffers
2371 /* clear (free buffers and unmap pci_mapping) */ 2706 * and unmap pci_mapping) previous_buffer_info */
2372 /* previous_buffer_info */
2373 if (likely(adapter->previous_buffer_info.skb != NULL)) { 2707 if (likely(adapter->previous_buffer_info.skb != NULL)) {
2374 e1000_unmap_and_free_tx_resource(adapter, 2708 e1000_unmap_and_free_tx_resource(adapter,
2375 &adapter->previous_buffer_info); 2709 &adapter->previous_buffer_info);
2376 } 2710 }
2377 2711
@@ -2380,26 +2714,30 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
2380 buffer_info = &tx_ring->buffer_info[i]; 2714 buffer_info = &tx_ring->buffer_info[i];
2381 cleaned = (i == eop); 2715 cleaned = (i == eop);
2382 2716
2383 /* pre-mature writeback of Tx descriptors */ 2717#ifdef NETIF_F_TSO
2384 /* save the cleaning of the this for the */ 2718 if (!(netdev->features & NETIF_F_TSO)) {
2385 /* next iteration */ 2719#endif
2386 if (cleaned) { 2720 e1000_unmap_and_free_tx_resource(adapter,
2387 memcpy(&adapter->previous_buffer_info, 2721 buffer_info);
2388 buffer_info, 2722#ifdef NETIF_F_TSO
2389 sizeof(struct e1000_buffer));
2390 memset(buffer_info,
2391 0,
2392 sizeof(struct e1000_buffer));
2393 } else { 2723 } else {
2394 e1000_unmap_and_free_tx_resource(adapter, 2724 if (cleaned) {
2395 buffer_info); 2725 memcpy(&adapter->previous_buffer_info,
2726 buffer_info,
2727 sizeof(struct e1000_buffer));
2728 memset(buffer_info, 0,
2729 sizeof(struct e1000_buffer));
2730 } else {
2731 e1000_unmap_and_free_tx_resource(
2732 adapter, buffer_info);
2733 }
2396 } 2734 }
2735#endif
2397 2736
2398 tx_desc->buffer_addr = 0; 2737 tx_desc->buffer_addr = 0;
2399 tx_desc->lower.data = 0; 2738 tx_desc->lower.data = 0;
2400 tx_desc->upper.data = 0; 2739 tx_desc->upper.data = 0;
2401 2740
2402 cleaned = (i == eop);
2403 if(unlikely(++i == tx_ring->count)) i = 0; 2741 if(unlikely(++i == tx_ring->count)) i = 0;
2404 } 2742 }
2405 2743
@@ -2416,57 +2754,107 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
2416 netif_wake_queue(netdev); 2754 netif_wake_queue(netdev);
2417 2755
2418 spin_unlock(&adapter->tx_lock); 2756 spin_unlock(&adapter->tx_lock);
2419
2420 if(adapter->detect_tx_hung) { 2757 if(adapter->detect_tx_hung) {
2421 /* detect a transmit hang in hardware, this serializes the 2758
2759 /* Detect a transmit hang in hardware, this serializes the
2422 * check with the clearing of time_stamp and movement of i */ 2760 * check with the clearing of time_stamp and movement of i */
2423 adapter->detect_tx_hung = FALSE; 2761 adapter->detect_tx_hung = FALSE;
2424 if(tx_ring->buffer_info[i].dma && 2762 if (tx_ring->buffer_info[i].dma &&
2425 time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ) && 2763 time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ)
2426 !(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_TXOFF)) 2764 && !(E1000_READ_REG(&adapter->hw, STATUS) &
2765 E1000_STATUS_TXOFF)) {
2766
2767 /* detected Tx unit hang */
2768 i = tx_ring->next_to_clean;
2769 eop = tx_ring->buffer_info[i].next_to_watch;
2770 eop_desc = E1000_TX_DESC(*tx_ring, eop);
2771 DPRINTK(TX_ERR, ERR, "Detected Tx Unit Hang\n"
2772 " TDH <%x>\n"
2773 " TDT <%x>\n"
2774 " next_to_use <%x>\n"
2775 " next_to_clean <%x>\n"
2776 "buffer_info[next_to_clean]\n"
2777 " dma <%llx>\n"
2778 " time_stamp <%lx>\n"
2779 " next_to_watch <%x>\n"
2780 " jiffies <%lx>\n"
2781 " next_to_watch.status <%x>\n",
2782 E1000_READ_REG(&adapter->hw, TDH),
2783 E1000_READ_REG(&adapter->hw, TDT),
2784 tx_ring->next_to_use,
2785 i,
2786 tx_ring->buffer_info[i].dma,
2787 tx_ring->buffer_info[i].time_stamp,
2788 eop,
2789 jiffies,
2790 eop_desc->upper.fields.status);
2427 netif_stop_queue(netdev); 2791 netif_stop_queue(netdev);
2792 }
2428 } 2793 }
2794#ifdef NETIF_F_TSO
2795
2796 if( unlikely(!(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
2797 time_after(jiffies, adapter->previous_buffer_info.time_stamp + HZ)))
2798 e1000_unmap_and_free_tx_resource(
2799 adapter, &adapter->previous_buffer_info);
2429 2800
2801#endif
2430 return cleaned; 2802 return cleaned;
2431} 2803}
2432 2804
2433/** 2805/**
2434 * e1000_rx_checksum - Receive Checksum Offload for 82543 2806 * e1000_rx_checksum - Receive Checksum Offload for 82543
2435 * @adapter: board private structure 2807 * @adapter: board private structure
2436 * @rx_desc: receive descriptor 2808 * @status_err: receive descriptor status and error fields
2437 * @sk_buff: socket buffer with received data 2809 * @csum: receive descriptor csum field
2810 * @sk_buff: socket buffer with received data
2438 **/ 2811 **/
2439 2812
2440static inline void 2813static inline void
2441e1000_rx_checksum(struct e1000_adapter *adapter, 2814e1000_rx_checksum(struct e1000_adapter *adapter,
2442 struct e1000_rx_desc *rx_desc, 2815 uint32_t status_err, uint32_t csum,
2443 struct sk_buff *skb) 2816 struct sk_buff *skb)
2444{ 2817{
2818 uint16_t status = (uint16_t)status_err;
2819 uint8_t errors = (uint8_t)(status_err >> 24);
2820 skb->ip_summed = CHECKSUM_NONE;
2821
2445 /* 82543 or newer only */ 2822 /* 82543 or newer only */
2446 if(unlikely((adapter->hw.mac_type < e1000_82543) || 2823 if(unlikely(adapter->hw.mac_type < e1000_82543)) return;
2447 /* Ignore Checksum bit is set */ 2824 /* Ignore Checksum bit is set */
2448 (rx_desc->status & E1000_RXD_STAT_IXSM) || 2825 if(unlikely(status & E1000_RXD_STAT_IXSM)) return;
2449 /* TCP Checksum has not been calculated */ 2826 /* TCP/UDP checksum error bit is set */
2450 (!(rx_desc->status & E1000_RXD_STAT_TCPCS)))) { 2827 if(unlikely(errors & E1000_RXD_ERR_TCPE)) {
2451 skb->ip_summed = CHECKSUM_NONE;
2452 return;
2453 }
2454
2455 /* At this point we know the hardware did the TCP checksum */
2456 /* now look at the TCP checksum error bit */
2457 if(rx_desc->errors & E1000_RXD_ERR_TCPE) {
2458 /* let the stack verify checksum errors */ 2828 /* let the stack verify checksum errors */
2459 skb->ip_summed = CHECKSUM_NONE;
2460 adapter->hw_csum_err++; 2829 adapter->hw_csum_err++;
2830 return;
2831 }
2832 /* TCP/UDP Checksum has not been calculated */
2833 if(adapter->hw.mac_type <= e1000_82547_rev_2) {
2834 if(!(status & E1000_RXD_STAT_TCPCS))
2835 return;
2461 } else { 2836 } else {
2837 if(!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
2838 return;
2839 }
2840 /* It must be a TCP or UDP packet with a valid checksum */
2841 if (likely(status & E1000_RXD_STAT_TCPCS)) {
2462 /* TCP checksum is good */ 2842 /* TCP checksum is good */
2463 skb->ip_summed = CHECKSUM_UNNECESSARY; 2843 skb->ip_summed = CHECKSUM_UNNECESSARY;
2464 adapter->hw_csum_good++; 2844 } else if (adapter->hw.mac_type > e1000_82547_rev_2) {
2845 /* IP fragment with UDP payload */
2846 /* Hardware complements the payload checksum, so we undo it
2847 * and then put the value in host order for further stack use.
2848 */
2849 csum = ntohl(csum ^ 0xFFFF);
2850 skb->csum = csum;
2851 skb->ip_summed = CHECKSUM_HW;
2465 } 2852 }
2853 adapter->hw_csum_good++;
2466} 2854}
2467 2855
2468/** 2856/**
2469 * e1000_clean_rx_irq - Send received data up the network stack 2857 * e1000_clean_rx_irq - Send received data up the network stack; legacy
2470 * @adapter: board private structure 2858 * @adapter: board private structure
2471 **/ 2859 **/
2472 2860
@@ -2513,7 +2901,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter)
2513 if(unlikely(!(rx_desc->status & E1000_RXD_STAT_EOP))) { 2901 if(unlikely(!(rx_desc->status & E1000_RXD_STAT_EOP))) {
2514 /* All receives must fit into a single buffer */ 2902 /* All receives must fit into a single buffer */
2515 E1000_DBG("%s: Receive packet consumed multiple" 2903 E1000_DBG("%s: Receive packet consumed multiple"
2516 " buffers\n", netdev->name); 2904 " buffers\n", netdev->name);
2517 dev_kfree_skb_irq(skb); 2905 dev_kfree_skb_irq(skb);
2518 goto next_desc; 2906 goto next_desc;
2519 } 2907 }
@@ -2539,15 +2927,17 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter)
2539 skb_put(skb, length - ETHERNET_FCS_SIZE); 2927 skb_put(skb, length - ETHERNET_FCS_SIZE);
2540 2928
2541 /* Receive Checksum Offload */ 2929 /* Receive Checksum Offload */
2542 e1000_rx_checksum(adapter, rx_desc, skb); 2930 e1000_rx_checksum(adapter,
2543 2931 (uint32_t)(rx_desc->status) |
2932 ((uint32_t)(rx_desc->errors) << 24),
2933 rx_desc->csum, skb);
2544 skb->protocol = eth_type_trans(skb, netdev); 2934 skb->protocol = eth_type_trans(skb, netdev);
2545#ifdef CONFIG_E1000_NAPI 2935#ifdef CONFIG_E1000_NAPI
2546 if(unlikely(adapter->vlgrp && 2936 if(unlikely(adapter->vlgrp &&
2547 (rx_desc->status & E1000_RXD_STAT_VP))) { 2937 (rx_desc->status & E1000_RXD_STAT_VP))) {
2548 vlan_hwaccel_receive_skb(skb, adapter->vlgrp, 2938 vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
2549 le16_to_cpu(rx_desc->special) & 2939 le16_to_cpu(rx_desc->special) &
2550 E1000_RXD_SPC_VLAN_MASK); 2940 E1000_RXD_SPC_VLAN_MASK);
2551 } else { 2941 } else {
2552 netif_receive_skb(skb); 2942 netif_receive_skb(skb);
2553 } 2943 }
@@ -2570,16 +2960,142 @@ next_desc:
2570 2960
2571 rx_desc = E1000_RX_DESC(*rx_ring, i); 2961 rx_desc = E1000_RX_DESC(*rx_ring, i);
2572 } 2962 }
2573
2574 rx_ring->next_to_clean = i; 2963 rx_ring->next_to_clean = i;
2964 adapter->alloc_rx_buf(adapter);
2965
2966 return cleaned;
2967}
2968
2969/**
2970 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
2971 * @adapter: board private structure
2972 **/
2973
2974static boolean_t
2975#ifdef CONFIG_E1000_NAPI
2976e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, int *work_done,
2977 int work_to_do)
2978#else
2979e1000_clean_rx_irq_ps(struct e1000_adapter *adapter)
2980#endif
2981{
2982 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
2983 union e1000_rx_desc_packet_split *rx_desc;
2984 struct net_device *netdev = adapter->netdev;
2985 struct pci_dev *pdev = adapter->pdev;
2986 struct e1000_buffer *buffer_info;
2987 struct e1000_ps_page *ps_page;
2988 struct e1000_ps_page_dma *ps_page_dma;
2989 struct sk_buff *skb;
2990 unsigned int i, j;
2991 uint32_t length, staterr;
2992 boolean_t cleaned = FALSE;
2993
2994 i = rx_ring->next_to_clean;
2995 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
2996 staterr = rx_desc->wb.middle.status_error;
2997
2998 while(staterr & E1000_RXD_STAT_DD) {
2999 buffer_info = &rx_ring->buffer_info[i];
3000 ps_page = &rx_ring->ps_page[i];
3001 ps_page_dma = &rx_ring->ps_page_dma[i];
3002#ifdef CONFIG_E1000_NAPI
3003 if(unlikely(*work_done >= work_to_do))
3004 break;
3005 (*work_done)++;
3006#endif
3007 cleaned = TRUE;
3008 pci_unmap_single(pdev, buffer_info->dma,
3009 buffer_info->length,
3010 PCI_DMA_FROMDEVICE);
3011
3012 skb = buffer_info->skb;
3013
3014 if(unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
3015 E1000_DBG("%s: Packet Split buffers didn't pick up"
3016 " the full packet\n", netdev->name);
3017 dev_kfree_skb_irq(skb);
3018 goto next_desc;
3019 }
3020
3021 if(unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
3022 dev_kfree_skb_irq(skb);
3023 goto next_desc;
3024 }
3025
3026 length = le16_to_cpu(rx_desc->wb.middle.length0);
3027
3028 if(unlikely(!length)) {
3029 E1000_DBG("%s: Last part of the packet spanning"
3030 " multiple descriptors\n", netdev->name);
3031 dev_kfree_skb_irq(skb);
3032 goto next_desc;
3033 }
3034
3035 /* Good Receive */
3036 skb_put(skb, length);
3037
3038 for(j = 0; j < PS_PAGE_BUFFERS; j++) {
3039 if(!(length = le16_to_cpu(rx_desc->wb.upper.length[j])))
3040 break;
3041
3042 pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
3043 PAGE_SIZE, PCI_DMA_FROMDEVICE);
3044 ps_page_dma->ps_page_dma[j] = 0;
3045 skb_shinfo(skb)->frags[j].page =
3046 ps_page->ps_page[j];
3047 ps_page->ps_page[j] = NULL;
3048 skb_shinfo(skb)->frags[j].page_offset = 0;
3049 skb_shinfo(skb)->frags[j].size = length;
3050 skb_shinfo(skb)->nr_frags++;
3051 skb->len += length;
3052 skb->data_len += length;
3053 }
2575 3054
2576 e1000_alloc_rx_buffers(adapter); 3055 e1000_rx_checksum(adapter, staterr,
3056 rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
3057 skb->protocol = eth_type_trans(skb, netdev);
3058
3059#ifdef HAVE_RX_ZERO_COPY
3060 if(likely(rx_desc->wb.upper.header_status &
3061 E1000_RXDPS_HDRSTAT_HDRSP))
3062 skb_shinfo(skb)->zero_copy = TRUE;
3063#endif
3064#ifdef CONFIG_E1000_NAPI
3065 if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
3066 vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
3067 le16_to_cpu(rx_desc->wb.middle.vlan &
3068 E1000_RXD_SPC_VLAN_MASK));
3069 } else {
3070 netif_receive_skb(skb);
3071 }
3072#else /* CONFIG_E1000_NAPI */
3073 if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
3074 vlan_hwaccel_rx(skb, adapter->vlgrp,
3075 le16_to_cpu(rx_desc->wb.middle.vlan &
3076 E1000_RXD_SPC_VLAN_MASK));
3077 } else {
3078 netif_rx(skb);
3079 }
3080#endif /* CONFIG_E1000_NAPI */
3081 netdev->last_rx = jiffies;
3082
3083next_desc:
3084 rx_desc->wb.middle.status_error &= ~0xFF;
3085 buffer_info->skb = NULL;
3086 if(unlikely(++i == rx_ring->count)) i = 0;
3087
3088 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
3089 staterr = rx_desc->wb.middle.status_error;
3090 }
3091 rx_ring->next_to_clean = i;
3092 adapter->alloc_rx_buf(adapter);
2577 3093
2578 return cleaned; 3094 return cleaned;
2579} 3095}
2580 3096
2581/** 3097/**
2582 * e1000_alloc_rx_buffers - Replace used receive buffers 3098 * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended
2583 * @adapter: address of board private structure 3099 * @adapter: address of board private structure
2584 **/ 3100 **/
2585 3101
@@ -2592,43 +3108,43 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter)
2592 struct e1000_rx_desc *rx_desc; 3108 struct e1000_rx_desc *rx_desc;
2593 struct e1000_buffer *buffer_info; 3109 struct e1000_buffer *buffer_info;
2594 struct sk_buff *skb; 3110 struct sk_buff *skb;
2595 unsigned int i, bufsz; 3111 unsigned int i;
3112 unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
2596 3113
2597 i = rx_ring->next_to_use; 3114 i = rx_ring->next_to_use;
2598 buffer_info = &rx_ring->buffer_info[i]; 3115 buffer_info = &rx_ring->buffer_info[i];
2599 3116
2600 while(!buffer_info->skb) { 3117 while(!buffer_info->skb) {
2601 bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
2602
2603 skb = dev_alloc_skb(bufsz); 3118 skb = dev_alloc_skb(bufsz);
3119
2604 if(unlikely(!skb)) { 3120 if(unlikely(!skb)) {
2605 /* Better luck next round */ 3121 /* Better luck next round */
2606 break; 3122 break;
2607 } 3123 }
2608 3124
2609 /* fix for errata 23, cant cross 64kB boundary */ 3125 /* Fix for errata 23, can't cross 64kB boundary */
2610 if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) { 3126 if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) {
2611 struct sk_buff *oldskb = skb; 3127 struct sk_buff *oldskb = skb;
2612 DPRINTK(RX_ERR,ERR, 3128 DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes "
2613 "skb align check failed: %u bytes at %p\n", 3129 "at %p\n", bufsz, skb->data);
2614 bufsz, skb->data); 3130 /* Try again, without freeing the previous */
2615 /* try again, without freeing the previous */
2616 skb = dev_alloc_skb(bufsz); 3131 skb = dev_alloc_skb(bufsz);
3132 /* Failed allocation, critical failure */
2617 if (!skb) { 3133 if (!skb) {
2618 dev_kfree_skb(oldskb); 3134 dev_kfree_skb(oldskb);
2619 break; 3135 break;
2620 } 3136 }
3137
2621 if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) { 3138 if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) {
2622 /* give up */ 3139 /* give up */
2623 dev_kfree_skb(skb); 3140 dev_kfree_skb(skb);
2624 dev_kfree_skb(oldskb); 3141 dev_kfree_skb(oldskb);
2625 break; /* while !buffer_info->skb */ 3142 break; /* while !buffer_info->skb */
2626 } else { 3143 } else {
2627 /* move on with the new one */ 3144 /* Use new allocation */
2628 dev_kfree_skb(oldskb); 3145 dev_kfree_skb(oldskb);
2629 } 3146 }
2630 } 3147 }
2631
2632 /* Make buffer alignment 2 beyond a 16 byte boundary 3148 /* Make buffer alignment 2 beyond a 16 byte boundary
2633 * this will result in a 16 byte aligned IP header after 3149 * this will result in a 16 byte aligned IP header after
2634 * the 14 byte MAC header is removed 3150 * the 14 byte MAC header is removed
@@ -2644,25 +3160,23 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter)
2644 adapter->rx_buffer_len, 3160 adapter->rx_buffer_len,
2645 PCI_DMA_FROMDEVICE); 3161 PCI_DMA_FROMDEVICE);
2646 3162
2647 /* fix for errata 23, cant cross 64kB boundary */ 3163 /* Fix for errata 23, can't cross 64kB boundary */
2648 if(!e1000_check_64k_bound(adapter, 3164 if (!e1000_check_64k_bound(adapter,
2649 (void *)(unsigned long)buffer_info->dma, 3165 (void *)(unsigned long)buffer_info->dma,
2650 adapter->rx_buffer_len)) { 3166 adapter->rx_buffer_len)) {
2651 DPRINTK(RX_ERR,ERR, 3167 DPRINTK(RX_ERR, ERR,
2652 "dma align check failed: %u bytes at %ld\n", 3168 "dma align check failed: %u bytes at %p\n",
2653 adapter->rx_buffer_len, (unsigned long)buffer_info->dma); 3169 adapter->rx_buffer_len,
2654 3170 (void *)(unsigned long)buffer_info->dma);
2655 dev_kfree_skb(skb); 3171 dev_kfree_skb(skb);
2656 buffer_info->skb = NULL; 3172 buffer_info->skb = NULL;
2657 3173
2658 pci_unmap_single(pdev, 3174 pci_unmap_single(pdev, buffer_info->dma,
2659 buffer_info->dma,
2660 adapter->rx_buffer_len, 3175 adapter->rx_buffer_len,
2661 PCI_DMA_FROMDEVICE); 3176 PCI_DMA_FROMDEVICE);
2662 3177
2663 break; /* while !buffer_info->skb */ 3178 break; /* while !buffer_info->skb */
2664 } 3179 }
2665
2666 rx_desc = E1000_RX_DESC(*rx_ring, i); 3180 rx_desc = E1000_RX_DESC(*rx_ring, i);
2667 rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); 3181 rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
2668 3182
@@ -2672,7 +3186,6 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter)
2672 * applicable for weak-ordered memory model archs, 3186 * applicable for weak-ordered memory model archs,
2673 * such as IA-64). */ 3187 * such as IA-64). */
2674 wmb(); 3188 wmb();
2675
2676 E1000_WRITE_REG(&adapter->hw, RDT, i); 3189 E1000_WRITE_REG(&adapter->hw, RDT, i);
2677 } 3190 }
2678 3191
@@ -2684,6 +3197,95 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter)
2684} 3197}
2685 3198
2686/** 3199/**
3200 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
3201 * @adapter: address of board private structure
3202 **/
3203
3204static void
3205e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter)
3206{
3207 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
3208 struct net_device *netdev = adapter->netdev;
3209 struct pci_dev *pdev = adapter->pdev;
3210 union e1000_rx_desc_packet_split *rx_desc;
3211 struct e1000_buffer *buffer_info;
3212 struct e1000_ps_page *ps_page;
3213 struct e1000_ps_page_dma *ps_page_dma;
3214 struct sk_buff *skb;
3215 unsigned int i, j;
3216
3217 i = rx_ring->next_to_use;
3218 buffer_info = &rx_ring->buffer_info[i];
3219 ps_page = &rx_ring->ps_page[i];
3220 ps_page_dma = &rx_ring->ps_page_dma[i];
3221
3222 while(!buffer_info->skb) {
3223 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
3224
3225 for(j = 0; j < PS_PAGE_BUFFERS; j++) {
3226 if(unlikely(!ps_page->ps_page[j])) {
3227 ps_page->ps_page[j] =
3228 alloc_page(GFP_ATOMIC);
3229 if(unlikely(!ps_page->ps_page[j]))
3230 goto no_buffers;
3231 ps_page_dma->ps_page_dma[j] =
3232 pci_map_page(pdev,
3233 ps_page->ps_page[j],
3234 0, PAGE_SIZE,
3235 PCI_DMA_FROMDEVICE);
3236 }
3237 /* Refresh the desc even if buffer_addrs didn't
3238 * change because each write-back erases this info.
3239 */
3240 rx_desc->read.buffer_addr[j+1] =
3241 cpu_to_le64(ps_page_dma->ps_page_dma[j]);
3242 }
3243
3244 skb = dev_alloc_skb(adapter->rx_ps_bsize0 + NET_IP_ALIGN);
3245
3246 if(unlikely(!skb))
3247 break;
3248
3249 /* Make buffer alignment 2 beyond a 16 byte boundary
3250 * this will result in a 16 byte aligned IP header after
3251 * the 14 byte MAC header is removed
3252 */
3253 skb_reserve(skb, NET_IP_ALIGN);
3254
3255 skb->dev = netdev;
3256
3257 buffer_info->skb = skb;
3258 buffer_info->length = adapter->rx_ps_bsize0;
3259 buffer_info->dma = pci_map_single(pdev, skb->data,
3260 adapter->rx_ps_bsize0,
3261 PCI_DMA_FROMDEVICE);
3262
3263 rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
3264
3265 if(unlikely((i & ~(E1000_RX_BUFFER_WRITE - 1)) == i)) {
3266 /* Force memory writes to complete before letting h/w
3267 * know there are new descriptors to fetch. (Only
3268 * applicable for weak-ordered memory model archs,
3269 * such as IA-64). */
3270 wmb();
3271 /* Hardware increments by 16 bytes, but packet split
3272 * descriptors are 32 bytes...so we increment tail
3273 * twice as much.
3274 */
3275 E1000_WRITE_REG(&adapter->hw, RDT, i<<1);
3276 }
3277
3278 if(unlikely(++i == rx_ring->count)) i = 0;
3279 buffer_info = &rx_ring->buffer_info[i];
3280 ps_page = &rx_ring->ps_page[i];
3281 ps_page_dma = &rx_ring->ps_page_dma[i];
3282 }
3283
3284no_buffers:
3285 rx_ring->next_to_use = i;
3286}
3287
3288/**
2687 * e1000_smartspeed - Workaround for SmartSpeed on 82541 and 82547 controllers. 3289 * e1000_smartspeed - Workaround for SmartSpeed on 82541 and 82547 controllers.
2688 * @adapter: 3290 * @adapter:
2689 **/ 3291 **/
@@ -2856,9 +3458,10 @@ void
2856e1000_pci_set_mwi(struct e1000_hw *hw) 3458e1000_pci_set_mwi(struct e1000_hw *hw)
2857{ 3459{
2858 struct e1000_adapter *adapter = hw->back; 3460 struct e1000_adapter *adapter = hw->back;
3461 int ret_val = pci_set_mwi(adapter->pdev);
2859 3462
2860 int ret; 3463 if(ret_val)
2861 ret = pci_set_mwi(adapter->pdev); 3464 DPRINTK(PROBE, ERR, "Error in setting MWI\n");
2862} 3465}
2863 3466
2864void 3467void
@@ -2917,6 +3520,7 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
2917 rctl |= E1000_RCTL_VFE; 3520 rctl |= E1000_RCTL_VFE;
2918 rctl &= ~E1000_RCTL_CFIEN; 3521 rctl &= ~E1000_RCTL_CFIEN;
2919 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 3522 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
3523 e1000_update_mng_vlan(adapter);
2920 } else { 3524 } else {
2921 /* disable VLAN tag insert/strip */ 3525 /* disable VLAN tag insert/strip */
2922 ctrl = E1000_READ_REG(&adapter->hw, CTRL); 3526 ctrl = E1000_READ_REG(&adapter->hw, CTRL);
@@ -2927,6 +3531,10 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
2927 rctl = E1000_READ_REG(&adapter->hw, RCTL); 3531 rctl = E1000_READ_REG(&adapter->hw, RCTL);
2928 rctl &= ~E1000_RCTL_VFE; 3532 rctl &= ~E1000_RCTL_VFE;
2929 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 3533 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
3534 if(adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) {
3535 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
3536 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
3537 }
2930 } 3538 }
2931 3539
2932 e1000_irq_enable(adapter); 3540 e1000_irq_enable(adapter);
@@ -2937,7 +3545,10 @@ e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
2937{ 3545{
2938 struct e1000_adapter *adapter = netdev->priv; 3546 struct e1000_adapter *adapter = netdev->priv;
2939 uint32_t vfta, index; 3547 uint32_t vfta, index;
2940 3548 if((adapter->hw.mng_cookie.status &
3549 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
3550 (vid == adapter->mng_vlan_id))
3551 return;
2941 /* add VID to filter table */ 3552 /* add VID to filter table */
2942 index = (vid >> 5) & 0x7F; 3553 index = (vid >> 5) & 0x7F;
2943 vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index); 3554 vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
@@ -2958,6 +3569,10 @@ e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
2958 3569
2959 e1000_irq_enable(adapter); 3570 e1000_irq_enable(adapter);
2960 3571
3572 if((adapter->hw.mng_cookie.status &
3573 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
3574 (vid == adapter->mng_vlan_id))
3575 return;
2961 /* remove VID from filter table */ 3576 /* remove VID from filter table */
2962 index = (vid >> 5) & 0x7F; 3577 index = (vid >> 5) & 0x7F;
2963 vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index); 3578 vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
@@ -3004,8 +3619,7 @@ e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx)
3004 break; 3619 break;
3005 case SPEED_1000 + DUPLEX_HALF: /* not supported */ 3620 case SPEED_1000 + DUPLEX_HALF: /* not supported */
3006 default: 3621 default:
3007 DPRINTK(PROBE, ERR, 3622 DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
3008 "Unsupported Speed/Duplexity configuration\n");
3009 return -EINVAL; 3623 return -EINVAL;
3010 } 3624 }
3011 return 0; 3625 return 0;
@@ -3033,7 +3647,7 @@ e1000_suspend(struct pci_dev *pdev, uint32_t state)
3033{ 3647{
3034 struct net_device *netdev = pci_get_drvdata(pdev); 3648 struct net_device *netdev = pci_get_drvdata(pdev);
3035 struct e1000_adapter *adapter = netdev->priv; 3649 struct e1000_adapter *adapter = netdev->priv;
3036 uint32_t ctrl, ctrl_ext, rctl, manc, status; 3650 uint32_t ctrl, ctrl_ext, rctl, manc, status, swsm;
3037 uint32_t wufc = adapter->wol; 3651 uint32_t wufc = adapter->wol;
3038 3652
3039 netif_device_detach(netdev); 3653 netif_device_detach(netdev);
@@ -3075,6 +3689,9 @@ e1000_suspend(struct pci_dev *pdev, uint32_t state)
3075 E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext); 3689 E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext);
3076 } 3690 }
3077 3691
3692 /* Allow time for pending master requests to run */
3693 e1000_disable_pciex_master(&adapter->hw);
3694
3078 E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN); 3695 E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
3079 E1000_WRITE_REG(&adapter->hw, WUFC, wufc); 3696 E1000_WRITE_REG(&adapter->hw, WUFC, wufc);
3080 pci_enable_wake(pdev, 3, 1); 3697 pci_enable_wake(pdev, 3, 1);
@@ -3099,6 +3716,16 @@ e1000_suspend(struct pci_dev *pdev, uint32_t state)
3099 } 3716 }
3100 } 3717 }
3101 3718
3719 switch(adapter->hw.mac_type) {
3720 case e1000_82573:
3721 swsm = E1000_READ_REG(&adapter->hw, SWSM);
3722 E1000_WRITE_REG(&adapter->hw, SWSM,
3723 swsm & ~E1000_SWSM_DRV_LOAD);
3724 break;
3725 default:
3726 break;
3727 }
3728
3102 pci_disable_device(pdev); 3729 pci_disable_device(pdev);
3103 3730
3104 state = (state > 0) ? 3 : 0; 3731 state = (state > 0) ? 3 : 0;
@@ -3113,13 +3740,12 @@ e1000_resume(struct pci_dev *pdev)
3113{ 3740{
3114 struct net_device *netdev = pci_get_drvdata(pdev); 3741 struct net_device *netdev = pci_get_drvdata(pdev);
3115 struct e1000_adapter *adapter = netdev->priv; 3742 struct e1000_adapter *adapter = netdev->priv;
3116 uint32_t manc, ret; 3743 uint32_t manc, ret, swsm;
3117 3744
3118 pci_set_power_state(pdev, 0); 3745 pci_set_power_state(pdev, 0);
3119 pci_restore_state(pdev); 3746 pci_restore_state(pdev);
3120 ret = pci_enable_device(pdev); 3747 ret = pci_enable_device(pdev);
3121 if (pdev->is_busmaster) 3748 pci_set_master(pdev);
3122 pci_set_master(pdev);
3123 3749
3124 pci_enable_wake(pdev, 3, 0); 3750 pci_enable_wake(pdev, 3, 0);
3125 pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */ 3751 pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */
@@ -3139,10 +3765,19 @@ e1000_resume(struct pci_dev *pdev)
3139 E1000_WRITE_REG(&adapter->hw, MANC, manc); 3765 E1000_WRITE_REG(&adapter->hw, MANC, manc);
3140 } 3766 }
3141 3767
3768 switch(adapter->hw.mac_type) {
3769 case e1000_82573:
3770 swsm = E1000_READ_REG(&adapter->hw, SWSM);
3771 E1000_WRITE_REG(&adapter->hw, SWSM,
3772 swsm | E1000_SWSM_DRV_LOAD);
3773 break;
3774 default:
3775 break;
3776 }
3777
3142 return 0; 3778 return 0;
3143} 3779}
3144#endif 3780#endif
3145
3146#ifdef CONFIG_NET_POLL_CONTROLLER 3781#ifdef CONFIG_NET_POLL_CONTROLLER
3147/* 3782/*
3148 * Polling 'interrupt' - used by things like netconsole to send skbs 3783 * Polling 'interrupt' - used by things like netconsole to send skbs
@@ -3150,7 +3785,7 @@ e1000_resume(struct pci_dev *pdev)
3150 * the interrupt routine is executing. 3785 * the interrupt routine is executing.
3151 */ 3786 */
3152static void 3787static void
3153e1000_netpoll (struct net_device *netdev) 3788e1000_netpoll(struct net_device *netdev)
3154{ 3789{
3155 struct e1000_adapter *adapter = netdev->priv; 3790 struct e1000_adapter *adapter = netdev->priv;
3156 disable_irq(adapter->pdev->irq); 3791 disable_irq(adapter->pdev->irq);
diff --git a/drivers/net/e1000/e1000_osdep.h b/drivers/net/e1000/e1000_osdep.h
index 970c656a517c..aac64de61437 100644
--- a/drivers/net/e1000/e1000_osdep.h
+++ b/drivers/net/e1000/e1000_osdep.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -42,7 +42,12 @@
42#include <linux/sched.h> 42#include <linux/sched.h>
43 43
44#ifndef msec_delay 44#ifndef msec_delay
45#define msec_delay(x) msleep(x) 45#define msec_delay(x) do { if(in_interrupt()) { \
46 /* Don't mdelay in interrupt context! */ \
47 BUG(); \
48 } else { \
49 msleep(x); \
50 } } while(0)
46 51
47/* Some workarounds require millisecond delays and are run during interrupt 52/* Some workarounds require millisecond delays and are run during interrupt
48 * context. Most notably, when establishing link, the phy may need tweaking 53 * context. Most notably, when establishing link, the phy may need tweaking
@@ -96,6 +101,29 @@ typedef enum {
96 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 101 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
97 ((offset) << 2))) 102 ((offset) << 2)))
98 103
104#define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
105#define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
106
107#define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
108 writew((value), ((a)->hw_addr + \
109 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
110 ((offset) << 1))))
111
112#define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
113 readw((a)->hw_addr + \
114 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
115 ((offset) << 1)))
116
117#define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
118 writeb((value), ((a)->hw_addr + \
119 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
120 (offset))))
121
122#define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
123 readb((a)->hw_addr + \
124 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
125 (offset)))
126
99#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS) 127#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS)
100 128
101#endif /* _E1000_OSDEP_H_ */ 129#endif /* _E1000_OSDEP_H_ */
diff --git a/drivers/net/e1000/e1000_param.c b/drivers/net/e1000/e1000_param.c
index e914d09fe6f9..676247f9f1cc 100644
--- a/drivers/net/e1000/e1000_param.c
+++ b/drivers/net/e1000/e1000_param.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -478,7 +478,6 @@ e1000_check_options(struct e1000_adapter *adapter)
478 DPRINTK(PROBE, INFO, "%s set to dynamic mode\n", 478 DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
479 opt.name); 479 opt.name);
480 break; 480 break;
481 case -1:
482 default: 481 default:
483 e1000_validate_option(&adapter->itr, &opt, 482 e1000_validate_option(&adapter->itr, &opt,
484 adapter); 483 adapter);
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index cda48c5d72a9..4ebcd052e150 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -81,6 +81,7 @@
81 * cause DMA to kfree'd memory. 81 * cause DMA to kfree'd memory.
82 * 0.31: 14 Nov 2004: ethtool support for getting/setting link 82 * 0.31: 14 Nov 2004: ethtool support for getting/setting link
83 * capabilities. 83 * capabilities.
84 * 0.32: 16 Apr 2005: RX_ERROR4 handling added.
84 * 85 *
85 * Known bugs: 86 * Known bugs:
86 * We suspect that on some hardware no TX done interrupts are generated. 87 * We suspect that on some hardware no TX done interrupts are generated.
@@ -92,7 +93,7 @@
92 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few 93 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
93 * superfluous timer interrupts from the nic. 94 * superfluous timer interrupts from the nic.
94 */ 95 */
95#define FORCEDETH_VERSION "0.31" 96#define FORCEDETH_VERSION "0.32"
96#define DRV_NAME "forcedeth" 97#define DRV_NAME "forcedeth"
97 98
98#include <linux/module.h> 99#include <linux/module.h>
@@ -109,6 +110,7 @@
109#include <linux/mii.h> 110#include <linux/mii.h>
110#include <linux/random.h> 111#include <linux/random.h>
111#include <linux/init.h> 112#include <linux/init.h>
113#include <linux/if_vlan.h>
112 114
113#include <asm/irq.h> 115#include <asm/irq.h>
114#include <asm/io.h> 116#include <asm/io.h>
@@ -1013,6 +1015,59 @@ static void nv_tx_timeout(struct net_device *dev)
1013 spin_unlock_irq(&np->lock); 1015 spin_unlock_irq(&np->lock);
1014} 1016}
1015 1017
1018/*
1019 * Called when the nic notices a mismatch between the actual data len on the
1020 * wire and the len indicated in the 802 header
1021 */
1022static int nv_getlen(struct net_device *dev, void *packet, int datalen)
1023{
1024 int hdrlen; /* length of the 802 header */
1025 int protolen; /* length as stored in the proto field */
1026
1027 /* 1) calculate len according to header */
1028 if ( ((struct vlan_ethhdr *)packet)->h_vlan_proto == __constant_htons(ETH_P_8021Q)) {
1029 protolen = ntohs( ((struct vlan_ethhdr *)packet)->h_vlan_encapsulated_proto );
1030 hdrlen = VLAN_HLEN;
1031 } else {
1032 protolen = ntohs( ((struct ethhdr *)packet)->h_proto);
1033 hdrlen = ETH_HLEN;
1034 }
1035 dprintk(KERN_DEBUG "%s: nv_getlen: datalen %d, protolen %d, hdrlen %d\n",
1036 dev->name, datalen, protolen, hdrlen);
1037 if (protolen > ETH_DATA_LEN)
1038 return datalen; /* Value in proto field not a len, no checks possible */
1039
1040 protolen += hdrlen;
1041 /* consistency checks: */
1042 if (datalen > ETH_ZLEN) {
1043 if (datalen >= protolen) {
1044 /* more data on wire than in 802 header, trim of
1045 * additional data.
1046 */
1047 dprintk(KERN_DEBUG "%s: nv_getlen: accepting %d bytes.\n",
1048 dev->name, protolen);
1049 return protolen;
1050 } else {
1051 /* less data on wire than mentioned in header.
1052 * Discard the packet.
1053 */
1054 dprintk(KERN_DEBUG "%s: nv_getlen: discarding long packet.\n",
1055 dev->name);
1056 return -1;
1057 }
1058 } else {
1059 /* short packet. Accept only if 802 values are also short */
1060 if (protolen > ETH_ZLEN) {
1061 dprintk(KERN_DEBUG "%s: nv_getlen: discarding short packet.\n",
1062 dev->name);
1063 return -1;
1064 }
1065 dprintk(KERN_DEBUG "%s: nv_getlen: accepting %d bytes.\n",
1066 dev->name, datalen);
1067 return datalen;
1068 }
1069}
1070
1016static void nv_rx_process(struct net_device *dev) 1071static void nv_rx_process(struct net_device *dev)
1017{ 1072{
1018 struct fe_priv *np = get_nvpriv(dev); 1073 struct fe_priv *np = get_nvpriv(dev);
@@ -1064,7 +1119,7 @@ static void nv_rx_process(struct net_device *dev)
1064 np->stats.rx_errors++; 1119 np->stats.rx_errors++;
1065 goto next_pkt; 1120 goto next_pkt;
1066 } 1121 }
1067 if (Flags & (NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3|NV_RX_ERROR4)) { 1122 if (Flags & (NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3)) {
1068 np->stats.rx_errors++; 1123 np->stats.rx_errors++;
1069 goto next_pkt; 1124 goto next_pkt;
1070 } 1125 }
@@ -1078,22 +1133,24 @@ static void nv_rx_process(struct net_device *dev)
1078 np->stats.rx_errors++; 1133 np->stats.rx_errors++;
1079 goto next_pkt; 1134 goto next_pkt;
1080 } 1135 }
1081 if (Flags & NV_RX_ERROR) { 1136 if (Flags & NV_RX_ERROR4) {
1082 /* framing errors are soft errors, the rest is fatal. */ 1137 len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
1083 if (Flags & NV_RX_FRAMINGERR) { 1138 if (len < 0) {
1084 if (Flags & NV_RX_SUBSTRACT1) {
1085 len--;
1086 }
1087 } else {
1088 np->stats.rx_errors++; 1139 np->stats.rx_errors++;
1089 goto next_pkt; 1140 goto next_pkt;
1090 } 1141 }
1091 } 1142 }
1143 /* framing errors are soft errors. */
1144 if (Flags & NV_RX_FRAMINGERR) {
1145 if (Flags & NV_RX_SUBSTRACT1) {
1146 len--;
1147 }
1148 }
1092 } else { 1149 } else {
1093 if (!(Flags & NV_RX2_DESCRIPTORVALID)) 1150 if (!(Flags & NV_RX2_DESCRIPTORVALID))
1094 goto next_pkt; 1151 goto next_pkt;
1095 1152
1096 if (Flags & (NV_RX2_ERROR1|NV_RX2_ERROR2|NV_RX2_ERROR3|NV_RX2_ERROR4)) { 1153 if (Flags & (NV_RX2_ERROR1|NV_RX2_ERROR2|NV_RX2_ERROR3)) {
1097 np->stats.rx_errors++; 1154 np->stats.rx_errors++;
1098 goto next_pkt; 1155 goto next_pkt;
1099 } 1156 }
@@ -1107,17 +1164,19 @@ static void nv_rx_process(struct net_device *dev)
1107 np->stats.rx_errors++; 1164 np->stats.rx_errors++;
1108 goto next_pkt; 1165 goto next_pkt;
1109 } 1166 }
1110 if (Flags & NV_RX2_ERROR) { 1167 if (Flags & NV_RX2_ERROR4) {
1111 /* framing errors are soft errors, the rest is fatal. */ 1168 len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
1112 if (Flags & NV_RX2_FRAMINGERR) { 1169 if (len < 0) {
1113 if (Flags & NV_RX2_SUBSTRACT1) {
1114 len--;
1115 }
1116 } else {
1117 np->stats.rx_errors++; 1170 np->stats.rx_errors++;
1118 goto next_pkt; 1171 goto next_pkt;
1119 } 1172 }
1120 } 1173 }
1174 /* framing errors are soft errors */
1175 if (Flags & NV_RX2_FRAMINGERR) {
1176 if (Flags & NV_RX2_SUBSTRACT1) {
1177 len--;
1178 }
1179 }
1121 Flags &= NV_RX2_CHECKSUMMASK; 1180 Flags &= NV_RX2_CHECKSUMMASK;
1122 if (Flags == NV_RX2_CHECKSUMOK1 || 1181 if (Flags == NV_RX2_CHECKSUMOK1 ||
1123 Flags == NV_RX2_CHECKSUMOK2 || 1182 Flags == NV_RX2_CHECKSUMOK2 ||
@@ -1480,6 +1539,13 @@ static void nv_do_nic_poll(unsigned long data)
1480 enable_irq(dev->irq); 1539 enable_irq(dev->irq);
1481} 1540}
1482 1541
1542#ifdef CONFIG_NET_POLL_CONTROLLER
1543static void nv_poll_controller(struct net_device *dev)
1544{
1545 nv_do_nic_poll((unsigned long) dev);
1546}
1547#endif
1548
1483static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 1549static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1484{ 1550{
1485 struct fe_priv *np = get_nvpriv(dev); 1551 struct fe_priv *np = get_nvpriv(dev);
@@ -1962,6 +2028,9 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
1962 dev->get_stats = nv_get_stats; 2028 dev->get_stats = nv_get_stats;
1963 dev->change_mtu = nv_change_mtu; 2029 dev->change_mtu = nv_change_mtu;
1964 dev->set_multicast_list = nv_set_multicast; 2030 dev->set_multicast_list = nv_set_multicast;
2031#ifdef CONFIG_NET_POLL_CONTROLLER
2032 dev->poll_controller = nv_poll_controller;
2033#endif
1965 SET_ETHTOOL_OPS(dev, &ops); 2034 SET_ETHTOOL_OPS(dev, &ops);
1966 dev->tx_timeout = nv_tx_timeout; 2035 dev->tx_timeout = nv_tx_timeout;
1967 dev->watchdog_timeo = NV_WATCHDOG_TIMEO; 2036 dev->watchdog_timeo = NV_WATCHDOG_TIMEO;
diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c
index ab44358ddbfc..6482d994d489 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -1595,7 +1595,7 @@ static struct ethtool_ops emac_ethtool_ops = {
1595static int emac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1595static int emac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1596{ 1596{
1597 struct ocp_enet_private *fep = dev->priv; 1597 struct ocp_enet_private *fep = dev->priv;
1598 uint *data = (uint *) & rq->ifr_ifru; 1598 uint16_t *data = (uint16_t *) & rq->ifr_ifru;
1599 1599
1600 switch (cmd) { 1600 switch (cmd) {
1601 case SIOCGMIIPHY: 1601 case SIOCGMIIPHY:
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index 855f8b2cf13b..13ed8dc1e91d 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -924,7 +924,7 @@ static int veth_transmit_to_one(struct sk_buff *skb, HvLpIndex rlp,
924 924
925 spin_lock_irqsave(&cnx->lock, flags); 925 spin_lock_irqsave(&cnx->lock, flags);
926 926
927 if (! cnx->state & VETH_STATE_READY) 927 if (! (cnx->state & VETH_STATE_READY))
928 goto drop; 928 goto drop;
929 929
930 if ((skb->len - 14) > VETH_MAX_MTU) 930 if ((skb->len - 14) > VETH_MAX_MTU)
@@ -1023,6 +1023,8 @@ static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev)
1023 1023
1024 lpmask = veth_transmit_to_many(skb, lpmask, dev); 1024 lpmask = veth_transmit_to_many(skb, lpmask, dev);
1025 1025
1026 dev->trans_start = jiffies;
1027
1026 if (! lpmask) { 1028 if (! lpmask) {
1027 dev_kfree_skb(skb); 1029 dev_kfree_skb(skb);
1028 } else { 1030 } else {
@@ -1262,13 +1264,18 @@ static void veth_receive(struct veth_lpar_connection *cnx,
1262 1264
1263 vlan = skb->data[9]; 1265 vlan = skb->data[9];
1264 dev = veth_dev[vlan]; 1266 dev = veth_dev[vlan];
1265 if (! dev) 1267 if (! dev) {
1266 /* Some earlier versions of the driver sent 1268 /*
1267 broadcasts down all connections, even to 1269 * Some earlier versions of the driver sent
1268 lpars that weren't on the relevant vlan. 1270 * broadcasts down all connections, even to lpars
1269 So ignore packets belonging to a vlan we're 1271 * that weren't on the relevant vlan. So ignore
1270 not on. */ 1272 * packets belonging to a vlan we're not on.
1273 * We can also be here if we receive packets while
1274 * the driver is going down, because then dev is NULL.
1275 */
1276 dev_kfree_skb_irq(skb);
1271 continue; 1277 continue;
1278 }
1272 1279
1273 port = (struct veth_port *)dev->priv; 1280 port = (struct veth_port *)dev->priv;
1274 dest = *((u64 *) skb->data) & 0xFFFFFFFFFFFF0000; 1281 dest = *((u64 *) skb->data) & 0xFFFFFFFFFFFF0000;
@@ -1381,18 +1388,25 @@ void __exit veth_module_cleanup(void)
1381{ 1388{
1382 int i; 1389 int i;
1383 1390
1384 vio_unregister_driver(&veth_driver); 1391 /* Stop the queues first to stop any new packets being sent. */
1392 for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++)
1393 if (veth_dev[i])
1394 netif_stop_queue(veth_dev[i]);
1385 1395
1396 /* Stop the connections before we unregister the driver. This
1397 * ensures there's no skbs lying around holding the device open. */
1386 for (i = 0; i < HVMAXARCHITECTEDLPS; ++i) 1398 for (i = 0; i < HVMAXARCHITECTEDLPS; ++i)
1387 veth_stop_connection(i); 1399 veth_stop_connection(i);
1388 1400
1389 HvLpEvent_unregisterHandler(HvLpEvent_Type_VirtualLan); 1401 HvLpEvent_unregisterHandler(HvLpEvent_Type_VirtualLan);
1390 1402
1391 /* Hypervisor callbacks may have scheduled more work while we 1403 /* Hypervisor callbacks may have scheduled more work while we
1392 * were destroying connections. Now that we've disconnected from 1404 * were stoping connections. Now that we've disconnected from
1393 * the hypervisor make sure everything's finished. */ 1405 * the hypervisor make sure everything's finished. */
1394 flush_scheduled_work(); 1406 flush_scheduled_work();
1395 1407
1408 vio_unregister_driver(&veth_driver);
1409
1396 for (i = 0; i < HVMAXARCHITECTEDLPS; ++i) 1410 for (i = 0; i < HVMAXARCHITECTEDLPS; ++i)
1397 veth_destroy_connection(i); 1411 veth_destroy_connection(i);
1398 1412
diff --git a/drivers/net/ixgb/ixgb.h b/drivers/net/ixgb/ixgb.h
index 26c4f15f7fc0..f8d3385c7842 100644
--- a/drivers/net/ixgb/ixgb.h
+++ b/drivers/net/ixgb/ixgb.h
@@ -110,7 +110,7 @@ struct ixgb_adapter;
110#define IXGB_TX_QUEUE_WAKE 16 110#define IXGB_TX_QUEUE_WAKE 16
111 111
112/* How many Rx Buffers do we bundle into one write to the hardware ? */ 112/* How many Rx Buffers do we bundle into one write to the hardware ? */
113#define IXGB_RX_BUFFER_WRITE 16 /* Must be power of 2 */ 113#define IXGB_RX_BUFFER_WRITE 4 /* Must be power of 2 */
114 114
115/* only works for sizes that are powers of 2 */ 115/* only works for sizes that are powers of 2 */
116#define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1))) 116#define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
diff --git a/drivers/net/ixgb/ixgb_ee.c b/drivers/net/ixgb/ixgb_ee.c
index 653e99f919ce..3aae110c5560 100644
--- a/drivers/net/ixgb/ixgb_ee.c
+++ b/drivers/net/ixgb/ixgb_ee.c
@@ -411,7 +411,7 @@ ixgb_write_eeprom(struct ixgb_hw *hw, uint16_t offset, uint16_t data)
411 ixgb_cleanup_eeprom(hw); 411 ixgb_cleanup_eeprom(hw);
412 412
413 /* clear the init_ctrl_reg_1 to signify that the cache is invalidated */ 413 /* clear the init_ctrl_reg_1 to signify that the cache is invalidated */
414 ee_map->init_ctrl_reg_1 = EEPROM_ICW1_SIGNATURE_CLEAR; 414 ee_map->init_ctrl_reg_1 = le16_to_cpu(EEPROM_ICW1_SIGNATURE_CLEAR);
415 415
416 return; 416 return;
417} 417}
@@ -483,7 +483,7 @@ ixgb_get_eeprom_data(struct ixgb_hw *hw)
483 DEBUGOUT("ixgb_ee: Checksum invalid.\n"); 483 DEBUGOUT("ixgb_ee: Checksum invalid.\n");
484 /* clear the init_ctrl_reg_1 to signify that the cache is 484 /* clear the init_ctrl_reg_1 to signify that the cache is
485 * invalidated */ 485 * invalidated */
486 ee_map->init_ctrl_reg_1 = EEPROM_ICW1_SIGNATURE_CLEAR; 486 ee_map->init_ctrl_reg_1 = le16_to_cpu(EEPROM_ICW1_SIGNATURE_CLEAR);
487 return (FALSE); 487 return (FALSE);
488 } 488 }
489 489
@@ -579,7 +579,7 @@ ixgb_get_ee_compatibility(struct ixgb_hw *hw)
579 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; 579 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
580 580
581 if(ixgb_check_and_get_eeprom_data(hw) == TRUE) 581 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
582 return(ee_map->compatibility); 582 return (le16_to_cpu(ee_map->compatibility));
583 583
584 return(0); 584 return(0);
585} 585}
@@ -616,7 +616,7 @@ ixgb_get_ee_init_ctrl_reg_1(struct ixgb_hw *hw)
616 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; 616 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
617 617
618 if(ixgb_check_and_get_eeprom_data(hw) == TRUE) 618 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
619 return(ee_map->init_ctrl_reg_1); 619 return (le16_to_cpu(ee_map->init_ctrl_reg_1));
620 620
621 return(0); 621 return(0);
622} 622}
@@ -635,7 +635,7 @@ ixgb_get_ee_init_ctrl_reg_2(struct ixgb_hw *hw)
635 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; 635 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
636 636
637 if(ixgb_check_and_get_eeprom_data(hw) == TRUE) 637 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
638 return(ee_map->init_ctrl_reg_2); 638 return (le16_to_cpu(ee_map->init_ctrl_reg_2));
639 639
640 return(0); 640 return(0);
641} 641}
@@ -654,7 +654,7 @@ ixgb_get_ee_subsystem_id(struct ixgb_hw *hw)
654 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; 654 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
655 655
656 if(ixgb_check_and_get_eeprom_data(hw) == TRUE) 656 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
657 return(ee_map->subsystem_id); 657 return (le16_to_cpu(ee_map->subsystem_id));
658 658
659 return(0); 659 return(0);
660} 660}
@@ -673,7 +673,7 @@ ixgb_get_ee_subvendor_id(struct ixgb_hw *hw)
673 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; 673 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
674 674
675 if(ixgb_check_and_get_eeprom_data(hw) == TRUE) 675 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
676 return(ee_map->subvendor_id); 676 return (le16_to_cpu(ee_map->subvendor_id));
677 677
678 return(0); 678 return(0);
679} 679}
@@ -692,7 +692,7 @@ ixgb_get_ee_device_id(struct ixgb_hw *hw)
692 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; 692 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
693 693
694 if(ixgb_check_and_get_eeprom_data(hw) == TRUE) 694 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
695 return(ee_map->device_id); 695 return (le16_to_cpu(ee_map->device_id));
696 696
697 return(0); 697 return(0);
698} 698}
@@ -711,7 +711,7 @@ ixgb_get_ee_vendor_id(struct ixgb_hw *hw)
711 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; 711 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
712 712
713 if(ixgb_check_and_get_eeprom_data(hw) == TRUE) 713 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
714 return(ee_map->vendor_id); 714 return (le16_to_cpu(ee_map->vendor_id));
715 715
716 return(0); 716 return(0);
717} 717}
@@ -730,7 +730,7 @@ ixgb_get_ee_swdpins_reg(struct ixgb_hw *hw)
730 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; 730 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
731 731
732 if(ixgb_check_and_get_eeprom_data(hw) == TRUE) 732 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
733 return(ee_map->swdpins_reg); 733 return (le16_to_cpu(ee_map->swdpins_reg));
734 734
735 return(0); 735 return(0);
736} 736}
@@ -749,7 +749,7 @@ ixgb_get_ee_d3_power(struct ixgb_hw *hw)
749 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; 749 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
750 750
751 if(ixgb_check_and_get_eeprom_data(hw) == TRUE) 751 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
752 return(ee_map->d3_power); 752 return (le16_to_cpu(ee_map->d3_power));
753 753
754 return(0); 754 return(0);
755} 755}
@@ -768,7 +768,7 @@ ixgb_get_ee_d0_power(struct ixgb_hw *hw)
768 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; 768 struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
769 769
770 if(ixgb_check_and_get_eeprom_data(hw) == TRUE) 770 if(ixgb_check_and_get_eeprom_data(hw) == TRUE)
771 return(ee_map->d0_power); 771 return (le16_to_cpu(ee_map->d0_power));
772 772
773 return(0); 773 return(0);
774} 774}
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
index aea10e8aaa72..3fa113854eeb 100644
--- a/drivers/net/ixgb/ixgb_ethtool.c
+++ b/drivers/net/ixgb/ixgb_ethtool.c
@@ -252,7 +252,9 @@ ixgb_get_regs(struct net_device *netdev,
252 uint32_t *reg_start = reg; 252 uint32_t *reg_start = reg;
253 uint8_t i; 253 uint8_t i;
254 254
255 regs->version = (adapter->hw.device_id << 16) | adapter->hw.subsystem_id; 255 /* the 1 (one) below indicates an attempt at versioning, if the
256 * interface in ethtool or the driver this 1 should be incremented */
257 regs->version = (1<<24) | hw->revision_id << 16 | hw->device_id;
256 258
257 /* General Registers */ 259 /* General Registers */
258 *reg++ = IXGB_READ_REG(hw, CTRL0); /* 0 */ 260 *reg++ = IXGB_READ_REG(hw, CTRL0); /* 0 */
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 7d26623d8592..35f6a7c271a2 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -47,7 +47,7 @@ char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
47#else 47#else
48#define DRIVERNAPI "-NAPI" 48#define DRIVERNAPI "-NAPI"
49#endif 49#endif
50char ixgb_driver_version[] = "1.0.90-k2"DRIVERNAPI; 50char ixgb_driver_version[] = "1.0.95-k2"DRIVERNAPI;
51char ixgb_copyright[] = "Copyright (c) 1999-2005 Intel Corporation."; 51char ixgb_copyright[] = "Copyright (c) 1999-2005 Intel Corporation.";
52 52
53/* ixgb_pci_tbl - PCI Device ID Table 53/* ixgb_pci_tbl - PCI Device ID Table
@@ -103,6 +103,7 @@ static int ixgb_change_mtu(struct net_device *netdev, int new_mtu);
103static int ixgb_set_mac(struct net_device *netdev, void *p); 103static int ixgb_set_mac(struct net_device *netdev, void *p);
104static irqreturn_t ixgb_intr(int irq, void *data, struct pt_regs *regs); 104static irqreturn_t ixgb_intr(int irq, void *data, struct pt_regs *regs);
105static boolean_t ixgb_clean_tx_irq(struct ixgb_adapter *adapter); 105static boolean_t ixgb_clean_tx_irq(struct ixgb_adapter *adapter);
106
106#ifdef CONFIG_IXGB_NAPI 107#ifdef CONFIG_IXGB_NAPI
107static int ixgb_clean(struct net_device *netdev, int *budget); 108static int ixgb_clean(struct net_device *netdev, int *budget);
108static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter, 109static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter,
@@ -120,33 +121,20 @@ static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
120static void ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid); 121static void ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
121static void ixgb_restore_vlan(struct ixgb_adapter *adapter); 122static void ixgb_restore_vlan(struct ixgb_adapter *adapter);
122 123
123static int ixgb_notify_reboot(struct notifier_block *, unsigned long event,
124 void *ptr);
125static int ixgb_suspend(struct pci_dev *pdev, uint32_t state);
126
127#ifdef CONFIG_NET_POLL_CONTROLLER 124#ifdef CONFIG_NET_POLL_CONTROLLER
128/* for netdump / net console */ 125/* for netdump / net console */
129static void ixgb_netpoll(struct net_device *dev); 126static void ixgb_netpoll(struct net_device *dev);
130#endif 127#endif
131 128
132struct notifier_block ixgb_notifier_reboot = {
133 .notifier_call = ixgb_notify_reboot,
134 .next = NULL,
135 .priority = 0
136};
137
138/* Exported from other modules */ 129/* Exported from other modules */
139 130
140extern void ixgb_check_options(struct ixgb_adapter *adapter); 131extern void ixgb_check_options(struct ixgb_adapter *adapter);
141 132
142static struct pci_driver ixgb_driver = { 133static struct pci_driver ixgb_driver = {
143 .name = ixgb_driver_name, 134 .name = ixgb_driver_name,
144 .id_table = ixgb_pci_tbl, 135 .id_table = ixgb_pci_tbl,
145 .probe = ixgb_probe, 136 .probe = ixgb_probe,
146 .remove = __devexit_p(ixgb_remove), 137 .remove = __devexit_p(ixgb_remove),
147 /* Power Managment Hooks */
148 .suspend = NULL,
149 .resume = NULL
150}; 138};
151 139
152MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); 140MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
@@ -169,17 +157,12 @@ MODULE_LICENSE("GPL");
169static int __init 157static int __init
170ixgb_init_module(void) 158ixgb_init_module(void)
171{ 159{
172 int ret;
173 printk(KERN_INFO "%s - version %s\n", 160 printk(KERN_INFO "%s - version %s\n",
174 ixgb_driver_string, ixgb_driver_version); 161 ixgb_driver_string, ixgb_driver_version);
175 162
176 printk(KERN_INFO "%s\n", ixgb_copyright); 163 printk(KERN_INFO "%s\n", ixgb_copyright);
177 164
178 ret = pci_module_init(&ixgb_driver); 165 return pci_module_init(&ixgb_driver);
179 if(ret >= 0) {
180 register_reboot_notifier(&ixgb_notifier_reboot);
181 }
182 return ret;
183} 166}
184 167
185module_init(ixgb_init_module); 168module_init(ixgb_init_module);
@@ -194,7 +177,6 @@ module_init(ixgb_init_module);
194static void __exit 177static void __exit
195ixgb_exit_module(void) 178ixgb_exit_module(void)
196{ 179{
197 unregister_reboot_notifier(&ixgb_notifier_reboot);
198 pci_unregister_driver(&ixgb_driver); 180 pci_unregister_driver(&ixgb_driver);
199} 181}
200 182
@@ -224,8 +206,8 @@ ixgb_irq_enable(struct ixgb_adapter *adapter)
224{ 206{
225 if(atomic_dec_and_test(&adapter->irq_sem)) { 207 if(atomic_dec_and_test(&adapter->irq_sem)) {
226 IXGB_WRITE_REG(&adapter->hw, IMS, 208 IXGB_WRITE_REG(&adapter->hw, IMS,
227 IXGB_INT_RXT0 | IXGB_INT_RXDMT0 | IXGB_INT_TXDW | 209 IXGB_INT_RXT0 | IXGB_INT_RXDMT0 | IXGB_INT_TXDW |
228 IXGB_INT_RXO | IXGB_INT_LSC); 210 IXGB_INT_LSC);
229 IXGB_WRITE_FLUSH(&adapter->hw); 211 IXGB_WRITE_FLUSH(&adapter->hw);
230 } 212 }
231} 213}
@@ -1209,10 +1191,10 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1209 | IXGB_CONTEXT_DESC_CMD_TSE 1191 | IXGB_CONTEXT_DESC_CMD_TSE
1210 | IXGB_CONTEXT_DESC_CMD_IP 1192 | IXGB_CONTEXT_DESC_CMD_IP
1211 | IXGB_CONTEXT_DESC_CMD_TCP 1193 | IXGB_CONTEXT_DESC_CMD_TCP
1212 | IXGB_CONTEXT_DESC_CMD_RS
1213 | IXGB_CONTEXT_DESC_CMD_IDE 1194 | IXGB_CONTEXT_DESC_CMD_IDE
1214 | (skb->len - (hdr_len))); 1195 | (skb->len - (hdr_len)));
1215 1196
1197
1216 if(++i == adapter->tx_ring.count) i = 0; 1198 if(++i == adapter->tx_ring.count) i = 0;
1217 adapter->tx_ring.next_to_use = i; 1199 adapter->tx_ring.next_to_use = i;
1218 1200
@@ -1247,8 +1229,7 @@ ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
1247 context_desc->mss = 0; 1229 context_desc->mss = 0;
1248 context_desc->cmd_type_len = 1230 context_desc->cmd_type_len =
1249 cpu_to_le32(IXGB_CONTEXT_DESC_TYPE 1231 cpu_to_le32(IXGB_CONTEXT_DESC_TYPE
1250 | IXGB_TX_DESC_CMD_RS 1232 | IXGB_TX_DESC_CMD_IDE);
1251 | IXGB_TX_DESC_CMD_IDE);
1252 1233
1253 if(++i == adapter->tx_ring.count) i = 0; 1234 if(++i == adapter->tx_ring.count) i = 0;
1254 adapter->tx_ring.next_to_use = i; 1235 adapter->tx_ring.next_to_use = i;
@@ -1273,6 +1254,7 @@ ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
1273 1254
1274 unsigned int nr_frags = skb_shinfo(skb)->nr_frags; 1255 unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
1275 unsigned int f; 1256 unsigned int f;
1257
1276 len -= skb->data_len; 1258 len -= skb->data_len;
1277 1259
1278 i = tx_ring->next_to_use; 1260 i = tx_ring->next_to_use;
@@ -1526,14 +1508,33 @@ ixgb_change_mtu(struct net_device *netdev, int new_mtu)
1526void 1508void
1527ixgb_update_stats(struct ixgb_adapter *adapter) 1509ixgb_update_stats(struct ixgb_adapter *adapter)
1528{ 1510{
1511 struct net_device *netdev = adapter->netdev;
1512
1513 if((netdev->flags & IFF_PROMISC) || (netdev->flags & IFF_ALLMULTI) ||
1514 (netdev->mc_count > IXGB_MAX_NUM_MULTICAST_ADDRESSES)) {
1515 u64 multi = IXGB_READ_REG(&adapter->hw, MPRCL);
1516 u32 bcast_l = IXGB_READ_REG(&adapter->hw, BPRCL);
1517 u32 bcast_h = IXGB_READ_REG(&adapter->hw, BPRCH);
1518 u64 bcast = ((u64)bcast_h << 32) | bcast_l;
1519
1520 multi |= ((u64)IXGB_READ_REG(&adapter->hw, MPRCH) << 32);
1521 /* fix up multicast stats by removing broadcasts */
1522 multi -= bcast;
1523
1524 adapter->stats.mprcl += (multi & 0xFFFFFFFF);
1525 adapter->stats.mprch += (multi >> 32);
1526 adapter->stats.bprcl += bcast_l;
1527 adapter->stats.bprch += bcast_h;
1528 } else {
1529 adapter->stats.mprcl += IXGB_READ_REG(&adapter->hw, MPRCL);
1530 adapter->stats.mprch += IXGB_READ_REG(&adapter->hw, MPRCH);
1531 adapter->stats.bprcl += IXGB_READ_REG(&adapter->hw, BPRCL);
1532 adapter->stats.bprch += IXGB_READ_REG(&adapter->hw, BPRCH);
1533 }
1529 adapter->stats.tprl += IXGB_READ_REG(&adapter->hw, TPRL); 1534 adapter->stats.tprl += IXGB_READ_REG(&adapter->hw, TPRL);
1530 adapter->stats.tprh += IXGB_READ_REG(&adapter->hw, TPRH); 1535 adapter->stats.tprh += IXGB_READ_REG(&adapter->hw, TPRH);
1531 adapter->stats.gprcl += IXGB_READ_REG(&adapter->hw, GPRCL); 1536 adapter->stats.gprcl += IXGB_READ_REG(&adapter->hw, GPRCL);
1532 adapter->stats.gprch += IXGB_READ_REG(&adapter->hw, GPRCH); 1537 adapter->stats.gprch += IXGB_READ_REG(&adapter->hw, GPRCH);
1533 adapter->stats.bprcl += IXGB_READ_REG(&adapter->hw, BPRCL);
1534 adapter->stats.bprch += IXGB_READ_REG(&adapter->hw, BPRCH);
1535 adapter->stats.mprcl += IXGB_READ_REG(&adapter->hw, MPRCL);
1536 adapter->stats.mprch += IXGB_READ_REG(&adapter->hw, MPRCH);
1537 adapter->stats.uprcl += IXGB_READ_REG(&adapter->hw, UPRCL); 1538 adapter->stats.uprcl += IXGB_READ_REG(&adapter->hw, UPRCL);
1538 adapter->stats.uprch += IXGB_READ_REG(&adapter->hw, UPRCH); 1539 adapter->stats.uprch += IXGB_READ_REG(&adapter->hw, UPRCH);
1539 adapter->stats.vprcl += IXGB_READ_REG(&adapter->hw, VPRCL); 1540 adapter->stats.vprcl += IXGB_READ_REG(&adapter->hw, VPRCL);
@@ -1823,7 +1824,6 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1823 struct pci_dev *pdev = adapter->pdev; 1824 struct pci_dev *pdev = adapter->pdev;
1824 struct ixgb_rx_desc *rx_desc, *next_rxd; 1825 struct ixgb_rx_desc *rx_desc, *next_rxd;
1825 struct ixgb_buffer *buffer_info, *next_buffer, *next2_buffer; 1826 struct ixgb_buffer *buffer_info, *next_buffer, *next2_buffer;
1826 struct sk_buff *skb, *next_skb;
1827 uint32_t length; 1827 uint32_t length;
1828 unsigned int i, j; 1828 unsigned int i, j;
1829 boolean_t cleaned = FALSE; 1829 boolean_t cleaned = FALSE;
@@ -1833,6 +1833,8 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1833 buffer_info = &rx_ring->buffer_info[i]; 1833 buffer_info = &rx_ring->buffer_info[i];
1834 1834
1835 while(rx_desc->status & IXGB_RX_DESC_STATUS_DD) { 1835 while(rx_desc->status & IXGB_RX_DESC_STATUS_DD) {
1836 struct sk_buff *skb, *next_skb;
1837 u8 status;
1836 1838
1837#ifdef CONFIG_IXGB_NAPI 1839#ifdef CONFIG_IXGB_NAPI
1838 if(*work_done >= work_to_do) 1840 if(*work_done >= work_to_do)
@@ -1840,7 +1842,9 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1840 1842
1841 (*work_done)++; 1843 (*work_done)++;
1842#endif 1844#endif
1845 status = rx_desc->status;
1843 skb = buffer_info->skb; 1846 skb = buffer_info->skb;
1847
1844 prefetch(skb->data); 1848 prefetch(skb->data);
1845 1849
1846 if(++i == rx_ring->count) i = 0; 1850 if(++i == rx_ring->count) i = 0;
@@ -1855,7 +1859,6 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1855 next_skb = next_buffer->skb; 1859 next_skb = next_buffer->skb;
1856 prefetch(next_skb); 1860 prefetch(next_skb);
1857 1861
1858
1859 cleaned = TRUE; 1862 cleaned = TRUE;
1860 1863
1861 pci_unmap_single(pdev, 1864 pci_unmap_single(pdev,
@@ -1865,7 +1868,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1865 1868
1866 length = le16_to_cpu(rx_desc->length); 1869 length = le16_to_cpu(rx_desc->length);
1867 1870
1868 if(unlikely(!(rx_desc->status & IXGB_RX_DESC_STATUS_EOP))) { 1871 if(unlikely(!(status & IXGB_RX_DESC_STATUS_EOP))) {
1869 1872
1870 /* All receives must fit into a single buffer */ 1873 /* All receives must fit into a single buffer */
1871 1874
@@ -1873,12 +1876,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1873 "length<%x>\n", length); 1876 "length<%x>\n", length);
1874 1877
1875 dev_kfree_skb_irq(skb); 1878 dev_kfree_skb_irq(skb);
1876 rx_desc->status = 0; 1879 goto rxdesc_done;
1877 buffer_info->skb = NULL;
1878
1879 rx_desc = next_rxd;
1880 buffer_info = next_buffer;
1881 continue;
1882 } 1880 }
1883 1881
1884 if (unlikely(rx_desc->errors 1882 if (unlikely(rx_desc->errors
@@ -1887,12 +1885,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1887 IXGB_RX_DESC_ERRORS_RXE))) { 1885 IXGB_RX_DESC_ERRORS_RXE))) {
1888 1886
1889 dev_kfree_skb_irq(skb); 1887 dev_kfree_skb_irq(skb);
1890 rx_desc->status = 0; 1888 goto rxdesc_done;
1891 buffer_info->skb = NULL;
1892
1893 rx_desc = next_rxd;
1894 buffer_info = next_buffer;
1895 continue;
1896 } 1889 }
1897 1890
1898 /* Good Receive */ 1891 /* Good Receive */
@@ -1903,7 +1896,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1903 1896
1904 skb->protocol = eth_type_trans(skb, netdev); 1897 skb->protocol = eth_type_trans(skb, netdev);
1905#ifdef CONFIG_IXGB_NAPI 1898#ifdef CONFIG_IXGB_NAPI
1906 if(adapter->vlgrp && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) { 1899 if(adapter->vlgrp && (status & IXGB_RX_DESC_STATUS_VP)) {
1907 vlan_hwaccel_receive_skb(skb, adapter->vlgrp, 1900 vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
1908 le16_to_cpu(rx_desc->special) & 1901 le16_to_cpu(rx_desc->special) &
1909 IXGB_RX_DESC_SPECIAL_VLAN_MASK); 1902 IXGB_RX_DESC_SPECIAL_VLAN_MASK);
@@ -1911,7 +1904,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1911 netif_receive_skb(skb); 1904 netif_receive_skb(skb);
1912 } 1905 }
1913#else /* CONFIG_IXGB_NAPI */ 1906#else /* CONFIG_IXGB_NAPI */
1914 if(adapter->vlgrp && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) { 1907 if(adapter->vlgrp && (status & IXGB_RX_DESC_STATUS_VP)) {
1915 vlan_hwaccel_rx(skb, adapter->vlgrp, 1908 vlan_hwaccel_rx(skb, adapter->vlgrp,
1916 le16_to_cpu(rx_desc->special) & 1909 le16_to_cpu(rx_desc->special) &
1917 IXGB_RX_DESC_SPECIAL_VLAN_MASK); 1910 IXGB_RX_DESC_SPECIAL_VLAN_MASK);
@@ -1921,9 +1914,12 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1921#endif /* CONFIG_IXGB_NAPI */ 1914#endif /* CONFIG_IXGB_NAPI */
1922 netdev->last_rx = jiffies; 1915 netdev->last_rx = jiffies;
1923 1916
1917rxdesc_done:
1918 /* clean up descriptor, might be written over by hw */
1924 rx_desc->status = 0; 1919 rx_desc->status = 0;
1925 buffer_info->skb = NULL; 1920 buffer_info->skb = NULL;
1926 1921
1922 /* use prefetched values */
1927 rx_desc = next_rxd; 1923 rx_desc = next_rxd;
1928 buffer_info = next_buffer; 1924 buffer_info = next_buffer;
1929 } 1925 }
@@ -1959,8 +1955,8 @@ ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
1959 1955
1960 num_group_tail_writes = IXGB_RX_BUFFER_WRITE; 1956 num_group_tail_writes = IXGB_RX_BUFFER_WRITE;
1961 1957
1962 /* leave one descriptor unused */ 1958 /* leave three descriptors unused */
1963 while(--cleancount > 0) { 1959 while(--cleancount > 2) {
1964 rx_desc = IXGB_RX_DESC(*rx_ring, i); 1960 rx_desc = IXGB_RX_DESC(*rx_ring, i);
1965 1961
1966 skb = dev_alloc_skb(adapter->rx_buffer_len + NET_IP_ALIGN); 1962 skb = dev_alloc_skb(adapter->rx_buffer_len + NET_IP_ALIGN);
@@ -1987,6 +1983,10 @@ ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
1987 PCI_DMA_FROMDEVICE); 1983 PCI_DMA_FROMDEVICE);
1988 1984
1989 rx_desc->buff_addr = cpu_to_le64(buffer_info->dma); 1985 rx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
1986 /* guarantee DD bit not set now before h/w gets descriptor
1987 * this is the rest of the workaround for h/w double
1988 * writeback. */
1989 rx_desc->status = 0;
1990 1990
1991 if((i & ~(num_group_tail_writes- 1)) == i) { 1991 if((i & ~(num_group_tail_writes- 1)) == i) {
1992 /* Force memory writes to complete before letting h/w 1992 /* Force memory writes to complete before letting h/w
@@ -2099,54 +2099,6 @@ ixgb_restore_vlan(struct ixgb_adapter *adapter)
2099 } 2099 }
2100} 2100}
2101 2101
2102/**
2103 * ixgb_notify_reboot - handles OS notification of reboot event.
2104 * @param nb notifier block, unused
2105 * @param event Event being passed to driver to act upon
2106 * @param p A pointer to our net device
2107 **/
2108static int
2109ixgb_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
2110{
2111 struct pci_dev *pdev = NULL;
2112
2113 switch(event) {
2114 case SYS_DOWN:
2115 case SYS_HALT:
2116 case SYS_POWER_OFF:
2117 while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
2118 if (pci_dev_driver(pdev) == &ixgb_driver)
2119 ixgb_suspend(pdev, 3);
2120 }
2121 }
2122 return NOTIFY_DONE;
2123}
2124
2125/**
2126 * ixgb_suspend - driver suspend function called from notify.
2127 * @param pdev pci driver structure used for passing to
2128 * @param state power state to enter
2129 **/
2130static int
2131ixgb_suspend(struct pci_dev *pdev, uint32_t state)
2132{
2133 struct net_device *netdev = pci_get_drvdata(pdev);
2134 struct ixgb_adapter *adapter = netdev->priv;
2135
2136 netif_device_detach(netdev);
2137
2138 if(netif_running(netdev))
2139 ixgb_down(adapter, TRUE);
2140
2141 pci_save_state(pdev);
2142
2143 state = (state > 0) ? 3 : 0;
2144 pci_set_power_state(pdev, state);
2145 msec_delay(200);
2146
2147 return 0;
2148}
2149
2150#ifdef CONFIG_NET_POLL_CONTROLLER 2102#ifdef CONFIG_NET_POLL_CONTROLLER
2151/* 2103/*
2152 * Polling 'interrupt' - used by things like netconsole to send skbs 2104 * Polling 'interrupt' - used by things like netconsole to send skbs
@@ -2157,6 +2109,7 @@ ixgb_suspend(struct pci_dev *pdev, uint32_t state)
2157static void ixgb_netpoll(struct net_device *dev) 2109static void ixgb_netpoll(struct net_device *dev)
2158{ 2110{
2159 struct ixgb_adapter *adapter = dev->priv; 2111 struct ixgb_adapter *adapter = dev->priv;
2112
2160 disable_irq(adapter->pdev->irq); 2113 disable_irq(adapter->pdev->irq);
2161 ixgb_intr(adapter->pdev->irq, dev, NULL); 2114 ixgb_intr(adapter->pdev->irq, dev, NULL);
2162 enable_irq(adapter->pdev->irq); 2115 enable_irq(adapter->pdev->irq);
diff --git a/drivers/net/ixgb/ixgb_osdep.h b/drivers/net/ixgb/ixgb_osdep.h
index 9eba92891901..dba20481ee80 100644
--- a/drivers/net/ixgb/ixgb_osdep.h
+++ b/drivers/net/ixgb/ixgb_osdep.h
@@ -45,8 +45,7 @@
45 /* Don't mdelay in interrupt context! */ \ 45 /* Don't mdelay in interrupt context! */ \
46 BUG(); \ 46 BUG(); \
47 } else { \ 47 } else { \
48 set_current_state(TASK_UNINTERRUPTIBLE); \ 48 msleep(x); \
49 schedule_timeout((x * HZ)/1000 + 2); \
50 } } while(0) 49 } } while(0)
51#endif 50#endif
52 51
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index 223bdadd4c0d..babb59e146ea 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -2433,9 +2433,9 @@ static void __set_rx_mode(struct net_device *dev)
2433 rx_mode = RxFilterEnable | AcceptBroadcast 2433 rx_mode = RxFilterEnable | AcceptBroadcast
2434 | AcceptMulticast | AcceptMyPhys; 2434 | AcceptMulticast | AcceptMyPhys;
2435 for (i = 0; i < 64; i += 2) { 2435 for (i = 0; i < 64; i += 2) {
2436 writew(HASH_TABLE + i, ioaddr + RxFilterAddr); 2436 writel(HASH_TABLE + i, ioaddr + RxFilterAddr);
2437 writew((mc_filter[i+1]<<8) + mc_filter[i], 2437 writel((mc_filter[i + 1] << 8) + mc_filter[i],
2438 ioaddr + RxFilterData); 2438 ioaddr + RxFilterData);
2439 } 2439 }
2440 } 2440 }
2441 writel(rx_mode, ioaddr + RxFilterAddr); 2441 writel(rx_mode, ioaddr + RxFilterAddr);
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index 2fcc181a8624..c336b46bd332 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -1,4 +1,4 @@
1#define _VERSION "0.20" 1#define VERSION "0.22"
2/* ns83820.c by Benjamin LaHaise with contributions. 2/* ns83820.c by Benjamin LaHaise with contributions.
3 * 3 *
4 * Questions/comments/discussion to linux-ns83820@kvack.org. 4 * Questions/comments/discussion to linux-ns83820@kvack.org.
@@ -63,9 +63,11 @@
63 * - fix missed txok introduced during performance 63 * - fix missed txok introduced during performance
64 * tuning 64 * tuning
65 * 0.20 - fix stupid RFEN thinko. i am such a smurf. 65 * 0.20 - fix stupid RFEN thinko. i am such a smurf.
66 *
67 * 20040828 0.21 - add hardware vlan accleration 66 * 20040828 0.21 - add hardware vlan accleration
68 * by Neil Horman <nhorman@redhat.com> 67 * by Neil Horman <nhorman@redhat.com>
68 * 20050406 0.22 - improved DAC ifdefs from Andi Kleen
69 * - removal of dead code from Adrian Bunk
70 * - fix half duplex collision behaviour
69 * Driver Overview 71 * Driver Overview
70 * =============== 72 * ===============
71 * 73 *
@@ -129,18 +131,6 @@ static int lnksts = 0; /* CFG_LNKSTS bit polarity */
129#undef Dprintk 131#undef Dprintk
130#define Dprintk dprintk 132#define Dprintk dprintk
131 133
132#if defined(CONFIG_HIGHMEM64G) || defined(__ia64__)
133#define USE_64BIT_ADDR "+"
134#endif
135
136#if defined(USE_64BIT_ADDR)
137#define VERSION _VERSION USE_64BIT_ADDR
138#define TRY_DAC 1
139#else
140#define VERSION _VERSION
141#define TRY_DAC 0
142#endif
143
144/* tunables */ 134/* tunables */
145#define RX_BUF_SIZE 1500 /* 8192 */ 135#define RX_BUF_SIZE 1500 /* 8192 */
146#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 136#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
@@ -386,22 +376,16 @@ static int lnksts = 0; /* CFG_LNKSTS bit polarity */
386#define LINK_DOWN 0x02 376#define LINK_DOWN 0x02
387#define LINK_UP 0x04 377#define LINK_UP 0x04
388 378
389#ifdef USE_64BIT_ADDR 379#define HW_ADDR_LEN sizeof(dma_addr_t)
390#define HW_ADDR_LEN 8
391#define desc_addr_set(desc, addr) \ 380#define desc_addr_set(desc, addr) \
392 do { \ 381 do { \
393 u64 __addr = (addr); \ 382 ((desc)[0] = cpu_to_le32(addr)); \
394 (desc)[0] = cpu_to_le32(__addr); \ 383 if (HW_ADDR_LEN == 8) \
395 (desc)[1] = cpu_to_le32(__addr >> 32); \ 384 (desc)[1] = cpu_to_le32(((u64)addr) >> 32); \
396 } while(0) 385 } while(0)
397#define desc_addr_get(desc) \ 386#define desc_addr_get(desc) \
398 (((u64)le32_to_cpu((desc)[1]) << 32) \ 387 (le32_to_cpu((desc)[0]) | \
399 | le32_to_cpu((desc)[0])) 388 (HW_ADDR_LEN == 8 ? ((dma_addr_t)le32_to_cpu((desc)[1]))<<32 : 0))
400#else
401#define HW_ADDR_LEN 4
402#define desc_addr_set(desc, addr) ((desc)[0] = cpu_to_le32(addr))
403#define desc_addr_get(desc) (le32_to_cpu((desc)[0]))
404#endif
405 389
406#define DESC_LINK 0 390#define DESC_LINK 0
407#define DESC_BUFPTR (DESC_LINK + HW_ADDR_LEN/4) 391#define DESC_BUFPTR (DESC_LINK + HW_ADDR_LEN/4)
@@ -727,11 +711,23 @@ static void fastcall phy_intr(struct net_device *ndev)
727 speed = ((cfg / CFG_SPDSTS0) & 3); 711 speed = ((cfg / CFG_SPDSTS0) & 3);
728 fullduplex = (cfg & CFG_DUPSTS); 712 fullduplex = (cfg & CFG_DUPSTS);
729 713
730 if (fullduplex) 714 if (fullduplex) {
731 new_cfg |= CFG_SB; 715 new_cfg |= CFG_SB;
716 writel(readl(dev->base + TXCFG)
717 | TXCFG_CSI | TXCFG_HBI,
718 dev->base + TXCFG);
719 writel(readl(dev->base + RXCFG) | RXCFG_RX_FD,
720 dev->base + RXCFG);
721 } else {
722 writel(readl(dev->base + TXCFG)
723 & ~(TXCFG_CSI | TXCFG_HBI),
724 dev->base + TXCFG);
725 writel(readl(dev->base + RXCFG) & ~(RXCFG_RX_FD),
726 dev->base + RXCFG);
727 }
732 728
733 if ((cfg & CFG_LNKSTS) && 729 if ((cfg & CFG_LNKSTS) &&
734 ((new_cfg ^ dev->CFG_cache) & CFG_MODE_1000)) { 730 ((new_cfg ^ dev->CFG_cache) != 0)) {
735 writel(new_cfg, dev->base + CFG); 731 writel(new_cfg, dev->base + CFG);
736 dev->CFG_cache = new_cfg; 732 dev->CFG_cache = new_cfg;
737 } 733 }
@@ -1189,7 +1185,6 @@ again:
1189 1185
1190 for (;;) { 1186 for (;;) {
1191 volatile u32 *desc = dev->tx_descs + (free_idx * DESC_SIZE); 1187 volatile u32 *desc = dev->tx_descs + (free_idx * DESC_SIZE);
1192 u32 residue = 0;
1193 1188
1194 dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len, 1189 dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len,
1195 (unsigned long long)buf); 1190 (unsigned long long)buf);
@@ -1199,17 +1194,11 @@ again:
1199 desc_addr_set(desc + DESC_BUFPTR, buf); 1194 desc_addr_set(desc + DESC_BUFPTR, buf);
1200 desc[DESC_EXTSTS] = cpu_to_le32(extsts); 1195 desc[DESC_EXTSTS] = cpu_to_le32(extsts);
1201 1196
1202 cmdsts = ((nr_frags|residue) ? CMDSTS_MORE : do_intr ? CMDSTS_INTR : 0); 1197 cmdsts = ((nr_frags) ? CMDSTS_MORE : do_intr ? CMDSTS_INTR : 0);
1203 cmdsts |= (desc == first_desc) ? 0 : CMDSTS_OWN; 1198 cmdsts |= (desc == first_desc) ? 0 : CMDSTS_OWN;
1204 cmdsts |= len; 1199 cmdsts |= len;
1205 desc[DESC_CMDSTS] = cpu_to_le32(cmdsts); 1200 desc[DESC_CMDSTS] = cpu_to_le32(cmdsts);
1206 1201
1207 if (residue) {
1208 buf += len;
1209 len = residue;
1210 continue;
1211 }
1212
1213 if (!nr_frags) 1202 if (!nr_frags)
1214 break; 1203 break;
1215 1204
@@ -1841,7 +1830,8 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1841 int using_dac = 0; 1830 int using_dac = 0;
1842 1831
1843 /* See if we can set the dma mask early on; failure is fatal. */ 1832 /* See if we can set the dma mask early on; failure is fatal. */
1844 if (TRY_DAC && !pci_set_dma_mask(pci_dev, 0xffffffffffffffffULL)) { 1833 if (sizeof(dma_addr_t) == 8 &&
1834 !pci_set_dma_mask(pci_dev, 0xffffffffffffffffULL)) {
1845 using_dac = 1; 1835 using_dac = 1;
1846 } else if (!pci_set_dma_mask(pci_dev, 0xffffffff)) { 1836 } else if (!pci_set_dma_mask(pci_dev, 0xffffffff)) {
1847 using_dac = 0; 1837 using_dac = 0;
@@ -1972,9 +1962,8 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1972 /* When compiled with 64 bit addressing, we must always enable 1962 /* When compiled with 64 bit addressing, we must always enable
1973 * the 64 bit descriptor format. 1963 * the 64 bit descriptor format.
1974 */ 1964 */
1975#ifdef USE_64BIT_ADDR 1965 if (sizeof(dma_addr_t) == 8)
1976 dev->CFG_cache |= CFG_M64ADDR; 1966 dev->CFG_cache |= CFG_M64ADDR;
1977#endif
1978 if (using_dac) 1967 if (using_dac)
1979 dev->CFG_cache |= CFG_T64ADDR; 1968 dev->CFG_cache |= CFG_T64ADDR;
1980 1969
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 17947e6c8793..13f114876965 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -22,8 +22,8 @@
22 *************************************************************************/ 22 *************************************************************************/
23 23
24#define DRV_NAME "pcnet32" 24#define DRV_NAME "pcnet32"
25#define DRV_VERSION "1.30i" 25#define DRV_VERSION "1.30j"
26#define DRV_RELDATE "06.28.2004" 26#define DRV_RELDATE "29.04.2005"
27#define PFX DRV_NAME ": " 27#define PFX DRV_NAME ": "
28 28
29static const char *version = 29static const char *version =
@@ -256,6 +256,7 @@ static int homepna[MAX_UNITS];
256 * homepna for selecting HomePNA mode for PCNet/Home 79C978. 256 * homepna for selecting HomePNA mode for PCNet/Home 79C978.
257 * v1.30h 24 Jun 2004 Don Fry correctly select auto, speed, duplex in bcr32. 257 * v1.30h 24 Jun 2004 Don Fry correctly select auto, speed, duplex in bcr32.
258 * v1.30i 28 Jun 2004 Don Fry change to use module_param. 258 * v1.30i 28 Jun 2004 Don Fry change to use module_param.
259 * v1.30j 29 Apr 2005 Don Fry fix skb/map leak with loopback test.
259 */ 260 */
260 261
261 262
@@ -395,6 +396,7 @@ static void pcnet32_led_blink_callback(struct net_device *dev);
395static int pcnet32_get_regs_len(struct net_device *dev); 396static int pcnet32_get_regs_len(struct net_device *dev);
396static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs, 397static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs,
397 void *ptr); 398 void *ptr);
399static void pcnet32_purge_tx_ring(struct net_device *dev);
398 400
399enum pci_flags_bit { 401enum pci_flags_bit {
400 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4, 402 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
@@ -785,6 +787,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t *data1)
785 } 787 }
786 788
787clean_up: 789clean_up:
790 pcnet32_purge_tx_ring(dev);
788 x = a->read_csr(ioaddr, 15) & 0xFFFF; 791 x = a->read_csr(ioaddr, 15) & 0xFFFF;
789 a->write_csr(ioaddr, 15, (x & ~0x0044)); /* reset bits 6 and 2 */ 792 a->write_csr(ioaddr, 15, (x & ~0x0044)); /* reset bits 6 and 2 */
790 793
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index 3e9d9aab0588..3107aed0fb51 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -162,6 +162,7 @@ struct sis900_private {
162 struct mii_phy * mii; 162 struct mii_phy * mii;
163 struct mii_phy * first_mii; /* record the first mii structure */ 163 struct mii_phy * first_mii; /* record the first mii structure */
164 unsigned int cur_phy; 164 unsigned int cur_phy;
165 struct mii_if_info mii_info;
165 166
166 struct timer_list timer; /* Link status detection timer. */ 167 struct timer_list timer; /* Link status detection timer. */
167 u8 autong_complete; /* 1: auto-negotiate complete */ 168 u8 autong_complete; /* 1: auto-negotiate complete */
@@ -203,7 +204,7 @@ static int sis900_open(struct net_device *net_dev);
203static int sis900_mii_probe (struct net_device * net_dev); 204static int sis900_mii_probe (struct net_device * net_dev);
204static void sis900_init_rxfilter (struct net_device * net_dev); 205static void sis900_init_rxfilter (struct net_device * net_dev);
205static u16 read_eeprom(long ioaddr, int location); 206static u16 read_eeprom(long ioaddr, int location);
206static u16 mdio_read(struct net_device *net_dev, int phy_id, int location); 207static int mdio_read(struct net_device *net_dev, int phy_id, int location);
207static void mdio_write(struct net_device *net_dev, int phy_id, int location, int val); 208static void mdio_write(struct net_device *net_dev, int phy_id, int location, int val);
208static void sis900_timer(unsigned long data); 209static void sis900_timer(unsigned long data);
209static void sis900_check_mode (struct net_device *net_dev, struct mii_phy *mii_phy); 210static void sis900_check_mode (struct net_device *net_dev, struct mii_phy *mii_phy);
@@ -478,7 +479,13 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
478 sis_priv->msg_enable = sis900_debug; 479 sis_priv->msg_enable = sis900_debug;
479 else 480 else
480 sis_priv->msg_enable = SIS900_DEF_MSG; 481 sis_priv->msg_enable = SIS900_DEF_MSG;
481 482
483 sis_priv->mii_info.dev = net_dev;
484 sis_priv->mii_info.mdio_read = mdio_read;
485 sis_priv->mii_info.mdio_write = mdio_write;
486 sis_priv->mii_info.phy_id_mask = 0x1f;
487 sis_priv->mii_info.reg_num_mask = 0x1f;
488
482 /* Get Mac address according to the chip revision */ 489 /* Get Mac address according to the chip revision */
483 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &(sis_priv->chipset_rev)); 490 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &(sis_priv->chipset_rev));
484 if(netif_msg_probe(sis_priv)) 491 if(netif_msg_probe(sis_priv))
@@ -725,6 +732,8 @@ static u16 sis900_default_phy(struct net_device * net_dev)
725 pci_name(sis_priv->pci_dev), sis_priv->cur_phy); 732 pci_name(sis_priv->pci_dev), sis_priv->cur_phy);
726 } 733 }
727 734
735 sis_priv->mii_info.phy_id = sis_priv->cur_phy;
736
728 status = mdio_read(net_dev, sis_priv->cur_phy, MII_CONTROL); 737 status = mdio_read(net_dev, sis_priv->cur_phy, MII_CONTROL);
729 status &= (~MII_CNTL_ISOLATE); 738 status &= (~MII_CNTL_ISOLATE);
730 739
@@ -852,7 +861,7 @@ static void mdio_reset(long mdio_addr)
852 * Please see SiS7014 or ICS spec 861 * Please see SiS7014 or ICS spec
853 */ 862 */
854 863
855static u16 mdio_read(struct net_device *net_dev, int phy_id, int location) 864static int mdio_read(struct net_device *net_dev, int phy_id, int location)
856{ 865{
857 long mdio_addr = net_dev->base_addr + mear; 866 long mdio_addr = net_dev->base_addr + mear;
858 int mii_cmd = MIIread|(phy_id<<MIIpmdShift)|(location<<MIIregShift); 867 int mii_cmd = MIIread|(phy_id<<MIIpmdShift)|(location<<MIIregShift);
@@ -1966,10 +1975,47 @@ static void sis900_set_msglevel(struct net_device *net_dev, u32 value)
1966 sis_priv->msg_enable = value; 1975 sis_priv->msg_enable = value;
1967} 1976}
1968 1977
1978static u32 sis900_get_link(struct net_device *net_dev)
1979{
1980 struct sis900_private *sis_priv = net_dev->priv;
1981 return mii_link_ok(&sis_priv->mii_info);
1982}
1983
1984static int sis900_get_settings(struct net_device *net_dev,
1985 struct ethtool_cmd *cmd)
1986{
1987 struct sis900_private *sis_priv = net_dev->priv;
1988 spin_lock_irq(&sis_priv->lock);
1989 mii_ethtool_gset(&sis_priv->mii_info, cmd);
1990 spin_unlock_irq(&sis_priv->lock);
1991 return 0;
1992}
1993
1994static int sis900_set_settings(struct net_device *net_dev,
1995 struct ethtool_cmd *cmd)
1996{
1997 struct sis900_private *sis_priv = net_dev->priv;
1998 int rt;
1999 spin_lock_irq(&sis_priv->lock);
2000 rt = mii_ethtool_sset(&sis_priv->mii_info, cmd);
2001 spin_unlock_irq(&sis_priv->lock);
2002 return rt;
2003}
2004
2005static int sis900_nway_reset(struct net_device *net_dev)
2006{
2007 struct sis900_private *sis_priv = net_dev->priv;
2008 return mii_nway_restart(&sis_priv->mii_info);
2009}
2010
1969static struct ethtool_ops sis900_ethtool_ops = { 2011static struct ethtool_ops sis900_ethtool_ops = {
1970 .get_drvinfo = sis900_get_drvinfo, 2012 .get_drvinfo = sis900_get_drvinfo,
1971 .get_msglevel = sis900_get_msglevel, 2013 .get_msglevel = sis900_get_msglevel,
1972 .set_msglevel = sis900_set_msglevel, 2014 .set_msglevel = sis900_set_msglevel,
2015 .get_link = sis900_get_link,
2016 .get_settings = sis900_get_settings,
2017 .set_settings = sis900_set_settings,
2018 .nway_reset = sis900_nway_reset,
1973}; 2019};
1974 2020
1975/** 2021/**
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index f79b02e80e75..f10dd74988c4 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -61,8 +61,8 @@
61 61
62#define DRV_MODULE_NAME "tg3" 62#define DRV_MODULE_NAME "tg3"
63#define PFX DRV_MODULE_NAME ": " 63#define PFX DRV_MODULE_NAME ": "
64#define DRV_MODULE_VERSION "3.27" 64#define DRV_MODULE_VERSION "3.29"
65#define DRV_MODULE_RELDATE "May 5, 2005" 65#define DRV_MODULE_RELDATE "May 23, 2005"
66 66
67#define TG3_DEF_MAC_MODE 0 67#define TG3_DEF_MAC_MODE 0
68#define TG3_DEF_RX_MODE 0 68#define TG3_DEF_RX_MODE 0
@@ -206,6 +206,8 @@ static struct pci_device_id tg3_pci_tbl[] = {
206 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 206 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
207 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5752, 207 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5752,
208 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 208 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
209 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5752M,
210 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
209 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753, 211 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753,
210 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 212 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
211 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753M, 213 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753M,
@@ -420,7 +422,8 @@ static void tg3_enable_ints(struct tg3 *tp)
420{ 422{
421 tw32(TG3PCI_MISC_HOST_CTRL, 423 tw32(TG3PCI_MISC_HOST_CTRL,
422 (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT)); 424 (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT));
423 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000); 425 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
426 (tp->last_tag << 24));
424 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); 427 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
425 428
426 tg3_cond_int(tp); 429 tg3_cond_int(tp);
@@ -455,10 +458,16 @@ static void tg3_restart_ints(struct tg3 *tp)
455{ 458{
456 tw32(TG3PCI_MISC_HOST_CTRL, 459 tw32(TG3PCI_MISC_HOST_CTRL,
457 (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT)); 460 (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT));
458 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000); 461 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
462 tp->last_tag << 24);
459 mmiowb(); 463 mmiowb();
460 464
461 if (tg3_has_work(tp)) 465 /* When doing tagged status, this work check is unnecessary.
466 * The last_tag we write above tells the chip which piece of
467 * work we've completed.
468 */
469 if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) &&
470 tg3_has_work(tp))
462 tw32(HOSTCC_MODE, tp->coalesce_mode | 471 tw32(HOSTCC_MODE, tp->coalesce_mode |
463 (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW)); 472 (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW));
464} 473}
@@ -2500,7 +2509,7 @@ static int tg3_setup_phy(struct tg3 *tp, int force_reset)
2500 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 2509 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
2501 if (netif_carrier_ok(tp->dev)) { 2510 if (netif_carrier_ok(tp->dev)) {
2502 tw32(HOSTCC_STAT_COAL_TICKS, 2511 tw32(HOSTCC_STAT_COAL_TICKS,
2503 DEFAULT_STAT_COAL_TICKS); 2512 tp->coal.stats_block_coalesce_usecs);
2504 } else { 2513 } else {
2505 tw32(HOSTCC_STAT_COAL_TICKS, 0); 2514 tw32(HOSTCC_STAT_COAL_TICKS, 0);
2506 } 2515 }
@@ -2886,7 +2895,6 @@ static int tg3_poll(struct net_device *netdev, int *budget)
2886 * All RX "locking" is done by ensuring outside 2895 * All RX "locking" is done by ensuring outside
2887 * code synchronizes with dev->poll() 2896 * code synchronizes with dev->poll()
2888 */ 2897 */
2889 done = 1;
2890 if (sblk->idx[0].rx_producer != tp->rx_rcb_ptr) { 2898 if (sblk->idx[0].rx_producer != tp->rx_rcb_ptr) {
2891 int orig_budget = *budget; 2899 int orig_budget = *budget;
2892 int work_done; 2900 int work_done;
@@ -2898,12 +2906,14 @@ static int tg3_poll(struct net_device *netdev, int *budget)
2898 2906
2899 *budget -= work_done; 2907 *budget -= work_done;
2900 netdev->quota -= work_done; 2908 netdev->quota -= work_done;
2901
2902 if (work_done >= orig_budget)
2903 done = 0;
2904 } 2909 }
2905 2910
2911 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)
2912 tp->last_tag = sblk->status_tag;
2913 rmb();
2914
2906 /* if no more work, tell net stack and NIC we're done */ 2915 /* if no more work, tell net stack and NIC we're done */
2916 done = !tg3_has_work(tp);
2907 if (done) { 2917 if (done) {
2908 spin_lock_irqsave(&tp->lock, flags); 2918 spin_lock_irqsave(&tp->lock, flags);
2909 __netif_rx_complete(netdev); 2919 __netif_rx_complete(netdev);
@@ -2928,22 +2938,21 @@ static irqreturn_t tg3_msi(int irq, void *dev_id, struct pt_regs *regs)
2928 spin_lock_irqsave(&tp->lock, flags); 2938 spin_lock_irqsave(&tp->lock, flags);
2929 2939
2930 /* 2940 /*
2931 * writing any value to intr-mbox-0 clears PCI INTA# and 2941 * Writing any value to intr-mbox-0 clears PCI INTA# and
2932 * chip-internal interrupt pending events. 2942 * chip-internal interrupt pending events.
2933 * writing non-zero to intr-mbox-0 additional tells the 2943 * Writing non-zero to intr-mbox-0 additional tells the
2934 * NIC to stop sending us irqs, engaging "in-intr-handler" 2944 * NIC to stop sending us irqs, engaging "in-intr-handler"
2935 * event coalescing. 2945 * event coalescing.
2936 */ 2946 */
2937 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001); 2947 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
2948 tp->last_tag = sblk->status_tag;
2938 sblk->status &= ~SD_STATUS_UPDATED; 2949 sblk->status &= ~SD_STATUS_UPDATED;
2939
2940 if (likely(tg3_has_work(tp))) 2950 if (likely(tg3_has_work(tp)))
2941 netif_rx_schedule(dev); /* schedule NAPI poll */ 2951 netif_rx_schedule(dev); /* schedule NAPI poll */
2942 else { 2952 else {
2943 /* no work, re-enable interrupts 2953 /* No work, re-enable interrupts. */
2944 */
2945 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 2954 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
2946 0x00000000); 2955 tp->last_tag << 24);
2947 } 2956 }
2948 2957
2949 spin_unlock_irqrestore(&tp->lock, flags); 2958 spin_unlock_irqrestore(&tp->lock, flags);
@@ -2969,21 +2978,62 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2969 if ((sblk->status & SD_STATUS_UPDATED) || 2978 if ((sblk->status & SD_STATUS_UPDATED) ||
2970 !(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) { 2979 !(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) {
2971 /* 2980 /*
2972 * writing any value to intr-mbox-0 clears PCI INTA# and 2981 * Writing any value to intr-mbox-0 clears PCI INTA# and
2973 * chip-internal interrupt pending events. 2982 * chip-internal interrupt pending events.
2974 * writing non-zero to intr-mbox-0 additional tells the 2983 * Writing non-zero to intr-mbox-0 additional tells the
2975 * NIC to stop sending us irqs, engaging "in-intr-handler" 2984 * NIC to stop sending us irqs, engaging "in-intr-handler"
2976 * event coalescing. 2985 * event coalescing.
2977 */ 2986 */
2978 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 2987 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
2979 0x00000001); 2988 0x00000001);
2989 sblk->status &= ~SD_STATUS_UPDATED;
2990 if (likely(tg3_has_work(tp)))
2991 netif_rx_schedule(dev); /* schedule NAPI poll */
2992 else {
2993 /* No work, shared interrupt perhaps? re-enable
2994 * interrupts, and flush that PCI write
2995 */
2996 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
2997 0x00000000);
2998 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
2999 }
3000 } else { /* shared interrupt */
3001 handled = 0;
3002 }
3003
3004 spin_unlock_irqrestore(&tp->lock, flags);
3005
3006 return IRQ_RETVAL(handled);
3007}
3008
3009static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id, struct pt_regs *regs)
3010{
3011 struct net_device *dev = dev_id;
3012 struct tg3 *tp = netdev_priv(dev);
3013 struct tg3_hw_status *sblk = tp->hw_status;
3014 unsigned long flags;
3015 unsigned int handled = 1;
3016
3017 spin_lock_irqsave(&tp->lock, flags);
3018
3019 /* In INTx mode, it is possible for the interrupt to arrive at
3020 * the CPU before the status block posted prior to the interrupt.
3021 * Reading the PCI State register will confirm whether the
3022 * interrupt is ours and will flush the status block.
3023 */
3024 if ((sblk->status & SD_STATUS_UPDATED) ||
3025 !(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) {
2980 /* 3026 /*
2981 * Flush PCI write. This also guarantees that our 3027 * writing any value to intr-mbox-0 clears PCI INTA# and
2982 * status block has been flushed to host memory. 3028 * chip-internal interrupt pending events.
3029 * writing non-zero to intr-mbox-0 additional tells the
3030 * NIC to stop sending us irqs, engaging "in-intr-handler"
3031 * event coalescing.
2983 */ 3032 */
2984 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); 3033 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
3034 0x00000001);
3035 tp->last_tag = sblk->status_tag;
2985 sblk->status &= ~SD_STATUS_UPDATED; 3036 sblk->status &= ~SD_STATUS_UPDATED;
2986
2987 if (likely(tg3_has_work(tp))) 3037 if (likely(tg3_has_work(tp)))
2988 netif_rx_schedule(dev); /* schedule NAPI poll */ 3038 netif_rx_schedule(dev); /* schedule NAPI poll */
2989 else { 3039 else {
@@ -2991,7 +3041,7 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2991 * interrupts, and flush that PCI write 3041 * interrupts, and flush that PCI write
2992 */ 3042 */
2993 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 3043 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
2994 0x00000000); 3044 tp->last_tag << 24);
2995 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); 3045 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
2996 } 3046 }
2997 } else { /* shared interrupt */ 3047 } else { /* shared interrupt */
@@ -5044,6 +5094,27 @@ static void tg3_set_bdinfo(struct tg3 *tp, u32 bdinfo_addr,
5044} 5094}
5045 5095
5046static void __tg3_set_rx_mode(struct net_device *); 5096static void __tg3_set_rx_mode(struct net_device *);
5097static void tg3_set_coalesce(struct tg3 *tp, struct ethtool_coalesce *ec)
5098{
5099 tw32(HOSTCC_RXCOL_TICKS, ec->rx_coalesce_usecs);
5100 tw32(HOSTCC_TXCOL_TICKS, ec->tx_coalesce_usecs);
5101 tw32(HOSTCC_RXMAX_FRAMES, ec->rx_max_coalesced_frames);
5102 tw32(HOSTCC_TXMAX_FRAMES, ec->tx_max_coalesced_frames);
5103 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
5104 tw32(HOSTCC_RXCOAL_TICK_INT, ec->rx_coalesce_usecs_irq);
5105 tw32(HOSTCC_TXCOAL_TICK_INT, ec->tx_coalesce_usecs_irq);
5106 }
5107 tw32(HOSTCC_RXCOAL_MAXF_INT, ec->rx_max_coalesced_frames_irq);
5108 tw32(HOSTCC_TXCOAL_MAXF_INT, ec->tx_max_coalesced_frames_irq);
5109 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
5110 u32 val = ec->stats_block_coalesce_usecs;
5111
5112 if (!netif_carrier_ok(tp->dev))
5113 val = 0;
5114
5115 tw32(HOSTCC_STAT_COAL_TICKS, val);
5116 }
5117}
5047 5118
5048/* tp->lock is held. */ 5119/* tp->lock is held. */
5049static int tg3_reset_hw(struct tg3 *tp) 5120static int tg3_reset_hw(struct tg3 *tp)
@@ -5366,16 +5437,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5366 udelay(10); 5437 udelay(10);
5367 } 5438 }
5368 5439
5369 tw32(HOSTCC_RXCOL_TICKS, 0); 5440 tg3_set_coalesce(tp, &tp->coal);
5370 tw32(HOSTCC_TXCOL_TICKS, LOW_TXCOL_TICKS);
5371 tw32(HOSTCC_RXMAX_FRAMES, 1);
5372 tw32(HOSTCC_TXMAX_FRAMES, LOW_RXMAX_FRAMES);
5373 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
5374 tw32(HOSTCC_RXCOAL_TICK_INT, 0);
5375 tw32(HOSTCC_TXCOAL_TICK_INT, 0);
5376 }
5377 tw32(HOSTCC_RXCOAL_MAXF_INT, 1);
5378 tw32(HOSTCC_TXCOAL_MAXF_INT, 0);
5379 5441
5380 /* set status block DMA address */ 5442 /* set status block DMA address */
5381 tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, 5443 tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
@@ -5388,8 +5450,6 @@ static int tg3_reset_hw(struct tg3 *tp)
5388 * the tg3_periodic_fetch_stats call there, and 5450 * the tg3_periodic_fetch_stats call there, and
5389 * tg3_get_stats to see how this works for 5705/5750 chips. 5451 * tg3_get_stats to see how this works for 5705/5750 chips.
5390 */ 5452 */
5391 tw32(HOSTCC_STAT_COAL_TICKS,
5392 DEFAULT_STAT_COAL_TICKS);
5393 tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, 5453 tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
5394 ((u64) tp->stats_mapping >> 32)); 5454 ((u64) tp->stats_mapping >> 32));
5395 tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW, 5455 tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
@@ -5445,7 +5505,8 @@ static int tg3_reset_hw(struct tg3 *tp)
5445 udelay(100); 5505 udelay(100);
5446 5506
5447 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0); 5507 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0);
5448 tr32(MAILBOX_INTERRUPT_0); 5508 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
5509 tp->last_tag = 0;
5449 5510
5450 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 5511 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
5451 tw32_f(DMAC_MODE, DMAC_MODE_ENABLE); 5512 tw32_f(DMAC_MODE, DMAC_MODE_ENABLE);
@@ -5723,31 +5784,33 @@ static void tg3_timer(unsigned long __opaque)
5723 spin_lock_irqsave(&tp->lock, flags); 5784 spin_lock_irqsave(&tp->lock, flags);
5724 spin_lock(&tp->tx_lock); 5785 spin_lock(&tp->tx_lock);
5725 5786
5726 /* All of this garbage is because when using non-tagged 5787 if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) {
5727 * IRQ status the mailbox/status_block protocol the chip 5788 /* All of this garbage is because when using non-tagged
5728 * uses with the cpu is race prone. 5789 * IRQ status the mailbox/status_block protocol the chip
5729 */ 5790 * uses with the cpu is race prone.
5730 if (tp->hw_status->status & SD_STATUS_UPDATED) { 5791 */
5731 tw32(GRC_LOCAL_CTRL, 5792 if (tp->hw_status->status & SD_STATUS_UPDATED) {
5732 tp->grc_local_ctrl | GRC_LCLCTRL_SETINT); 5793 tw32(GRC_LOCAL_CTRL,
5733 } else { 5794 tp->grc_local_ctrl | GRC_LCLCTRL_SETINT);
5734 tw32(HOSTCC_MODE, tp->coalesce_mode | 5795 } else {
5735 (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW)); 5796 tw32(HOSTCC_MODE, tp->coalesce_mode |
5736 } 5797 (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW));
5798 }
5737 5799
5738 if (!(tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) { 5800 if (!(tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {
5739 tp->tg3_flags2 |= TG3_FLG2_RESTART_TIMER; 5801 tp->tg3_flags2 |= TG3_FLG2_RESTART_TIMER;
5740 spin_unlock(&tp->tx_lock); 5802 spin_unlock(&tp->tx_lock);
5741 spin_unlock_irqrestore(&tp->lock, flags); 5803 spin_unlock_irqrestore(&tp->lock, flags);
5742 schedule_work(&tp->reset_task); 5804 schedule_work(&tp->reset_task);
5743 return; 5805 return;
5806 }
5744 } 5807 }
5745 5808
5746 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)
5747 tg3_periodic_fetch_stats(tp);
5748
5749 /* This part only runs once per second. */ 5809 /* This part only runs once per second. */
5750 if (!--tp->timer_counter) { 5810 if (!--tp->timer_counter) {
5811 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)
5812 tg3_periodic_fetch_stats(tp);
5813
5751 if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) { 5814 if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) {
5752 u32 mac_stat; 5815 u32 mac_stat;
5753 int phy_event; 5816 int phy_event;
@@ -5846,9 +5909,13 @@ static int tg3_test_interrupt(struct tg3 *tp)
5846 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) 5909 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI)
5847 err = request_irq(tp->pdev->irq, tg3_msi, 5910 err = request_irq(tp->pdev->irq, tg3_msi,
5848 SA_SAMPLE_RANDOM, dev->name, dev); 5911 SA_SAMPLE_RANDOM, dev->name, dev);
5849 else 5912 else {
5850 err = request_irq(tp->pdev->irq, tg3_interrupt, 5913 irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt;
5914 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)
5915 fn = tg3_interrupt_tagged;
5916 err = request_irq(tp->pdev->irq, fn,
5851 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); 5917 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
5918 }
5852 5919
5853 if (err) 5920 if (err)
5854 return err; 5921 return err;
@@ -5900,9 +5967,14 @@ static int tg3_test_msi(struct tg3 *tp)
5900 5967
5901 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; 5968 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
5902 5969
5903 err = request_irq(tp->pdev->irq, tg3_interrupt, 5970 {
5904 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); 5971 irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt;
5972 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)
5973 fn = tg3_interrupt_tagged;
5905 5974
5975 err = request_irq(tp->pdev->irq, fn,
5976 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
5977 }
5906 if (err) 5978 if (err)
5907 return err; 5979 return err;
5908 5980
@@ -5948,7 +6020,13 @@ static int tg3_open(struct net_device *dev)
5948 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && 6020 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
5949 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) && 6021 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) &&
5950 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX)) { 6022 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX)) {
5951 if (pci_enable_msi(tp->pdev) == 0) { 6023 /* All MSI supporting chips should support tagged
6024 * status. Assert that this is the case.
6025 */
6026 if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) {
6027 printk(KERN_WARNING PFX "%s: MSI without TAGGED? "
6028 "Not using MSI.\n", tp->dev->name);
6029 } else if (pci_enable_msi(tp->pdev) == 0) {
5952 u32 msi_mode; 6030 u32 msi_mode;
5953 6031
5954 msi_mode = tr32(MSGINT_MODE); 6032 msi_mode = tr32(MSGINT_MODE);
@@ -5959,9 +6037,14 @@ static int tg3_open(struct net_device *dev)
5959 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) 6037 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI)
5960 err = request_irq(tp->pdev->irq, tg3_msi, 6038 err = request_irq(tp->pdev->irq, tg3_msi,
5961 SA_SAMPLE_RANDOM, dev->name, dev); 6039 SA_SAMPLE_RANDOM, dev->name, dev);
5962 else 6040 else {
5963 err = request_irq(tp->pdev->irq, tg3_interrupt, 6041 irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt;
6042 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)
6043 fn = tg3_interrupt_tagged;
6044
6045 err = request_irq(tp->pdev->irq, fn,
5964 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); 6046 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
6047 }
5965 6048
5966 if (err) { 6049 if (err) {
5967 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { 6050 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
@@ -5980,9 +6063,16 @@ static int tg3_open(struct net_device *dev)
5980 tg3_halt(tp, 1); 6063 tg3_halt(tp, 1);
5981 tg3_free_rings(tp); 6064 tg3_free_rings(tp);
5982 } else { 6065 } else {
5983 tp->timer_offset = HZ / 10; 6066 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)
5984 tp->timer_counter = tp->timer_multiplier = 10; 6067 tp->timer_offset = HZ;
5985 tp->asf_counter = tp->asf_multiplier = (10 * 120); 6068 else
6069 tp->timer_offset = HZ / 10;
6070
6071 BUG_ON(tp->timer_offset > HZ);
6072 tp->timer_counter = tp->timer_multiplier =
6073 (HZ / tp->timer_offset);
6074 tp->asf_counter = tp->asf_multiplier =
6075 ((HZ / tp->timer_offset) * 120);
5986 6076
5987 init_timer(&tp->timer); 6077 init_timer(&tp->timer);
5988 tp->timer.expires = jiffies + tp->timer_offset; 6078 tp->timer.expires = jiffies + tp->timer_offset;
@@ -6005,6 +6095,7 @@ static int tg3_open(struct net_device *dev)
6005 6095
6006 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { 6096 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
6007 err = tg3_test_msi(tp); 6097 err = tg3_test_msi(tp);
6098
6008 if (err) { 6099 if (err) {
6009 spin_lock_irq(&tp->lock); 6100 spin_lock_irq(&tp->lock);
6010 spin_lock(&tp->tx_lock); 6101 spin_lock(&tp->tx_lock);
@@ -7203,6 +7294,14 @@ static void tg3_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
7203} 7294}
7204#endif 7295#endif
7205 7296
7297static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
7298{
7299 struct tg3 *tp = netdev_priv(dev);
7300
7301 memcpy(ec, &tp->coal, sizeof(*ec));
7302 return 0;
7303}
7304
7206static struct ethtool_ops tg3_ethtool_ops = { 7305static struct ethtool_ops tg3_ethtool_ops = {
7207 .get_settings = tg3_get_settings, 7306 .get_settings = tg3_get_settings,
7208 .set_settings = tg3_set_settings, 7307 .set_settings = tg3_set_settings,
@@ -7235,6 +7334,7 @@ static struct ethtool_ops tg3_ethtool_ops = {
7235 .get_strings = tg3_get_strings, 7334 .get_strings = tg3_get_strings,
7236 .get_stats_count = tg3_get_stats_count, 7335 .get_stats_count = tg3_get_stats_count,
7237 .get_ethtool_stats = tg3_get_ethtool_stats, 7336 .get_ethtool_stats = tg3_get_ethtool_stats,
7337 .get_coalesce = tg3_get_coalesce,
7238}; 7338};
7239 7339
7240static void __devinit tg3_get_eeprom_size(struct tg3 *tp) 7340static void __devinit tg3_get_eeprom_size(struct tg3 *tp)
@@ -8422,15 +8522,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
8422 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) 8522 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)
8423 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; 8523 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG;
8424 8524
8425 /* Only 5701 and later support tagged irq status mode.
8426 * Also, 5788 chips cannot use tagged irq status.
8427 *
8428 * However, since we are using NAPI avoid tagged irq status
8429 * because the interrupt condition is more difficult to
8430 * fully clear in that mode.
8431 */
8432 tp->coalesce_mode = 0; 8525 tp->coalesce_mode = 0;
8433
8434 if (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_AX && 8526 if (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_AX &&
8435 GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_BX) 8527 GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_BX)
8436 tp->coalesce_mode |= HOSTCC_MODE_32BYTE; 8528 tp->coalesce_mode |= HOSTCC_MODE_32BYTE;
@@ -8494,6 +8586,18 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
8494 grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788M)) 8586 grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788M))
8495 tp->tg3_flags2 |= TG3_FLG2_IS_5788; 8587 tp->tg3_flags2 |= TG3_FLG2_IS_5788;
8496 8588
8589 if (!(tp->tg3_flags2 & TG3_FLG2_IS_5788) &&
8590 (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700))
8591 tp->tg3_flags |= TG3_FLAG_TAGGED_STATUS;
8592 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) {
8593 tp->coalesce_mode |= (HOSTCC_MODE_CLRTICK_RXBD |
8594 HOSTCC_MODE_CLRTICK_TXBD);
8595
8596 tp->misc_host_ctrl |= MISC_HOST_CTRL_TAGGED_STATUS;
8597 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
8598 tp->misc_host_ctrl);
8599 }
8600
8497 /* these are limited to 10/100 only */ 8601 /* these are limited to 10/100 only */
8498 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 && 8602 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 &&
8499 (grc_misc_cfg == 0x8000 || grc_misc_cfg == 0x4000)) || 8603 (grc_misc_cfg == 0x8000 || grc_misc_cfg == 0x4000)) ||
@@ -8671,6 +8775,146 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
8671 return 0; 8775 return 0;
8672} 8776}
8673 8777
8778#define BOUNDARY_SINGLE_CACHELINE 1
8779#define BOUNDARY_MULTI_CACHELINE 2
8780
8781static u32 __devinit tg3_calc_dma_bndry(struct tg3 *tp, u32 val)
8782{
8783 int cacheline_size;
8784 u8 byte;
8785 int goal;
8786
8787 pci_read_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, &byte);
8788 if (byte == 0)
8789 cacheline_size = 1024;
8790 else
8791 cacheline_size = (int) byte * 4;
8792
8793 /* On 5703 and later chips, the boundary bits have no
8794 * effect.
8795 */
8796 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
8797 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701 &&
8798 !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS))
8799 goto out;
8800
8801#if defined(CONFIG_PPC64) || defined(CONFIG_IA64) || defined(CONFIG_PARISC)
8802 goal = BOUNDARY_MULTI_CACHELINE;
8803#else
8804#if defined(CONFIG_SPARC64) || defined(CONFIG_ALPHA)
8805 goal = BOUNDARY_SINGLE_CACHELINE;
8806#else
8807 goal = 0;
8808#endif
8809#endif
8810
8811 if (!goal)
8812 goto out;
8813
8814 /* PCI controllers on most RISC systems tend to disconnect
8815 * when a device tries to burst across a cache-line boundary.
8816 * Therefore, letting tg3 do so just wastes PCI bandwidth.
8817 *
8818 * Unfortunately, for PCI-E there are only limited
8819 * write-side controls for this, and thus for reads
8820 * we will still get the disconnects. We'll also waste
8821 * these PCI cycles for both read and write for chips
8822 * other than 5700 and 5701 which do not implement the
8823 * boundary bits.
8824 */
8825 if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) &&
8826 !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)) {
8827 switch (cacheline_size) {
8828 case 16:
8829 case 32:
8830 case 64:
8831 case 128:
8832 if (goal == BOUNDARY_SINGLE_CACHELINE) {
8833 val |= (DMA_RWCTRL_READ_BNDRY_128_PCIX |
8834 DMA_RWCTRL_WRITE_BNDRY_128_PCIX);
8835 } else {
8836 val |= (DMA_RWCTRL_READ_BNDRY_384_PCIX |
8837 DMA_RWCTRL_WRITE_BNDRY_384_PCIX);
8838 }
8839 break;
8840
8841 case 256:
8842 val |= (DMA_RWCTRL_READ_BNDRY_256_PCIX |
8843 DMA_RWCTRL_WRITE_BNDRY_256_PCIX);
8844 break;
8845
8846 default:
8847 val |= (DMA_RWCTRL_READ_BNDRY_384_PCIX |
8848 DMA_RWCTRL_WRITE_BNDRY_384_PCIX);
8849 break;
8850 };
8851 } else if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
8852 switch (cacheline_size) {
8853 case 16:
8854 case 32:
8855 case 64:
8856 if (goal == BOUNDARY_SINGLE_CACHELINE) {
8857 val &= ~DMA_RWCTRL_WRITE_BNDRY_DISAB_PCIE;
8858 val |= DMA_RWCTRL_WRITE_BNDRY_64_PCIE;
8859 break;
8860 }
8861 /* fallthrough */
8862 case 128:
8863 default:
8864 val &= ~DMA_RWCTRL_WRITE_BNDRY_DISAB_PCIE;
8865 val |= DMA_RWCTRL_WRITE_BNDRY_128_PCIE;
8866 break;
8867 };
8868 } else {
8869 switch (cacheline_size) {
8870 case 16:
8871 if (goal == BOUNDARY_SINGLE_CACHELINE) {
8872 val |= (DMA_RWCTRL_READ_BNDRY_16 |
8873 DMA_RWCTRL_WRITE_BNDRY_16);
8874 break;
8875 }
8876 /* fallthrough */
8877 case 32:
8878 if (goal == BOUNDARY_SINGLE_CACHELINE) {
8879 val |= (DMA_RWCTRL_READ_BNDRY_32 |
8880 DMA_RWCTRL_WRITE_BNDRY_32);
8881 break;
8882 }
8883 /* fallthrough */
8884 case 64:
8885 if (goal == BOUNDARY_SINGLE_CACHELINE) {
8886 val |= (DMA_RWCTRL_READ_BNDRY_64 |
8887 DMA_RWCTRL_WRITE_BNDRY_64);
8888 break;
8889 }
8890 /* fallthrough */
8891 case 128:
8892 if (goal == BOUNDARY_SINGLE_CACHELINE) {
8893 val |= (DMA_RWCTRL_READ_BNDRY_128 |
8894 DMA_RWCTRL_WRITE_BNDRY_128);
8895 break;
8896 }
8897 /* fallthrough */
8898 case 256:
8899 val |= (DMA_RWCTRL_READ_BNDRY_256 |
8900 DMA_RWCTRL_WRITE_BNDRY_256);
8901 break;
8902 case 512:
8903 val |= (DMA_RWCTRL_READ_BNDRY_512 |
8904 DMA_RWCTRL_WRITE_BNDRY_512);
8905 break;
8906 case 1024:
8907 default:
8908 val |= (DMA_RWCTRL_READ_BNDRY_1024 |
8909 DMA_RWCTRL_WRITE_BNDRY_1024);
8910 break;
8911 };
8912 }
8913
8914out:
8915 return val;
8916}
8917
8674static int __devinit tg3_do_test_dma(struct tg3 *tp, u32 *buf, dma_addr_t buf_dma, int size, int to_device) 8918static int __devinit tg3_do_test_dma(struct tg3 *tp, u32 *buf, dma_addr_t buf_dma, int size, int to_device)
8675{ 8919{
8676 struct tg3_internal_buffer_desc test_desc; 8920 struct tg3_internal_buffer_desc test_desc;
@@ -8752,12 +8996,12 @@ static int __devinit tg3_do_test_dma(struct tg3 *tp, u32 *buf, dma_addr_t buf_dm
8752 return ret; 8996 return ret;
8753} 8997}
8754 8998
8755#define TEST_BUFFER_SIZE 0x400 8999#define TEST_BUFFER_SIZE 0x2000
8756 9000
8757static int __devinit tg3_test_dma(struct tg3 *tp) 9001static int __devinit tg3_test_dma(struct tg3 *tp)
8758{ 9002{
8759 dma_addr_t buf_dma; 9003 dma_addr_t buf_dma;
8760 u32 *buf; 9004 u32 *buf, saved_dma_rwctrl;
8761 int ret; 9005 int ret;
8762 9006
8763 buf = pci_alloc_consistent(tp->pdev, TEST_BUFFER_SIZE, &buf_dma); 9007 buf = pci_alloc_consistent(tp->pdev, TEST_BUFFER_SIZE, &buf_dma);
@@ -8769,46 +9013,7 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
8769 tp->dma_rwctrl = ((0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) | 9013 tp->dma_rwctrl = ((0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) |
8770 (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT)); 9014 (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT));
8771 9015
8772#ifndef CONFIG_X86 9016 tp->dma_rwctrl = tg3_calc_dma_bndry(tp, tp->dma_rwctrl);
8773 {
8774 u8 byte;
8775 int cacheline_size;
8776 pci_read_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, &byte);
8777
8778 if (byte == 0)
8779 cacheline_size = 1024;
8780 else
8781 cacheline_size = (int) byte * 4;
8782
8783 switch (cacheline_size) {
8784 case 16:
8785 case 32:
8786 case 64:
8787 case 128:
8788 if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) &&
8789 !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)) {
8790 tp->dma_rwctrl |=
8791 DMA_RWCTRL_WRITE_BNDRY_384_PCIX;
8792 break;
8793 } else if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
8794 tp->dma_rwctrl &=
8795 ~(DMA_RWCTRL_PCI_WRITE_CMD);
8796 tp->dma_rwctrl |=
8797 DMA_RWCTRL_WRITE_BNDRY_128_PCIE;
8798 break;
8799 }
8800 /* fallthrough */
8801 case 256:
8802 if (!(tp->tg3_flags & TG3_FLAG_PCIX_MODE) &&
8803 !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS))
8804 tp->dma_rwctrl |=
8805 DMA_RWCTRL_WRITE_BNDRY_256;
8806 else if (!(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS))
8807 tp->dma_rwctrl |=
8808 DMA_RWCTRL_WRITE_BNDRY_256_PCIX;
8809 };
8810 }
8811#endif
8812 9017
8813 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) { 9018 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
8814 /* DMA read watermark not used on PCIE */ 9019 /* DMA read watermark not used on PCIE */
@@ -8827,7 +9032,7 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
8827 if (ccval == 0x6 || ccval == 0x7) 9032 if (ccval == 0x6 || ccval == 0x7)
8828 tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA; 9033 tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA;
8829 9034
8830 /* Set bit 23 to renable PCIX hw bug fix */ 9035 /* Set bit 23 to enable PCIX hw bug fix */
8831 tp->dma_rwctrl |= 0x009f0000; 9036 tp->dma_rwctrl |= 0x009f0000;
8832 } else { 9037 } else {
8833 tp->dma_rwctrl |= 0x001b000f; 9038 tp->dma_rwctrl |= 0x001b000f;
@@ -8868,6 +9073,13 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
8868 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) 9073 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701)
8869 goto out; 9074 goto out;
8870 9075
9076 /* It is best to perform DMA test with maximum write burst size
9077 * to expose the 5700/5701 write DMA bug.
9078 */
9079 saved_dma_rwctrl = tp->dma_rwctrl;
9080 tp->dma_rwctrl &= ~DMA_RWCTRL_WRITE_BNDRY_MASK;
9081 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
9082
8871 while (1) { 9083 while (1) {
8872 u32 *p = buf, i; 9084 u32 *p = buf, i;
8873 9085
@@ -8906,8 +9118,9 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
8906 if (p[i] == i) 9118 if (p[i] == i)
8907 continue; 9119 continue;
8908 9120
8909 if ((tp->dma_rwctrl & DMA_RWCTRL_WRITE_BNDRY_MASK) == 9121 if ((tp->dma_rwctrl & DMA_RWCTRL_WRITE_BNDRY_MASK) !=
8910 DMA_RWCTRL_WRITE_BNDRY_DISAB) { 9122 DMA_RWCTRL_WRITE_BNDRY_16) {
9123 tp->dma_rwctrl &= ~DMA_RWCTRL_WRITE_BNDRY_MASK;
8911 tp->dma_rwctrl |= DMA_RWCTRL_WRITE_BNDRY_16; 9124 tp->dma_rwctrl |= DMA_RWCTRL_WRITE_BNDRY_16;
8912 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); 9125 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
8913 break; 9126 break;
@@ -8924,6 +9137,14 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
8924 break; 9137 break;
8925 } 9138 }
8926 } 9139 }
9140 if ((tp->dma_rwctrl & DMA_RWCTRL_WRITE_BNDRY_MASK) !=
9141 DMA_RWCTRL_WRITE_BNDRY_16) {
9142 /* DMA test passed without adjusting DMA boundary,
9143 * just restore the calculated DMA boundary
9144 */
9145 tp->dma_rwctrl = saved_dma_rwctrl;
9146 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
9147 }
8927 9148
8928out: 9149out:
8929 pci_free_consistent(tp->pdev, TEST_BUFFER_SIZE, buf, buf_dma); 9150 pci_free_consistent(tp->pdev, TEST_BUFFER_SIZE, buf, buf_dma);
@@ -9011,6 +9232,31 @@ static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp)
9011 return peer; 9232 return peer;
9012} 9233}
9013 9234
9235static void __devinit tg3_init_coal(struct tg3 *tp)
9236{
9237 struct ethtool_coalesce *ec = &tp->coal;
9238
9239 memset(ec, 0, sizeof(*ec));
9240 ec->cmd = ETHTOOL_GCOALESCE;
9241 ec->rx_coalesce_usecs = LOW_RXCOL_TICKS;
9242 ec->tx_coalesce_usecs = LOW_TXCOL_TICKS;
9243 ec->rx_max_coalesced_frames = LOW_RXMAX_FRAMES;
9244 ec->tx_max_coalesced_frames = LOW_TXMAX_FRAMES;
9245 ec->rx_coalesce_usecs_irq = DEFAULT_RXCOAL_TICK_INT;
9246 ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT;
9247 ec->rx_max_coalesced_frames_irq = DEFAULT_RXCOAL_MAXF_INT;
9248 ec->tx_max_coalesced_frames_irq = DEFAULT_TXCOAL_MAXF_INT;
9249 ec->stats_block_coalesce_usecs = DEFAULT_STAT_COAL_TICKS;
9250
9251 if (tp->coalesce_mode & (HOSTCC_MODE_CLRTICK_RXBD |
9252 HOSTCC_MODE_CLRTICK_TXBD)) {
9253 ec->rx_coalesce_usecs = LOW_RXCOL_TICKS_CLRTCKS;
9254 ec->rx_coalesce_usecs_irq = DEFAULT_RXCOAL_TICK_INT_CLRTCKS;
9255 ec->tx_coalesce_usecs = LOW_TXCOL_TICKS_CLRTCKS;
9256 ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT_CLRTCKS;
9257 }
9258}
9259
9014static int __devinit tg3_init_one(struct pci_dev *pdev, 9260static int __devinit tg3_init_one(struct pci_dev *pdev,
9015 const struct pci_device_id *ent) 9261 const struct pci_device_id *ent)
9016{ 9262{
@@ -9256,6 +9502,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
9256 /* flow control autonegotiation is default behavior */ 9502 /* flow control autonegotiation is default behavior */
9257 tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG; 9503 tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG;
9258 9504
9505 tg3_init_coal(tp);
9506
9259 err = register_netdev(dev); 9507 err = register_netdev(dev);
9260 if (err) { 9508 if (err) {
9261 printk(KERN_ERR PFX "Cannot register net device, " 9509 printk(KERN_ERR PFX "Cannot register net device, "
@@ -9298,6 +9546,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
9298 (tp->tg3_flags & TG3_FLAG_SPLIT_MODE) != 0, 9546 (tp->tg3_flags & TG3_FLAG_SPLIT_MODE) != 0,
9299 (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED) == 0, 9547 (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED) == 0,
9300 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) != 0); 9548 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) != 0);
9549 printk(KERN_INFO "%s: dma_rwctrl[%08x]\n",
9550 dev->name, tp->dma_rwctrl);
9301 9551
9302 return 0; 9552 return 0;
9303 9553
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 8de6f21037ba..993f84c93dc4 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -876,10 +876,12 @@
876#define HOSTCC_STATUS_ERROR_ATTN 0x00000004 876#define HOSTCC_STATUS_ERROR_ATTN 0x00000004
877#define HOSTCC_RXCOL_TICKS 0x00003c08 877#define HOSTCC_RXCOL_TICKS 0x00003c08
878#define LOW_RXCOL_TICKS 0x00000032 878#define LOW_RXCOL_TICKS 0x00000032
879#define LOW_RXCOL_TICKS_CLRTCKS 0x00000014
879#define DEFAULT_RXCOL_TICKS 0x00000048 880#define DEFAULT_RXCOL_TICKS 0x00000048
880#define HIGH_RXCOL_TICKS 0x00000096 881#define HIGH_RXCOL_TICKS 0x00000096
881#define HOSTCC_TXCOL_TICKS 0x00003c0c 882#define HOSTCC_TXCOL_TICKS 0x00003c0c
882#define LOW_TXCOL_TICKS 0x00000096 883#define LOW_TXCOL_TICKS 0x00000096
884#define LOW_TXCOL_TICKS_CLRTCKS 0x00000048
883#define DEFAULT_TXCOL_TICKS 0x0000012c 885#define DEFAULT_TXCOL_TICKS 0x0000012c
884#define HIGH_TXCOL_TICKS 0x00000145 886#define HIGH_TXCOL_TICKS 0x00000145
885#define HOSTCC_RXMAX_FRAMES 0x00003c10 887#define HOSTCC_RXMAX_FRAMES 0x00003c10
@@ -892,8 +894,10 @@
892#define HIGH_TXMAX_FRAMES 0x00000052 894#define HIGH_TXMAX_FRAMES 0x00000052
893#define HOSTCC_RXCOAL_TICK_INT 0x00003c18 895#define HOSTCC_RXCOAL_TICK_INT 0x00003c18
894#define DEFAULT_RXCOAL_TICK_INT 0x00000019 896#define DEFAULT_RXCOAL_TICK_INT 0x00000019
897#define DEFAULT_RXCOAL_TICK_INT_CLRTCKS 0x00000014
895#define HOSTCC_TXCOAL_TICK_INT 0x00003c1c 898#define HOSTCC_TXCOAL_TICK_INT 0x00003c1c
896#define DEFAULT_TXCOAL_TICK_INT 0x00000019 899#define DEFAULT_TXCOAL_TICK_INT 0x00000019
900#define DEFAULT_TXCOAL_TICK_INT_CLRTCKS 0x00000014
897#define HOSTCC_RXCOAL_MAXF_INT 0x00003c20 901#define HOSTCC_RXCOAL_MAXF_INT 0x00003c20
898#define DEFAULT_RXCOAL_MAXF_INT 0x00000005 902#define DEFAULT_RXCOAL_MAXF_INT 0x00000005
899#define HOSTCC_TXCOAL_MAXF_INT 0x00003c24 903#define HOSTCC_TXCOAL_MAXF_INT 0x00003c24
@@ -2023,6 +2027,7 @@ struct tg3 {
2023 2027
2024 struct tg3_hw_status *hw_status; 2028 struct tg3_hw_status *hw_status;
2025 dma_addr_t status_mapping; 2029 dma_addr_t status_mapping;
2030 u32 last_tag;
2026 2031
2027 u32 msg_enable; 2032 u32 msg_enable;
2028 2033
@@ -2068,6 +2073,7 @@ struct tg3 {
2068 2073
2069 u32 rx_offset; 2074 u32 rx_offset;
2070 u32 tg3_flags; 2075 u32 tg3_flags;
2076#define TG3_FLAG_TAGGED_STATUS 0x00000001
2071#define TG3_FLAG_TXD_MBOX_HWBUG 0x00000002 2077#define TG3_FLAG_TXD_MBOX_HWBUG 0x00000002
2072#define TG3_FLAG_RX_CHECKSUMS 0x00000004 2078#define TG3_FLAG_RX_CHECKSUMS 0x00000004
2073#define TG3_FLAG_USE_LINKCHG_REG 0x00000008 2079#define TG3_FLAG_USE_LINKCHG_REG 0x00000008
@@ -2225,7 +2231,7 @@ struct tg3 {
2225 2231
2226#define SST_25VF0X0_PAGE_SIZE 4098 2232#define SST_25VF0X0_PAGE_SIZE 4098
2227 2233
2228 2234 struct ethtool_coalesce coal;
2229}; 2235};
2230 2236
2231#endif /* !(_T3_H) */ 2237#endif /* !(_T3_H) */
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index a7ffa64502dd..9680a308c62b 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -193,6 +193,12 @@ static int aui[MAX_TLAN_BOARDS];
193static int duplex[MAX_TLAN_BOARDS]; 193static int duplex[MAX_TLAN_BOARDS];
194static int speed[MAX_TLAN_BOARDS]; 194static int speed[MAX_TLAN_BOARDS];
195static int boards_found; 195static int boards_found;
196module_param_array(aui, int, NULL, 0);
197module_param_array(duplex, int, NULL, 0);
198module_param_array(speed, int, NULL, 0);
199MODULE_PARM_DESC(aui, "ThunderLAN use AUI port(s) (0-1)");
200MODULE_PARM_DESC(duplex, "ThunderLAN duplex setting(s) (0-default, 1-half, 2-full)");
201MODULE_PARM_DESC(speed, "ThunderLAN port speen setting(s) (0,10,100)");
196 202
197MODULE_AUTHOR("Maintainer: Samuel Chessman <chessman@tux.org>"); 203MODULE_AUTHOR("Maintainer: Samuel Chessman <chessman@tux.org>");
198MODULE_DESCRIPTION("Driver for TI ThunderLAN based ethernet PCI adapters"); 204MODULE_DESCRIPTION("Driver for TI ThunderLAN based ethernet PCI adapters");
@@ -204,8 +210,13 @@ MODULE_LICENSE("GPL");
204 210
205/* Turn on debugging. See Documentation/networking/tlan.txt for details */ 211/* Turn on debugging. See Documentation/networking/tlan.txt for details */
206static int debug; 212static int debug;
213module_param(debug, int, 0);
214MODULE_PARM_DESC(debug, "ThunderLAN debug mask");
207 215
208static int bbuf; 216static int bbuf;
217module_param(bbuf, int, 0);
218MODULE_PARM_DESC(bbuf, "ThunderLAN use big buffer (0-1)");
219
209static u8 *TLanPadBuffer; 220static u8 *TLanPadBuffer;
210static dma_addr_t TLanPadBufferDMA; 221static dma_addr_t TLanPadBufferDMA;
211static char TLanSignature[] = "TLAN"; 222static char TLanSignature[] = "TLAN";
@@ -2381,6 +2392,7 @@ TLan_FinishReset( struct net_device *dev )
2381 TLan_SetTimer( dev, (10*HZ), TLAN_TIMER_FINISH_RESET ); 2392 TLan_SetTimer( dev, (10*HZ), TLAN_TIMER_FINISH_RESET );
2382 return; 2393 return;
2383 } 2394 }
2395 TLan_SetMulticastList(dev);
2384 2396
2385} /* TLan_FinishReset */ 2397} /* TLan_FinishReset */
2386 2398
diff --git a/drivers/net/tulip/media.c b/drivers/net/tulip/media.c
index edae09a4b021..919c40cd635c 100644
--- a/drivers/net/tulip/media.c
+++ b/drivers/net/tulip/media.c
@@ -174,6 +174,7 @@ void tulip_mdio_write(struct net_device *dev, int phy_id, int location, int val)
174 break; 174 break;
175 } 175 }
176 spin_unlock_irqrestore(&tp->mii_lock, flags); 176 spin_unlock_irqrestore(&tp->mii_lock, flags);
177 return;
177 } 178 }
178 179
179 /* Establish sync by sending 32 logic ones. */ 180 /* Establish sync by sending 32 logic ones. */
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index d098b3ba3538..e0ae3ed6e578 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1104,7 +1104,7 @@ static void set_rx_mode(struct net_device *dev)
1104 if (entry != 0) { 1104 if (entry != 0) {
1105 /* Avoid a chip errata by prefixing a dummy entry. Don't do 1105 /* Avoid a chip errata by prefixing a dummy entry. Don't do
1106 this on the ULI526X as it triggers a different problem */ 1106 this on the ULI526X as it triggers a different problem */
1107 if (!(tp->chip_id == ULI526X && (tp->revision = 0x40 || tp->revision == 0x50))) { 1107 if (!(tp->chip_id == ULI526X && (tp->revision == 0x40 || tp->revision == 0x50))) {
1108 tp->tx_buffers[entry].skb = NULL; 1108 tp->tx_buffers[entry].skb = NULL;
1109 tp->tx_buffers[entry].mapping = 0; 1109 tp->tx_buffers[entry].mapping = 0;
1110 tp->tx_ring[entry].length = 1110 tp->tx_ring[entry].length =
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 6e88d4839971..a4a7e8a41775 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -428,7 +428,7 @@ config PRISM54
428 For a complete list of supported cards visit <http://prism54.org>. 428 For a complete list of supported cards visit <http://prism54.org>.
429 Here is the latest confirmed list of supported cards: 429 Here is the latest confirmed list of supported cards:
430 430
431 3com OfficeConnect 11g Cardbus Card aka 3CRWE154G72 431 3com OfficeConnect 11g Cardbus Card aka 3CRWE154G72 (version 1)
432 Allnet ALL0271 PCI Card 432 Allnet ALL0271 PCI Card
433 Compex WL54G Cardbus Card 433 Compex WL54G Cardbus Card
434 Corega CG-WLCB54GT Cardbus Card 434 Corega CG-WLCB54GT Cardbus Card
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index e3168a13b786..4314df28d60d 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -754,7 +754,7 @@ typedef struct {
754 u8 zero; 754 u8 zero;
755 u8 ssidLen; 755 u8 ssidLen;
756 u8 ssid[32]; 756 u8 ssid[32];
757 u16 rssi; 757 u16 dBm;
758#define CAP_ESS (1<<0) 758#define CAP_ESS (1<<0)
759#define CAP_IBSS (1<<1) 759#define CAP_IBSS (1<<1)
760#define CAP_PRIVACY (1<<4) 760#define CAP_PRIVACY (1<<4)
@@ -1125,6 +1125,9 @@ static int micsetup(struct airo_info *ai);
1125static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len); 1125static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len);
1126static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket, u16 payLen); 1126static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket, u16 payLen);
1127 1127
1128static u8 airo_rssi_to_dbm (tdsRssiEntry *rssi_rid, u8 rssi);
1129static u8 airo_dbm_to_pct (tdsRssiEntry *rssi_rid, u8 dbm);
1130
1128#include <linux/crypto.h> 1131#include <linux/crypto.h>
1129#endif 1132#endif
1130 1133
@@ -1720,6 +1723,7 @@ static int readBSSListRid(struct airo_info *ai, int first,
1720 list->fh.dwell = le16_to_cpu(list->fh.dwell); 1723 list->fh.dwell = le16_to_cpu(list->fh.dwell);
1721 list->dsChannel = le16_to_cpu(list->dsChannel); 1724 list->dsChannel = le16_to_cpu(list->dsChannel);
1722 list->atimWindow = le16_to_cpu(list->atimWindow); 1725 list->atimWindow = le16_to_cpu(list->atimWindow);
1726 list->dBm = le16_to_cpu(list->dBm);
1723 return rc; 1727 return rc;
1724} 1728}
1725 1729
@@ -3252,7 +3256,10 @@ badrx:
3252 wstats.level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm; 3256 wstats.level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
3253 else 3257 else
3254 wstats.level = (hdr.rssi[1] + 321) / 2; 3258 wstats.level = (hdr.rssi[1] + 321) / 2;
3255 wstats.updated = 3; 3259 wstats.noise = apriv->wstats.qual.noise;
3260 wstats.updated = IW_QUAL_LEVEL_UPDATED
3261 | IW_QUAL_QUAL_UPDATED
3262 | IW_QUAL_NOISE_UPDATED;
3256 /* Update spy records */ 3263 /* Update spy records */
3257 wireless_spy_update(dev, sa, &wstats); 3264 wireless_spy_update(dev, sa, &wstats);
3258 } 3265 }
@@ -3595,7 +3602,10 @@ void mpi_receive_802_11 (struct airo_info *ai)
3595 wstats.level = 0x100 - ai->rssi[hdr.rssi[1]].rssidBm; 3602 wstats.level = 0x100 - ai->rssi[hdr.rssi[1]].rssidBm;
3596 else 3603 else
3597 wstats.level = (hdr.rssi[1] + 321) / 2; 3604 wstats.level = (hdr.rssi[1] + 321) / 2;
3598 wstats.updated = 3; 3605 wstats.noise = ai->wstats.qual.noise;
3606 wstats.updated = IW_QUAL_QUAL_UPDATED
3607 | IW_QUAL_LEVEL_UPDATED
3608 | IW_QUAL_NOISE_UPDATED;
3599 /* Update spy records */ 3609 /* Update spy records */
3600 wireless_spy_update(ai->dev, sa, &wstats); 3610 wireless_spy_update(ai->dev, sa, &wstats);
3601 } 3611 }
@@ -3686,7 +3696,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
3686 status = PC4500_readrid(ai,RID_RSSI,&rssi_rid,sizeof(rssi_rid),lock); 3696 status = PC4500_readrid(ai,RID_RSSI,&rssi_rid,sizeof(rssi_rid),lock);
3687 if ( status == SUCCESS ) { 3697 if ( status == SUCCESS ) {
3688 if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL) 3698 if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL)
3689 memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); 3699 memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */
3690 } 3700 }
3691 else { 3701 else {
3692 if (ai->rssi) { 3702 if (ai->rssi) {
@@ -5355,7 +5365,7 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
5355 (int)BSSList_rid.bssid[5], 5365 (int)BSSList_rid.bssid[5],
5356 (int)BSSList_rid.ssidLen, 5366 (int)BSSList_rid.ssidLen,
5357 BSSList_rid.ssid, 5367 BSSList_rid.ssid,
5358 (int)BSSList_rid.rssi); 5368 (int)BSSList_rid.dBm);
5359 ptr += sprintf(ptr, " channel = %d %s %s %s %s\n", 5369 ptr += sprintf(ptr, " channel = %d %s %s %s %s\n",
5360 (int)BSSList_rid.dsChannel, 5370 (int)BSSList_rid.dsChannel,
5361 BSSList_rid.cap & CAP_ESS ? "ESS" : "", 5371 BSSList_rid.cap & CAP_ESS ? "ESS" : "",
@@ -5600,6 +5610,29 @@ static void __exit airo_cleanup_module( void )
5600 * would not work at all... - Jean II 5610 * would not work at all... - Jean II
5601 */ 5611 */
5602 5612
5613static u8 airo_rssi_to_dbm (tdsRssiEntry *rssi_rid, u8 rssi)
5614{
5615 if( !rssi_rid )
5616 return 0;
5617
5618 return (0x100 - rssi_rid[rssi].rssidBm);
5619}
5620
5621static u8 airo_dbm_to_pct (tdsRssiEntry *rssi_rid, u8 dbm)
5622{
5623 int i;
5624
5625 if( !rssi_rid )
5626 return 0;
5627
5628 for( i = 0; i < 256; i++ )
5629 if (rssi_rid[i].rssidBm == dbm)
5630 return rssi_rid[i].rssipct;
5631
5632 return 0;
5633}
5634
5635
5603static int airo_get_quality (StatusRid *status_rid, CapabilityRid *cap_rid) 5636static int airo_get_quality (StatusRid *status_rid, CapabilityRid *cap_rid)
5604{ 5637{
5605 int quality = 0; 5638 int quality = 0;
@@ -6450,11 +6483,29 @@ static int airo_get_range(struct net_device *dev,
6450 } 6483 }
6451 range->num_frequency = k; 6484 range->num_frequency = k;
6452 6485
6486 range->sensitivity = 65535;
6487
6453 /* Hum... Should put the right values there */ 6488 /* Hum... Should put the right values there */
6454 range->max_qual.qual = airo_get_max_quality(&cap_rid); 6489 if (local->rssi)
6455 range->max_qual.level = 0x100 - 120; /* -120 dBm */ 6490 range->max_qual.qual = 100; /* % */
6491 else
6492 range->max_qual.qual = airo_get_max_quality(&cap_rid);
6493 range->max_qual.level = 0; /* 0 means we use dBm */
6456 range->max_qual.noise = 0; 6494 range->max_qual.noise = 0;
6457 range->sensitivity = 65535; 6495 range->max_qual.updated = 0;
6496
6497 /* Experimental measurements - boundary 11/5.5 Mb/s */
6498 /* Note : with or without the (local->rssi), results
6499 * are somewhat different. - Jean II */
6500 if (local->rssi) {
6501 range->avg_qual.qual = 50; /* % */
6502 range->avg_qual.level = 186; /* -70 dBm */
6503 } else {
6504 range->avg_qual.qual = airo_get_avg_quality(&cap_rid);
6505 range->avg_qual.level = 176; /* -80 dBm */
6506 }
6507 range->avg_qual.noise = 0;
6508 range->avg_qual.updated = 0;
6458 6509
6459 for(i = 0 ; i < 8 ; i++) { 6510 for(i = 0 ; i < 8 ; i++) {
6460 range->bitrate[i] = cap_rid.supportedRates[i] * 500000; 6511 range->bitrate[i] = cap_rid.supportedRates[i] * 500000;
@@ -6515,15 +6566,6 @@ static int airo_get_range(struct net_device *dev,
6515 range->max_retry = 65535; 6566 range->max_retry = 65535;
6516 range->min_r_time = 1024; 6567 range->min_r_time = 1024;
6517 range->max_r_time = 65535 * 1024; 6568 range->max_r_time = 65535 * 1024;
6518 /* Experimental measurements - boundary 11/5.5 Mb/s */
6519 /* Note : with or without the (local->rssi), results
6520 * are somewhat different. - Jean II */
6521 range->avg_qual.qual = airo_get_avg_quality(&cap_rid);
6522 if (local->rssi)
6523 range->avg_qual.level = 186; /* -70 dBm */
6524 else
6525 range->avg_qual.level = 176; /* -80 dBm */
6526 range->avg_qual.noise = 0;
6527 6569
6528 /* Event capability (kernel + driver) */ 6570 /* Event capability (kernel + driver) */
6529 range->event_capa[0] = (IW_EVENT_CAPA_K_0 | 6571 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
@@ -6683,12 +6725,18 @@ static int airo_get_aplist(struct net_device *dev,
6683 loseSync = 0; 6725 loseSync = 0;
6684 memcpy(address[i].sa_data, BSSList.bssid, ETH_ALEN); 6726 memcpy(address[i].sa_data, BSSList.bssid, ETH_ALEN);
6685 address[i].sa_family = ARPHRD_ETHER; 6727 address[i].sa_family = ARPHRD_ETHER;
6686 if (local->rssi) 6728 if (local->rssi) {
6687 qual[i].level = 0x100 - local->rssi[BSSList.rssi].rssidBm; 6729 qual[i].level = 0x100 - BSSList.dBm;
6688 else 6730 qual[i].qual = airo_dbm_to_pct( local->rssi, BSSList.dBm );
6689 qual[i].level = (BSSList.rssi + 321) / 2; 6731 qual[i].updated = IW_QUAL_QUAL_UPDATED;
6690 qual[i].qual = qual[i].noise = 0; 6732 } else {
6691 qual[i].updated = 2; 6733 qual[i].level = (BSSList.dBm + 321) / 2;
6734 qual[i].qual = 0;
6735 qual[i].updated = IW_QUAL_QUAL_INVALID;
6736 }
6737 qual[i].noise = local->wstats.qual.noise;
6738 qual[i].updated = IW_QUAL_LEVEL_UPDATED
6739 | IW_QUAL_NOISE_UPDATED;
6692 if (BSSList.index == 0xffff) 6740 if (BSSList.index == 0xffff)
6693 break; 6741 break;
6694 } 6742 }
@@ -6767,7 +6815,7 @@ static int airo_set_scan(struct net_device *dev,
6767static inline char *airo_translate_scan(struct net_device *dev, 6815static inline char *airo_translate_scan(struct net_device *dev,
6768 char *current_ev, 6816 char *current_ev,
6769 char *end_buf, 6817 char *end_buf,
6770 BSSListRid *list) 6818 BSSListRid *bss)
6771{ 6819{
6772 struct airo_info *ai = dev->priv; 6820 struct airo_info *ai = dev->priv;
6773 struct iw_event iwe; /* Temporary buffer */ 6821 struct iw_event iwe; /* Temporary buffer */
@@ -6778,22 +6826,22 @@ static inline char *airo_translate_scan(struct net_device *dev,
6778 /* First entry *MUST* be the AP MAC address */ 6826 /* First entry *MUST* be the AP MAC address */
6779 iwe.cmd = SIOCGIWAP; 6827 iwe.cmd = SIOCGIWAP;
6780 iwe.u.ap_addr.sa_family = ARPHRD_ETHER; 6828 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
6781 memcpy(iwe.u.ap_addr.sa_data, list->bssid, ETH_ALEN); 6829 memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN);
6782 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_ADDR_LEN); 6830 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
6783 6831
6784 /* Other entries will be displayed in the order we give them */ 6832 /* Other entries will be displayed in the order we give them */
6785 6833
6786 /* Add the ESSID */ 6834 /* Add the ESSID */
6787 iwe.u.data.length = list->ssidLen; 6835 iwe.u.data.length = bss->ssidLen;
6788 if(iwe.u.data.length > 32) 6836 if(iwe.u.data.length > 32)
6789 iwe.u.data.length = 32; 6837 iwe.u.data.length = 32;
6790 iwe.cmd = SIOCGIWESSID; 6838 iwe.cmd = SIOCGIWESSID;
6791 iwe.u.data.flags = 1; 6839 iwe.u.data.flags = 1;
6792 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, list->ssid); 6840 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, bss->ssid);
6793 6841
6794 /* Add mode */ 6842 /* Add mode */
6795 iwe.cmd = SIOCGIWMODE; 6843 iwe.cmd = SIOCGIWMODE;
6796 capabilities = le16_to_cpu(list->cap); 6844 capabilities = le16_to_cpu(bss->cap);
6797 if(capabilities & (CAP_ESS | CAP_IBSS)) { 6845 if(capabilities & (CAP_ESS | CAP_IBSS)) {
6798 if(capabilities & CAP_ESS) 6846 if(capabilities & CAP_ESS)
6799 iwe.u.mode = IW_MODE_MASTER; 6847 iwe.u.mode = IW_MODE_MASTER;
@@ -6804,19 +6852,25 @@ static inline char *airo_translate_scan(struct net_device *dev,
6804 6852
6805 /* Add frequency */ 6853 /* Add frequency */
6806 iwe.cmd = SIOCGIWFREQ; 6854 iwe.cmd = SIOCGIWFREQ;
6807 iwe.u.freq.m = le16_to_cpu(list->dsChannel); 6855 iwe.u.freq.m = le16_to_cpu(bss->dsChannel);
6808 iwe.u.freq.m = frequency_list[iwe.u.freq.m] * 100000; 6856 iwe.u.freq.m = frequency_list[iwe.u.freq.m] * 100000;
6809 iwe.u.freq.e = 1; 6857 iwe.u.freq.e = 1;
6810 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); 6858 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
6811 6859
6812 /* Add quality statistics */ 6860 /* Add quality statistics */
6813 iwe.cmd = IWEVQUAL; 6861 iwe.cmd = IWEVQUAL;
6814 if (ai->rssi) 6862 if (ai->rssi) {
6815 iwe.u.qual.level = 0x100 - ai->rssi[list->rssi].rssidBm; 6863 iwe.u.qual.level = 0x100 - bss->dBm;
6816 else 6864 iwe.u.qual.qual = airo_dbm_to_pct( ai->rssi, bss->dBm );
6817 iwe.u.qual.level = (list->rssi + 321) / 2; 6865 iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED;
6818 iwe.u.qual.noise = 0; 6866 } else {
6819 iwe.u.qual.qual = 0; 6867 iwe.u.qual.level = (bss->dBm + 321) / 2;
6868 iwe.u.qual.qual = 0;
6869 iwe.u.qual.updated = IW_QUAL_QUAL_INVALID;
6870 }
6871 iwe.u.qual.noise = ai->wstats.qual.noise;
6872 iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED
6873 | IW_QUAL_NOISE_UPDATED;
6820 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); 6874 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
6821 6875
6822 /* Add encryption capability */ 6876 /* Add encryption capability */
@@ -6826,7 +6880,7 @@ static inline char *airo_translate_scan(struct net_device *dev,
6826 else 6880 else
6827 iwe.u.data.flags = IW_ENCODE_DISABLED; 6881 iwe.u.data.flags = IW_ENCODE_DISABLED;
6828 iwe.u.data.length = 0; 6882 iwe.u.data.length = 0;
6829 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, list->ssid); 6883 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, bss->ssid);
6830 6884
6831 /* Rate : stuffing multiple values in a single event require a bit 6885 /* Rate : stuffing multiple values in a single event require a bit
6832 * more of magic - Jean II */ 6886 * more of magic - Jean II */
@@ -6838,10 +6892,10 @@ static inline char *airo_translate_scan(struct net_device *dev,
6838 /* Max 8 values */ 6892 /* Max 8 values */
6839 for(i = 0 ; i < 8 ; i++) { 6893 for(i = 0 ; i < 8 ; i++) {
6840 /* NULL terminated */ 6894 /* NULL terminated */
6841 if(list->rates[i] == 0) 6895 if(bss->rates[i] == 0)
6842 break; 6896 break;
6843 /* Bit rate given in 500 kb/s units (+ 0x80) */ 6897 /* Bit rate given in 500 kb/s units (+ 0x80) */
6844 iwe.u.bitrate.value = ((list->rates[i] & 0x7f) * 500000); 6898 iwe.u.bitrate.value = ((bss->rates[i] & 0x7f) * 500000);
6845 /* Add new value to event */ 6899 /* Add new value to event */
6846 current_val = iwe_stream_add_value(current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); 6900 current_val = iwe_stream_add_value(current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
6847 } 6901 }
@@ -7160,18 +7214,22 @@ static void airo_read_wireless_stats(struct airo_info *local)
7160 /* The status */ 7214 /* The status */
7161 local->wstats.status = status_rid.mode; 7215 local->wstats.status = status_rid.mode;
7162 7216
7163 /* Signal quality and co. But where is the noise level ??? */ 7217 /* Signal quality and co */
7164 local->wstats.qual.qual = airo_get_quality(&status_rid, &cap_rid); 7218 if (local->rssi) {
7165 if (local->rssi) 7219 local->wstats.qual.level = airo_rssi_to_dbm( local->rssi, status_rid.sigQuality );
7166 local->wstats.qual.level = 0x100 - local->rssi[status_rid.sigQuality].rssidBm; 7220 /* normalizedSignalStrength appears to be a percentage */
7167 else 7221 local->wstats.qual.qual = status_rid.normalizedSignalStrength;
7222 } else {
7168 local->wstats.qual.level = (status_rid.normalizedSignalStrength + 321) / 2; 7223 local->wstats.qual.level = (status_rid.normalizedSignalStrength + 321) / 2;
7224 local->wstats.qual.qual = airo_get_quality(&status_rid, &cap_rid);
7225 }
7226 local->wstats.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED;
7169 if (status_rid.len >= 124) { 7227 if (status_rid.len >= 124) {
7170 local->wstats.qual.noise = 256 - status_rid.noisedBm; 7228 local->wstats.qual.noise = 0x100 - status_rid.noisedBm;
7171 local->wstats.qual.updated = 7; 7229 local->wstats.qual.updated |= IW_QUAL_NOISE_UPDATED;
7172 } else { 7230 } else {
7173 local->wstats.qual.noise = 0; 7231 local->wstats.qual.noise = 0;
7174 local->wstats.qual.updated = 3; 7232 local->wstats.qual.updated |= IW_QUAL_NOISE_INVALID;
7175 } 7233 }
7176 7234
7177 /* Packets discarded in the wireless adapter due to wireless 7235 /* Packets discarded in the wireless adapter due to wireless
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index a91b507e0a7a..a4ed28d9c783 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -321,6 +321,7 @@ static struct {
321 { 0x01bf, 0x3302, NULL, ATMEL_FW_TYPE_502E, "Belkin F5D6020-V2" }, 321 { 0x01bf, 0x3302, NULL, ATMEL_FW_TYPE_502E, "Belkin F5D6020-V2" },
322 { 0, 0, "BT/Voyager 1020 Laptop Adapter", ATMEL_FW_TYPE_502, "BT Voyager 1020" }, 322 { 0, 0, "BT/Voyager 1020 Laptop Adapter", ATMEL_FW_TYPE_502, "BT Voyager 1020" },
323 { 0, 0, "IEEE 802.11b/Wireless LAN PC Card", ATMEL_FW_TYPE_502, "Siemens Gigaset PC Card II" }, 323 { 0, 0, "IEEE 802.11b/Wireless LAN PC Card", ATMEL_FW_TYPE_502, "Siemens Gigaset PC Card II" },
324 { 0, 0, "IEEE 802.11b/Wireless LAN Card S", ATMEL_FW_TYPE_504_2958, "Siemens Gigaset PC Card II" },
324 { 0, 0, "CNet/CNWLC 11Mbps Wireless PC Card V-5", ATMEL_FW_TYPE_502E, "CNet CNWLC-811ARL" }, 325 { 0, 0, "CNet/CNWLC 11Mbps Wireless PC Card V-5", ATMEL_FW_TYPE_502E, "CNet CNWLC-811ARL" },
325 { 0, 0, "Wireless/PC_CARD", ATMEL_FW_TYPE_502D, "Planet WL-3552" }, 326 { 0, 0, "Wireless/PC_CARD", ATMEL_FW_TYPE_502D, "Planet WL-3552" },
326 { 0, 0, "OEM/11Mbps Wireless LAN PC Card V-3", ATMEL_FW_TYPE_502, "OEM 11Mbps WLAN PCMCIA Card" }, 327 { 0, 0, "OEM/11Mbps Wireless LAN PC Card V-3", ATMEL_FW_TYPE_502, "OEM 11Mbps WLAN PCMCIA Card" },
diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
index 021d0f76bc4c..3903f8c559b6 100644
--- a/drivers/pci/hotplug.c
+++ b/drivers/pci/hotplug.c
@@ -52,116 +52,17 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp,
52 if ((buffer_size - length <= 0) || (i >= num_envp)) 52 if ((buffer_size - length <= 0) || (i >= num_envp))
53 return -ENOMEM; 53 return -ENOMEM;
54 54
55 envp[i++] = scratch;
56 length += scnprintf (scratch, buffer_size - length,
57 "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n",
58 pdev->vendor, pdev->device,
59 pdev->subsystem_vendor, pdev->subsystem_device,
60 (u8)(pdev->class >> 16), (u8)(pdev->class >> 8),
61 (u8)(pdev->class));
62 if ((buffer_size - length <= 0) || (i >= num_envp))
63 return -ENOMEM;
64
55 envp[i] = NULL; 65 envp[i] = NULL;
56 66
57 return 0; 67 return 0;
58} 68}
59
60static int pci_visit_bus (struct pci_visit * fn, struct pci_bus_wrapped *wrapped_bus, struct pci_dev_wrapped *wrapped_parent)
61{
62 struct list_head *ln;
63 struct pci_dev *dev;
64 struct pci_dev_wrapped wrapped_dev;
65 int result = 0;
66
67 pr_debug("PCI: Scanning bus %04x:%02x\n", pci_domain_nr(wrapped_bus->bus),
68 wrapped_bus->bus->number);
69
70 if (fn->pre_visit_pci_bus) {
71 result = fn->pre_visit_pci_bus(wrapped_bus, wrapped_parent);
72 if (result)
73 return result;
74 }
75
76 ln = wrapped_bus->bus->devices.next;
77 while (ln != &wrapped_bus->bus->devices) {
78 dev = pci_dev_b(ln);
79 ln = ln->next;
80
81 memset(&wrapped_dev, 0, sizeof(struct pci_dev_wrapped));
82 wrapped_dev.dev = dev;
83
84 result = pci_visit_dev(fn, &wrapped_dev, wrapped_bus);
85 if (result)
86 return result;
87 }
88
89 if (fn->post_visit_pci_bus)
90 result = fn->post_visit_pci_bus(wrapped_bus, wrapped_parent);
91
92 return result;
93}
94
95static int pci_visit_bridge (struct pci_visit * fn,
96 struct pci_dev_wrapped *wrapped_dev,
97 struct pci_bus_wrapped *wrapped_parent)
98{
99 struct pci_bus *bus;
100 struct pci_bus_wrapped wrapped_bus;
101 int result = 0;
102
103 pr_debug("PCI: Scanning bridge %s\n", pci_name(wrapped_dev->dev));
104
105 if (fn->visit_pci_dev) {
106 result = fn->visit_pci_dev(wrapped_dev, wrapped_parent);
107 if (result)
108 return result;
109 }
110
111 bus = wrapped_dev->dev->subordinate;
112 if (bus) {
113 memset(&wrapped_bus, 0, sizeof(struct pci_bus_wrapped));
114 wrapped_bus.bus = bus;
115
116 result = pci_visit_bus(fn, &wrapped_bus, wrapped_dev);
117 }
118 return result;
119}
120
121/**
122 * pci_visit_dev - scans the pci buses.
123 * @fn: callback functions that are called while visiting
124 * @wrapped_dev: the device to scan
125 * @wrapped_parent: the bus where @wrapped_dev is connected to
126 *
127 * Every bus and every function is presented to a custom
128 * function that can act upon it.
129 */
130int pci_visit_dev(struct pci_visit *fn, struct pci_dev_wrapped *wrapped_dev,
131 struct pci_bus_wrapped *wrapped_parent)
132{
133 struct pci_dev* dev = wrapped_dev ? wrapped_dev->dev : NULL;
134 int result = 0;
135
136 if (!dev)
137 return 0;
138
139 if (fn->pre_visit_pci_dev) {
140 result = fn->pre_visit_pci_dev(wrapped_dev, wrapped_parent);
141 if (result)
142 return result;
143 }
144
145 switch (dev->class >> 8) {
146 case PCI_CLASS_BRIDGE_PCI:
147 result = pci_visit_bridge(fn, wrapped_dev,
148 wrapped_parent);
149 if (result)
150 return result;
151 break;
152 default:
153 pr_debug("PCI: Scanning device %s\n", pci_name(dev));
154 if (fn->visit_pci_dev) {
155 result = fn->visit_pci_dev (wrapped_dev,
156 wrapped_parent);
157 if (result)
158 return result;
159 }
160 }
161
162 if (fn->post_visit_pci_dev)
163 result = fn->post_visit_pci_dev(wrapped_dev, wrapped_parent);
164
165 return result;
166}
167EXPORT_SYMBOL(pci_visit_dev);
diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h
index 3ddd75937a40..d9769b30be9a 100644
--- a/drivers/pci/hotplug/cpci_hotplug.h
+++ b/drivers/pci/hotplug/cpci_hotplug.h
@@ -31,7 +31,7 @@
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/pci.h> 32#include <linux/pci.h>
33 33
34/* PICMG 2.12 R2.0 HS CSR bits: */ 34/* PICMG 2.1 R2.0 HS CSR bits: */
35#define HS_CSR_INS 0x0080 35#define HS_CSR_INS 0x0080
36#define HS_CSR_EXT 0x0040 36#define HS_CSR_EXT 0x0040
37#define HS_CSR_PI 0x0030 37#define HS_CSR_PI 0x0030
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index ed243605dc7b..9e9dab7fe86a 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -33,11 +33,11 @@
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/smp_lock.h> 35#include <linux/smp_lock.h>
36#include <asm/atomic.h>
36#include <linux/delay.h> 37#include <linux/delay.h>
37#include "pci_hotplug.h" 38#include "pci_hotplug.h"
38#include "cpci_hotplug.h" 39#include "cpci_hotplug.h"
39 40
40#define DRIVER_VERSION "0.2"
41#define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>" 41#define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>"
42#define DRIVER_DESC "CompactPCI Hot Plug Core" 42#define DRIVER_DESC "CompactPCI Hot Plug Core"
43 43
@@ -54,9 +54,10 @@
54#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 54#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
55 55
56/* local variables */ 56/* local variables */
57static spinlock_t list_lock; 57static DECLARE_RWSEM(list_rwsem);
58static LIST_HEAD(slot_list); 58static LIST_HEAD(slot_list);
59static int slots; 59static int slots;
60static atomic_t extracting;
60int cpci_debug; 61int cpci_debug;
61static struct cpci_hp_controller *controller; 62static struct cpci_hp_controller *controller;
62static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ 63static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */
@@ -68,6 +69,8 @@ static int disable_slot(struct hotplug_slot *slot);
68static int set_attention_status(struct hotplug_slot *slot, u8 value); 69static int set_attention_status(struct hotplug_slot *slot, u8 value);
69static int get_power_status(struct hotplug_slot *slot, u8 * value); 70static int get_power_status(struct hotplug_slot *slot, u8 * value);
70static int get_attention_status(struct hotplug_slot *slot, u8 * value); 71static int get_attention_status(struct hotplug_slot *slot, u8 * value);
72static int get_adapter_status(struct hotplug_slot *slot, u8 * value);
73static int get_latch_status(struct hotplug_slot *slot, u8 * value);
71 74
72static struct hotplug_slot_ops cpci_hotplug_slot_ops = { 75static struct hotplug_slot_ops cpci_hotplug_slot_ops = {
73 .owner = THIS_MODULE, 76 .owner = THIS_MODULE,
@@ -76,6 +79,8 @@ static struct hotplug_slot_ops cpci_hotplug_slot_ops = {
76 .set_attention_status = set_attention_status, 79 .set_attention_status = set_attention_status,
77 .get_power_status = get_power_status, 80 .get_power_status = get_power_status,
78 .get_attention_status = get_attention_status, 81 .get_attention_status = get_attention_status,
82 .get_adapter_status = get_adapter_status,
83 .get_latch_status = get_latch_status,
79}; 84};
80 85
81static int 86static int
@@ -148,8 +153,10 @@ disable_slot(struct hotplug_slot *hotplug_slot)
148 warn("failure to update adapter file"); 153 warn("failure to update adapter file");
149 } 154 }
150 155
151 slot->extracting = 0; 156 if(slot->extracting) {
152 157 slot->extracting = 0;
158 atomic_dec(&extracting);
159 }
153 return retval; 160 return retval;
154} 161}
155 162
@@ -188,6 +195,20 @@ set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
188 return cpci_set_attention_status(hotplug_slot->private, status); 195 return cpci_set_attention_status(hotplug_slot->private, status);
189} 196}
190 197
198static int
199get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
200{
201 *value = hotplug_slot->info->adapter_status;
202 return 0;
203}
204
205static int
206get_latch_status(struct hotplug_slot *hotplug_slot, u8 * value)
207{
208 *value = hotplug_slot->info->latch_status;
209 return 0;
210}
211
191static void release_slot(struct hotplug_slot *hotplug_slot) 212static void release_slot(struct hotplug_slot *hotplug_slot)
192{ 213{
193 struct slot *slot = hotplug_slot->private; 214 struct slot *slot = hotplug_slot->private;
@@ -273,10 +294,10 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
273 } 294 }
274 295
275 /* Add slot to our internal list */ 296 /* Add slot to our internal list */
276 spin_lock(&list_lock); 297 down_write(&list_rwsem);
277 list_add(&slot->slot_list, &slot_list); 298 list_add(&slot->slot_list, &slot_list);
278 slots++; 299 slots++;
279 spin_unlock(&list_lock); 300 up_write(&list_rwsem);
280 } 301 }
281 return 0; 302 return 0;
282error_name: 303error_name:
@@ -299,9 +320,9 @@ cpci_hp_unregister_bus(struct pci_bus *bus)
299 struct list_head *next; 320 struct list_head *next;
300 int status; 321 int status;
301 322
302 spin_lock(&list_lock); 323 down_write(&list_rwsem);
303 if(!slots) { 324 if(!slots) {
304 spin_unlock(&list_lock); 325 up_write(&list_rwsem);
305 return -1; 326 return -1;
306 } 327 }
307 list_for_each_safe(tmp, next, &slot_list) { 328 list_for_each_safe(tmp, next, &slot_list) {
@@ -319,7 +340,7 @@ cpci_hp_unregister_bus(struct pci_bus *bus)
319 slots--; 340 slots--;
320 } 341 }
321 } 342 }
322 spin_unlock(&list_lock); 343 up_write(&list_rwsem);
323 return 0; 344 return 0;
324} 345}
325 346
@@ -347,7 +368,7 @@ cpci_hp_intr(int irq, void *data, struct pt_regs *regs)
347} 368}
348 369
349/* 370/*
350 * According to PICMG 2.12 R2.0, section 6.3.2, upon 371 * According to PICMG 2.1 R2.0, section 6.3.2, upon
351 * initialization, the system driver shall clear the 372 * initialization, the system driver shall clear the
352 * INS bits of the cold-inserted devices. 373 * INS bits of the cold-inserted devices.
353 */ 374 */
@@ -359,9 +380,9 @@ init_slots(void)
359 struct pci_dev* dev; 380 struct pci_dev* dev;
360 381
361 dbg("%s - enter", __FUNCTION__); 382 dbg("%s - enter", __FUNCTION__);
362 spin_lock(&list_lock); 383 down_read(&list_rwsem);
363 if(!slots) { 384 if(!slots) {
364 spin_unlock(&list_lock); 385 up_read(&list_rwsem);
365 return -1; 386 return -1;
366 } 387 }
367 list_for_each(tmp, &slot_list) { 388 list_for_each(tmp, &slot_list) {
@@ -386,7 +407,7 @@ init_slots(void)
386 } 407 }
387 } 408 }
388 } 409 }
389 spin_unlock(&list_lock); 410 up_read(&list_rwsem);
390 dbg("%s - exit", __FUNCTION__); 411 dbg("%s - exit", __FUNCTION__);
391 return 0; 412 return 0;
392} 413}
@@ -398,10 +419,11 @@ check_slots(void)
398 struct list_head *tmp; 419 struct list_head *tmp;
399 int extracted; 420 int extracted;
400 int inserted; 421 int inserted;
422 u16 hs_csr;
401 423
402 spin_lock(&list_lock); 424 down_read(&list_rwsem);
403 if(!slots) { 425 if(!slots) {
404 spin_unlock(&list_lock); 426 up_read(&list_rwsem);
405 err("no slots registered, shutting down"); 427 err("no slots registered, shutting down");
406 return -1; 428 return -1;
407 } 429 }
@@ -411,8 +433,6 @@ check_slots(void)
411 dbg("%s - looking at slot %s", 433 dbg("%s - looking at slot %s",
412 __FUNCTION__, slot->hotplug_slot->name); 434 __FUNCTION__, slot->hotplug_slot->name);
413 if(cpci_check_and_clear_ins(slot)) { 435 if(cpci_check_and_clear_ins(slot)) {
414 u16 hs_csr;
415
416 /* Some broken hardware (e.g. PLX 9054AB) asserts ENUM# twice... */ 436 /* Some broken hardware (e.g. PLX 9054AB) asserts ENUM# twice... */
417 if(slot->dev) { 437 if(slot->dev) {
418 warn("slot %s already inserted", slot->hotplug_slot->name); 438 warn("slot %s already inserted", slot->hotplug_slot->name);
@@ -462,8 +482,6 @@ check_slots(void)
462 482
463 inserted++; 483 inserted++;
464 } else if(cpci_check_ext(slot)) { 484 } else if(cpci_check_ext(slot)) {
465 u16 hs_csr;
466
467 /* Process extraction request */ 485 /* Process extraction request */
468 dbg("%s - slot %s extracted", 486 dbg("%s - slot %s extracted",
469 __FUNCTION__, slot->hotplug_slot->name); 487 __FUNCTION__, slot->hotplug_slot->name);
@@ -476,20 +494,40 @@ check_slots(void)
476 if(!slot->extracting) { 494 if(!slot->extracting) {
477 if(update_latch_status(slot->hotplug_slot, 0)) { 495 if(update_latch_status(slot->hotplug_slot, 0)) {
478 warn("failure to update latch file"); 496 warn("failure to update latch file");
497
479 } 498 }
499 atomic_inc(&extracting);
480 slot->extracting = 1; 500 slot->extracting = 1;
481 } 501 }
482 extracted++; 502 extracted++;
503 } else if(slot->extracting) {
504 hs_csr = cpci_get_hs_csr(slot);
505 if(hs_csr == 0xffff) {
506 /*
507 * Hmmm, we're likely hosed at this point, should we
508 * bother trying to tell the driver or not?
509 */
510 err("card in slot %s was improperly removed",
511 slot->hotplug_slot->name);
512 if(update_adapter_status(slot->hotplug_slot, 0)) {
513 warn("failure to update adapter file");
514 }
515 slot->extracting = 0;
516 atomic_dec(&extracting);
517 }
483 } 518 }
484 } 519 }
485 spin_unlock(&list_lock); 520 up_read(&list_rwsem);
521 dbg("inserted=%d, extracted=%d, extracting=%d",
522 inserted, extracted, atomic_read(&extracting));
486 if(inserted || extracted) { 523 if(inserted || extracted) {
487 return extracted; 524 return extracted;
488 } 525 }
489 else { 526 else if(!atomic_read(&extracting)) {
490 err("cannot find ENUM# source, shutting down"); 527 err("cannot find ENUM# source, shutting down");
491 return -1; 528 return -1;
492 } 529 }
530 return 0;
493} 531}
494 532
495/* This is the interrupt mode worker thread body */ 533/* This is the interrupt mode worker thread body */
@@ -497,8 +535,6 @@ static int
497event_thread(void *data) 535event_thread(void *data)
498{ 536{
499 int rc; 537 int rc;
500 struct slot *slot;
501 struct list_head *tmp;
502 538
503 lock_kernel(); 539 lock_kernel();
504 daemonize("cpci_hp_eventd"); 540 daemonize("cpci_hp_eventd");
@@ -512,39 +548,22 @@ event_thread(void *data)
512 thread_finished); 548 thread_finished);
513 if(thread_finished || signal_pending(current)) 549 if(thread_finished || signal_pending(current))
514 break; 550 break;
515 while(controller->ops->query_enum()) { 551 do {
516 rc = check_slots(); 552 rc = check_slots();
517 if (rc > 0) 553 if (rc > 0) {
518 /* Give userspace a chance to handle extraction */ 554 /* Give userspace a chance to handle extraction */
519 msleep(500); 555 msleep(500);
520 else if (rc < 0) { 556 } else if (rc < 0) {
521 dbg("%s - error checking slots", __FUNCTION__); 557 dbg("%s - error checking slots", __FUNCTION__);
522 thread_finished = 1; 558 thread_finished = 1;
523 break; 559 break;
524 } 560 }
525 } 561 } while(atomic_read(&extracting) != 0);
526 /* Check for someone yanking out a board */
527 list_for_each(tmp, &slot_list) {
528 slot = list_entry(tmp, struct slot, slot_list);
529 if(slot->extracting) {
530 /*
531 * Hmmm, we're likely hosed at this point, should we
532 * bother trying to tell the driver or not?
533 */
534 err("card in slot %s was improperly removed",
535 slot->hotplug_slot->name);
536 if(update_adapter_status(slot->hotplug_slot, 0)) {
537 warn("failure to update adapter file");
538 }
539 slot->extracting = 0;
540 }
541 }
542 562
543 /* Re-enable ENUM# interrupt */ 563 /* Re-enable ENUM# interrupt */
544 dbg("%s - re-enabling irq", __FUNCTION__); 564 dbg("%s - re-enabling irq", __FUNCTION__);
545 controller->ops->enable_irq(); 565 controller->ops->enable_irq();
546 } 566 }
547
548 dbg("%s - event thread signals exit", __FUNCTION__); 567 dbg("%s - event thread signals exit", __FUNCTION__);
549 up(&thread_exit); 568 up(&thread_exit);
550 return 0; 569 return 0;
@@ -555,8 +574,6 @@ static int
555poll_thread(void *data) 574poll_thread(void *data)
556{ 575{
557 int rc; 576 int rc;
558 struct slot *slot;
559 struct list_head *tmp;
560 577
561 lock_kernel(); 578 lock_kernel();
562 daemonize("cpci_hp_polld"); 579 daemonize("cpci_hp_polld");
@@ -565,35 +582,19 @@ poll_thread(void *data)
565 while(1) { 582 while(1) {
566 if(thread_finished || signal_pending(current)) 583 if(thread_finished || signal_pending(current))
567 break; 584 break;
568 585 if(controller->ops->query_enum()) {
569 while(controller->ops->query_enum()) { 586 do {
570 rc = check_slots(); 587 rc = check_slots();
571 if(rc > 0) 588 if(rc > 0) {
572 /* Give userspace a chance to handle extraction */ 589 /* Give userspace a chance to handle extraction */
573 msleep(500); 590 msleep(500);
574 else if (rc < 0) { 591 } else if(rc < 0) {
575 dbg("%s - error checking slots", __FUNCTION__); 592 dbg("%s - error checking slots", __FUNCTION__);
576 thread_finished = 1; 593 thread_finished = 1;
577 break; 594 break;
578 }
579 }
580 /* Check for someone yanking out a board */
581 list_for_each(tmp, &slot_list) {
582 slot = list_entry(tmp, struct slot, slot_list);
583 if(slot->extracting) {
584 /*
585 * Hmmm, we're likely hosed at this point, should we
586 * bother trying to tell the driver or not?
587 */
588 err("card in slot %s was improperly removed",
589 slot->hotplug_slot->name);
590 if(update_adapter_status(slot->hotplug_slot, 0)) {
591 warn("failure to update adapter file");
592 } 595 }
593 slot->extracting = 0; 596 } while(atomic_read(&extracting) != 0);
594 }
595 } 597 }
596
597 msleep(100); 598 msleep(100);
598 } 599 }
599 dbg("poll thread signals exit"); 600 dbg("poll thread signals exit");
@@ -667,6 +668,9 @@ cpci_hp_unregister_controller(struct cpci_hp_controller *old_controller)
667 int status = 0; 668 int status = 0;
668 669
669 if(controller) { 670 if(controller) {
671 if(atomic_read(&extracting) != 0) {
672 return -EBUSY;
673 }
670 if(!thread_finished) { 674 if(!thread_finished) {
671 cpci_stop_thread(); 675 cpci_stop_thread();
672 } 676 }
@@ -691,12 +695,12 @@ cpci_hp_start(void)
691 return -ENODEV; 695 return -ENODEV;
692 } 696 }
693 697
694 spin_lock(&list_lock); 698 down_read(&list_rwsem);
695 if(!slots) { 699 if(list_empty(&slot_list)) {
696 spin_unlock(&list_lock); 700 up_read(&list_rwsem);
697 return -ENODEV; 701 return -ENODEV;
698 } 702 }
699 spin_unlock(&list_lock); 703 up_read(&list_rwsem);
700 704
701 if(first) { 705 if(first) {
702 status = init_slots(); 706 status = init_slots();
@@ -727,7 +731,9 @@ cpci_hp_stop(void)
727 if(!controller) { 731 if(!controller) {
728 return -ENODEV; 732 return -ENODEV;
729 } 733 }
730 734 if(atomic_read(&extracting) != 0) {
735 return -EBUSY;
736 }
731 if(controller->irq) { 737 if(controller->irq) {
732 /* Stop enum interrupt processing */ 738 /* Stop enum interrupt processing */
733 dbg("%s - disabling irq", __FUNCTION__); 739 dbg("%s - disabling irq", __FUNCTION__);
@@ -747,7 +753,7 @@ cleanup_slots(void)
747 * Unregister all of our slots with the pci_hotplug subsystem, 753 * Unregister all of our slots with the pci_hotplug subsystem,
748 * and free up all memory that we had allocated. 754 * and free up all memory that we had allocated.
749 */ 755 */
750 spin_lock(&list_lock); 756 down_write(&list_rwsem);
751 if(!slots) { 757 if(!slots) {
752 goto null_cleanup; 758 goto null_cleanup;
753 } 759 }
@@ -761,17 +767,14 @@ cleanup_slots(void)
761 kfree(slot); 767 kfree(slot);
762 } 768 }
763 null_cleanup: 769 null_cleanup:
764 spin_unlock(&list_lock); 770 up_write(&list_rwsem);
765 return; 771 return;
766} 772}
767 773
768int __init 774int __init
769cpci_hotplug_init(int debug) 775cpci_hotplug_init(int debug)
770{ 776{
771 spin_lock_init(&list_lock);
772 cpci_debug = debug; 777 cpci_debug = debug;
773
774 info(DRIVER_DESC " version: " DRIVER_VERSION);
775 return 0; 778 return 0;
776} 779}
777 780
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index 2e969616f298..69eb4fc54f2f 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -32,11 +32,7 @@
32#include "pci_hotplug.h" 32#include "pci_hotplug.h"
33#include "cpci_hotplug.h" 33#include "cpci_hotplug.h"
34 34
35#if !defined(MODULE)
36#define MY_NAME "cpci_hotplug" 35#define MY_NAME "cpci_hotplug"
37#else
38#define MY_NAME THIS_MODULE->name
39#endif
40 36
41extern int cpci_debug; 37extern int cpci_debug;
42 38
@@ -127,38 +123,6 @@ u16 cpci_get_hs_csr(struct slot* slot)
127 return hs_csr; 123 return hs_csr;
128} 124}
129 125
130#if 0
131u16 cpci_set_hs_csr(struct slot* slot, u16 hs_csr)
132{
133 int hs_cap;
134 u16 new_hs_csr;
135
136 hs_cap = pci_bus_find_capability(slot->bus,
137 slot->devfn,
138 PCI_CAP_ID_CHSWP);
139 if(!hs_cap) {
140 return 0xFFFF;
141 }
142
143 /* Write out the new value */
144 if(pci_bus_write_config_word(slot->bus,
145 slot->devfn,
146 hs_cap + 2,
147 hs_csr)) {
148 return 0xFFFF;
149 }
150
151 /* Read back what we just wrote out */
152 if(pci_bus_read_config_word(slot->bus,
153 slot->devfn,
154 hs_cap + 2,
155 &new_hs_csr)) {
156 return 0xFFFF;
157 }
158 return new_hs_csr;
159}
160#endif
161
162int cpci_check_and_clear_ins(struct slot* slot) 126int cpci_check_and_clear_ins(struct slot* slot)
163{ 127{
164 int hs_cap; 128 int hs_cap;
@@ -261,7 +225,6 @@ int cpci_led_on(struct slot* slot)
261 return -ENODEV; 225 return -ENODEV;
262 } 226 }
263 if((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) { 227 if((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) {
264 /* Set LOO */
265 hs_csr |= HS_CSR_LOO; 228 hs_csr |= HS_CSR_LOO;
266 if(pci_bus_write_config_word(slot->bus, 229 if(pci_bus_write_config_word(slot->bus,
267 slot->devfn, 230 slot->devfn,
@@ -293,7 +256,6 @@ int cpci_led_off(struct slot* slot)
293 return -ENODEV; 256 return -ENODEV;
294 } 257 }
295 if(hs_csr & HS_CSR_LOO) { 258 if(hs_csr & HS_CSR_LOO) {
296 /* Clear LOO */
297 hs_csr &= ~HS_CSR_LOO; 259 hs_csr &= ~HS_CSR_LOO;
298 if(pci_bus_write_config_word(slot->bus, 260 if(pci_bus_write_config_word(slot->bus,
299 slot->devfn, 261 slot->devfn,
@@ -312,257 +274,23 @@ int cpci_led_off(struct slot* slot)
312 * Device configuration functions 274 * Device configuration functions
313 */ 275 */
314 276
315static int cpci_configure_dev(struct pci_bus *bus, struct pci_dev *dev) 277static void cpci_enable_device(struct pci_dev *dev)
316{
317 u8 irq_pin;
318 int r;
319
320 dbg("%s - enter", __FUNCTION__);
321
322 /* NOTE: device already setup from prior scan */
323
324 /* FIXME: How would we know if we need to enable the expansion ROM? */
325 pci_write_config_word(dev, PCI_ROM_ADDRESS, 0x00L);
326
327 /* Assign resources */
328 dbg("assigning resources for %02x:%02x.%x",
329 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
330 for (r = 0; r < 6; r++) {
331 struct resource *res = dev->resource + r;
332 if(res->flags)
333 pci_assign_resource(dev, r);
334 }
335 dbg("finished assigning resources for %02x:%02x.%x",
336 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
337
338 /* Does this function have an interrupt at all? */
339 dbg("checking for function interrupt");
340 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq_pin);
341 if(irq_pin) {
342 dbg("function uses interrupt pin %d", irq_pin);
343 }
344
345 /*
346 * Need to explicitly set irq field to 0 so that it'll get assigned
347 * by the pcibios platform dependent code called by pci_enable_device.
348 */
349 dev->irq = 0;
350
351 dbg("enabling device");
352 pci_enable_device(dev); /* XXX check return */
353 dbg("now dev->irq = %d", dev->irq);
354 if(irq_pin && dev->irq) {
355 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
356 }
357
358 /* Can't use pci_insert_device at the moment, do it manually for now */
359 pci_proc_attach_device(dev);
360 dbg("notifying drivers");
361 //pci_announce_device_to_drivers(dev);
362 dbg("%s - exit", __FUNCTION__);
363 return 0;
364}
365
366static int cpci_configure_bridge(struct pci_bus* bus, struct pci_dev* dev)
367{ 278{
368 int rc; 279 struct pci_bus *bus;
369 struct pci_bus* child;
370 struct resource* r;
371 u8 max, n;
372 u16 command;
373
374 dbg("%s - enter", __FUNCTION__);
375 280
376 /* Do basic bridge initialization */ 281 pci_enable_device(dev);
377 rc = pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x40);
378 if(rc) {
379 printk(KERN_ERR "%s - write of PCI_LATENCY_TIMER failed\n", __FUNCTION__);
380 }
381 rc = pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 0x40);
382 if(rc) {
383 printk(KERN_ERR "%s - write of PCI_SEC_LATENCY_TIMER failed\n", __FUNCTION__);
384 }
385 rc = pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4);
386 if(rc) {
387 printk(KERN_ERR "%s - write of PCI_CACHE_LINE_SIZE failed\n", __FUNCTION__);
388 }
389
390 /*
391 * Set parent bridge's subordinate field so that configuration space
392 * access will work in pci_scan_bridge and friends.
393 */
394 max = pci_max_busnr();
395 bus->subordinate = max + 1;
396 pci_write_config_byte(bus->self, PCI_SUBORDINATE_BUS, max + 1);
397
398 /* Scan behind bridge */
399 n = pci_scan_bridge(bus, dev, max, 2);
400 child = pci_find_bus(0, max + 1);
401 if (!child)
402 return -ENODEV;
403 pci_proc_attach_bus(child);
404
405 /*
406 * Update parent bridge's subordinate field if there were more bridges
407 * behind the bridge that was scanned.
408 */
409 if(n > max) {
410 bus->subordinate = n;
411 pci_write_config_byte(bus->self, PCI_SUBORDINATE_BUS, n);
412 }
413
414 /*
415 * Update the bridge resources of the bridge to accommodate devices
416 * behind it.
417 */
418 pci_bus_size_bridges(child);
419 pci_bus_assign_resources(child);
420
421 /* Enable resource mapping via command register */
422 command = PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
423 r = child->resource[0];
424 if(r && r->start) {
425 command |= PCI_COMMAND_IO;
426 }
427 r = child->resource[1];
428 if(r && r->start) {
429 command |= PCI_COMMAND_MEMORY;
430 }
431 r = child->resource[2];
432 if(r && r->start) {
433 command |= PCI_COMMAND_MEMORY;
434 }
435 rc = pci_write_config_word(dev, PCI_COMMAND, command);
436 if(rc) {
437 err("Error setting command register");
438 return rc;
439 }
440
441 /* Set bridge control register */
442 command = PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR | PCI_BRIDGE_CTL_NO_ISA;
443 rc = pci_write_config_word(dev, PCI_BRIDGE_CONTROL, command);
444 if(rc) {
445 err("Error setting bridge control register");
446 return rc;
447 }
448 dbg("%s - exit", __FUNCTION__);
449 return 0;
450}
451
452static int configure_visit_pci_dev(struct pci_dev_wrapped *wrapped_dev,
453 struct pci_bus_wrapped *wrapped_bus)
454{
455 int rc;
456 struct pci_dev *dev = wrapped_dev->dev;
457 struct pci_bus *bus = wrapped_bus->bus;
458 struct slot* slot;
459
460 dbg("%s - enter", __FUNCTION__);
461
462 /*
463 * We need to fix up the hotplug representation with the Linux
464 * representation.
465 */
466 if(wrapped_dev->data) {
467 slot = (struct slot*) wrapped_dev->data;
468 slot->dev = dev;
469 }
470
471 /* If it's a bridge, scan behind it for devices */
472 if(dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 282 if(dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
473 rc = cpci_configure_bridge(bus, dev); 283 bus = dev->subordinate;
474 if(rc) 284 list_for_each_entry(dev, &bus->devices, bus_list) {
475 return rc; 285 cpci_enable_device(dev);
476 }
477
478 /* Actually configure device */
479 if(dev) {
480 rc = cpci_configure_dev(bus, dev);
481 if(rc)
482 return rc;
483 }
484 dbg("%s - exit", __FUNCTION__);
485 return 0;
486}
487
488static int unconfigure_visit_pci_dev_phase2(struct pci_dev_wrapped *wrapped_dev,
489 struct pci_bus_wrapped *wrapped_bus)
490{
491 struct pci_dev *dev = wrapped_dev->dev;
492 struct slot* slot;
493
494 dbg("%s - enter", __FUNCTION__);
495 if(!dev)
496 return -ENODEV;
497
498 /* Remove the Linux representation */
499 if(pci_remove_device_safe(dev)) {
500 err("Could not remove device\n");
501 return -1;
502 }
503
504 /*
505 * Now remove the hotplug representation.
506 */
507 if(wrapped_dev->data) {
508 slot = (struct slot*) wrapped_dev->data;
509 slot->dev = NULL;
510 } else {
511 dbg("No hotplug representation for %02x:%02x.%x",
512 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
513 }
514 dbg("%s - exit", __FUNCTION__);
515 return 0;
516}
517
518static int unconfigure_visit_pci_bus_phase2(struct pci_bus_wrapped *wrapped_bus,
519 struct pci_dev_wrapped *wrapped_dev)
520{
521 struct pci_bus *bus = wrapped_bus->bus;
522 struct pci_bus *parent = bus->self->bus;
523
524 dbg("%s - enter", __FUNCTION__);
525
526 /* The cleanup code for proc entries regarding buses should be in the kernel... */
527 if(bus->procdir)
528 dbg("detach_pci_bus %s", bus->procdir->name);
529 pci_proc_detach_bus(bus);
530
531 /* The cleanup code should live in the kernel... */
532 bus->self->subordinate = NULL;
533
534 /* unlink from parent bus */
535 list_del(&bus->node);
536
537 /* Now, remove */
538 if(bus)
539 kfree(bus);
540
541 /* Update parent's subordinate field */
542 if(parent) {
543 u8 n = pci_bus_max_busnr(parent);
544 if(n < parent->subordinate) {
545 parent->subordinate = n;
546 pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, n);
547 } 286 }
548 } 287 }
549 dbg("%s - exit", __FUNCTION__);
550 return 0;
551} 288}
552 289
553static struct pci_visit configure_functions = {
554 .visit_pci_dev = configure_visit_pci_dev,
555};
556
557static struct pci_visit unconfigure_functions_phase2 = {
558 .post_visit_pci_bus = unconfigure_visit_pci_bus_phase2,
559 .post_visit_pci_dev = unconfigure_visit_pci_dev_phase2
560};
561
562
563int cpci_configure_slot(struct slot* slot) 290int cpci_configure_slot(struct slot* slot)
564{ 291{
565 int rc = 0; 292 unsigned char busnr;
293 struct pci_bus *child;
566 294
567 dbg("%s - enter", __FUNCTION__); 295 dbg("%s - enter", __FUNCTION__);
568 296
@@ -588,74 +316,44 @@ int cpci_configure_slot(struct slot* slot)
588 slot->dev = pci_find_slot(slot->bus->number, slot->devfn); 316 slot->dev = pci_find_slot(slot->bus->number, slot->devfn);
589 if(slot->dev == NULL) { 317 if(slot->dev == NULL) {
590 err("Could not find PCI device for slot %02x", slot->number); 318 err("Could not find PCI device for slot %02x", slot->number);
591 return 0; 319 return 1;
592 } 320 }
593 } 321 }
594 dbg("slot->dev = %p", slot->dev); 322
595 if(slot->dev) { 323 if (slot->dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
596 struct pci_dev *dev; 324 pci_read_config_byte(slot->dev, PCI_SECONDARY_BUS, &busnr);
597 struct pci_dev_wrapped wrapped_dev; 325 child = pci_add_new_bus(slot->dev->bus, slot->dev, busnr);
598 struct pci_bus_wrapped wrapped_bus; 326 pci_do_scan_bus(child);
599 int i; 327 pci_bus_size_bridges(child);
600
601 memset(&wrapped_dev, 0, sizeof (struct pci_dev_wrapped));
602 memset(&wrapped_bus, 0, sizeof (struct pci_bus_wrapped));
603
604 for (i = 0; i < 8; i++) {
605 dev = pci_find_slot(slot->bus->number,
606 PCI_DEVFN(PCI_SLOT(slot->dev->devfn), i));
607 if(!dev)
608 continue;
609 wrapped_dev.dev = dev;
610 wrapped_bus.bus = slot->dev->bus;
611 if(i)
612 wrapped_dev.data = NULL;
613 else
614 wrapped_dev.data = (void*) slot;
615 rc = pci_visit_dev(&configure_functions, &wrapped_dev, &wrapped_bus);
616 }
617 } 328 }
618 329
619 dbg("%s - exit, rc = %d", __FUNCTION__, rc); 330 pci_bus_assign_resources(slot->dev->bus);
620 return rc; 331
332 cpci_enable_device(slot->dev);
333
334 dbg("%s - exit", __FUNCTION__);
335 return 0;
621} 336}
622 337
623int cpci_unconfigure_slot(struct slot* slot) 338int cpci_unconfigure_slot(struct slot* slot)
624{ 339{
625 int rc = 0;
626 int i; 340 int i;
627 struct pci_dev_wrapped wrapped_dev;
628 struct pci_bus_wrapped wrapped_bus;
629 struct pci_dev *dev; 341 struct pci_dev *dev;
630 342
631 dbg("%s - enter", __FUNCTION__); 343 dbg("%s - enter", __FUNCTION__);
632
633 if(!slot->dev) { 344 if(!slot->dev) {
634 err("No device for slot %02x\n", slot->number); 345 err("No device for slot %02x\n", slot->number);
635 return -ENODEV; 346 return -ENODEV;
636 } 347 }
637 348
638 memset(&wrapped_dev, 0, sizeof (struct pci_dev_wrapped));
639 memset(&wrapped_bus, 0, sizeof (struct pci_bus_wrapped));
640
641 for (i = 0; i < 8; i++) { 349 for (i = 0; i < 8; i++) {
642 dev = pci_find_slot(slot->bus->number, 350 dev = pci_find_slot(slot->bus->number,
643 PCI_DEVFN(PCI_SLOT(slot->devfn), i)); 351 PCI_DEVFN(PCI_SLOT(slot->devfn), i));
644 if(dev) { 352 if(dev) {
645 wrapped_dev.dev = dev; 353 pci_remove_bus_device(dev);
646 wrapped_bus.bus = dev->bus; 354 slot->dev = NULL;
647 if(i)
648 wrapped_dev.data = NULL;
649 else
650 wrapped_dev.data = (void*) slot;
651 dbg("%s - unconfigure phase 2", __FUNCTION__);
652 rc = pci_visit_dev(&unconfigure_functions_phase2,
653 &wrapped_dev,
654 &wrapped_bus);
655 if(rc)
656 break;
657 } 355 }
658 } 356 }
659 dbg("%s - exit, rc = %d", __FUNCTION__, rc); 357 dbg("%s - exit", __FUNCTION__);
660 return rc; 358 return 0;
661} 359}
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index f313121d5141..46b294a12418 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -130,6 +130,7 @@ struct controller {
130 u8 slot_bus; /* Bus where the slots handled by this controller sit */ 130 u8 slot_bus; /* Bus where the slots handled by this controller sit */
131 u8 ctrlcap; 131 u8 ctrlcap;
132 u16 vendor_id; 132 u16 vendor_id;
133 u8 cap_base;
133}; 134};
134 135
135struct irq_mapping { 136struct irq_mapping {
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index ed1fd8d6178d..df4915dbc321 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -607,7 +607,7 @@ static int pciehp_resume (struct pcie_device *dev)
607static struct pcie_port_service_id port_pci_ids[] = { { 607static struct pcie_port_service_id port_pci_ids[] = { {
608 .vendor = PCI_ANY_ID, 608 .vendor = PCI_ANY_ID,
609 .device = PCI_ANY_ID, 609 .device = PCI_ANY_ID,
610 .port_type = PCIE_RC_PORT, 610 .port_type = PCIE_ANY_PORT,
611 .service_type = PCIE_PORT_SERVICE_HP, 611 .service_type = PCIE_PORT_SERVICE_HP,
612 .driver_data = 0, 612 .driver_data = 0,
613 }, { /* end: all zeroes */ } 613 }, { /* end: all zeroes */ }
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 9e70c4681f77..1cda30bd6e47 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -109,20 +109,20 @@ enum ctrl_offsets {
109}; 109};
110static int pcie_cap_base = 0; /* Base of the PCI Express capability item structure */ 110static int pcie_cap_base = 0; /* Base of the PCI Express capability item structure */
111 111
112#define PCIE_CAP_ID ( pcie_cap_base + PCIECAPID ) 112#define PCIE_CAP_ID(cb) ( cb + PCIECAPID )
113#define NXT_CAP_PTR ( pcie_cap_base + NXTCAPPTR ) 113#define NXT_CAP_PTR(cb) ( cb + NXTCAPPTR )
114#define CAP_REG ( pcie_cap_base + CAPREG ) 114#define CAP_REG(cb) ( cb + CAPREG )
115#define DEV_CAP ( pcie_cap_base + DEVCAP ) 115#define DEV_CAP(cb) ( cb + DEVCAP )
116#define DEV_CTRL ( pcie_cap_base + DEVCTRL ) 116#define DEV_CTRL(cb) ( cb + DEVCTRL )
117#define DEV_STATUS ( pcie_cap_base + DEVSTATUS ) 117#define DEV_STATUS(cb) ( cb + DEVSTATUS )
118#define LNK_CAP ( pcie_cap_base + LNKCAP ) 118#define LNK_CAP(cb) ( cb + LNKCAP )
119#define LNK_CTRL ( pcie_cap_base + LNKCTRL ) 119#define LNK_CTRL(cb) ( cb + LNKCTRL )
120#define LNK_STATUS ( pcie_cap_base + LNKSTATUS ) 120#define LNK_STATUS(cb) ( cb + LNKSTATUS )
121#define SLOT_CAP ( pcie_cap_base + SLOTCAP ) 121#define SLOT_CAP(cb) ( cb + SLOTCAP )
122#define SLOT_CTRL ( pcie_cap_base + SLOTCTRL ) 122#define SLOT_CTRL(cb) ( cb + SLOTCTRL )
123#define SLOT_STATUS ( pcie_cap_base + SLOTSTATUS ) 123#define SLOT_STATUS(cb) ( cb + SLOTSTATUS )
124#define ROOT_CTRL ( pcie_cap_base + ROOTCTRL ) 124#define ROOT_CTRL(cb) ( cb + ROOTCTRL )
125#define ROOT_STATUS ( pcie_cap_base + ROOTSTATUS ) 125#define ROOT_STATUS(cb) ( cb + ROOTSTATUS )
126 126
127#define hp_register_read_word(pdev, reg , value) \ 127#define hp_register_read_word(pdev, reg , value) \
128 pci_read_config_word(pdev, reg, &value) 128 pci_read_config_word(pdev, reg, &value)
@@ -303,7 +303,7 @@ static int pcie_write_cmd(struct slot *slot, u16 cmd)
303 return -1; 303 return -1;
304 } 304 }
305 305
306 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 306 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
307 if (retval) { 307 if (retval) {
308 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 308 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
309 return retval; 309 return retval;
@@ -317,7 +317,7 @@ static int pcie_write_cmd(struct slot *slot, u16 cmd)
317 } 317 }
318 318
319 dbg("%s: Before hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, cmd); 319 dbg("%s: Before hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, cmd);
320 retval = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, cmd | CMD_CMPL_INTR_ENABLE); 320 retval = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), cmd | CMD_CMPL_INTR_ENABLE);
321 if (retval) { 321 if (retval) {
322 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 322 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
323 return retval; 323 return retval;
@@ -342,7 +342,7 @@ static int hpc_check_lnk_status(struct controller *ctrl)
342 return -1; 342 return -1;
343 } 343 }
344 344
345 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 345 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(ctrl->cap_base), lnk_status);
346 346
347 if (retval) { 347 if (retval) {
348 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); 348 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__);
@@ -376,14 +376,14 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status)
376 return -1; 376 return -1;
377 } 377 }
378 378
379 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 379 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
380 380
381 if (retval) { 381 if (retval) {
382 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 382 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
383 return retval; 383 return retval;
384 } 384 }
385 385
386 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__,SLOT_CTRL, slot_ctrl); 386 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__,SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
387 387
388 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6; 388 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6;
389 389
@@ -423,13 +423,13 @@ static int hpc_get_power_status(struct slot * slot, u8 *status)
423 return -1; 423 return -1;
424 } 424 }
425 425
426 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 426 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
427 427
428 if (retval) { 428 if (retval) {
429 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 429 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
430 return retval; 430 return retval;
431 } 431 }
432 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, slot_ctrl); 432 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
433 433
434 pwr_state = (slot_ctrl & PWR_CTRL) >> 10; 434 pwr_state = (slot_ctrl & PWR_CTRL) >> 10;
435 435
@@ -463,7 +463,7 @@ static int hpc_get_latch_status(struct slot *slot, u8 *status)
463 return -1; 463 return -1;
464 } 464 }
465 465
466 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 466 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
467 467
468 if (retval) { 468 if (retval) {
469 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 469 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
@@ -490,7 +490,7 @@ static int hpc_get_adapter_status(struct slot *slot, u8 *status)
490 return -1; 490 return -1;
491 } 491 }
492 492
493 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 493 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
494 494
495 if (retval) { 495 if (retval) {
496 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 496 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
@@ -518,7 +518,7 @@ static int hpc_query_power_fault(struct slot * slot)
518 return -1; 518 return -1;
519 } 519 }
520 520
521 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 521 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
522 522
523 if (retval) { 523 if (retval) {
524 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 524 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
@@ -549,7 +549,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
549 err("%s: Invalid HPC slot number!\n", __FUNCTION__); 549 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
550 return -1; 550 return -1;
551 } 551 }
552 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 552 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
553 553
554 if (rc) { 554 if (rc) {
555 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 555 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
@@ -574,7 +574,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
574 slot_cmd = slot_cmd | HP_INTR_ENABLE; 574 slot_cmd = slot_cmd | HP_INTR_ENABLE;
575 575
576 pcie_write_cmd(slot, slot_cmd); 576 pcie_write_cmd(slot, slot_cmd);
577 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL, slot_cmd); 577 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
578 578
579 return rc; 579 return rc;
580} 580}
@@ -598,7 +598,7 @@ static void hpc_set_green_led_on(struct slot *slot)
598 return ; 598 return ;
599 } 599 }
600 600
601 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 601 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
602 602
603 if (rc) { 603 if (rc) {
604 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 604 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
@@ -611,7 +611,7 @@ static void hpc_set_green_led_on(struct slot *slot)
611 611
612 pcie_write_cmd(slot, slot_cmd); 612 pcie_write_cmd(slot, slot_cmd);
613 613
614 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 614 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
615 return; 615 return;
616} 616}
617 617
@@ -633,7 +633,7 @@ static void hpc_set_green_led_off(struct slot *slot)
633 return ; 633 return ;
634 } 634 }
635 635
636 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 636 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
637 637
638 if (rc) { 638 if (rc) {
639 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 639 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
@@ -646,7 +646,7 @@ static void hpc_set_green_led_off(struct slot *slot)
646 if (!pciehp_poll_mode) 646 if (!pciehp_poll_mode)
647 slot_cmd = slot_cmd | HP_INTR_ENABLE; 647 slot_cmd = slot_cmd | HP_INTR_ENABLE;
648 pcie_write_cmd(slot, slot_cmd); 648 pcie_write_cmd(slot, slot_cmd);
649 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL, slot_cmd); 649 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
650 650
651 return; 651 return;
652} 652}
@@ -669,7 +669,7 @@ static void hpc_set_green_led_blink(struct slot *slot)
669 return ; 669 return ;
670 } 670 }
671 671
672 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 672 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
673 673
674 if (rc) { 674 if (rc) {
675 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 675 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
@@ -683,7 +683,7 @@ static void hpc_set_green_led_blink(struct slot *slot)
683 slot_cmd = slot_cmd | HP_INTR_ENABLE; 683 slot_cmd = slot_cmd | HP_INTR_ENABLE;
684 pcie_write_cmd(slot, slot_cmd); 684 pcie_write_cmd(slot, slot_cmd);
685 685
686 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 686 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
687 return; 687 return;
688} 688}
689 689
@@ -707,7 +707,7 @@ int pcie_get_ctlr_slot_config(struct controller *ctrl,
707 *first_device_num = 0; 707 *first_device_num = 0;
708 *num_ctlr_slots = 1; 708 *num_ctlr_slots = 1;
709 709
710 rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP, slot_cap); 710 rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP(ctrl->cap_base), slot_cap);
711 711
712 if (rc) { 712 if (rc) {
713 err("%s : hp_register_read_dword SLOT_CAP failed\n", __FUNCTION__); 713 err("%s : hp_register_read_dword SLOT_CAP failed\n", __FUNCTION__);
@@ -793,13 +793,13 @@ static int hpc_power_on_slot(struct slot * slot)
793 return -1; 793 return -1;
794 } 794 }
795 795
796 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 796 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
797 797
798 if (retval) { 798 if (retval) {
799 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 799 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
800 return retval; 800 return retval;
801 } 801 }
802 dbg("%s: SLOT_CTRL %x, value read %xn", __FUNCTION__, SLOT_CTRL, 802 dbg("%s: SLOT_CTRL %x, value read %xn", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base),
803 slot_ctrl); 803 slot_ctrl);
804 804
805 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON; 805 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON;
@@ -813,7 +813,7 @@ static int hpc_power_on_slot(struct slot * slot)
813 err("%s: Write %x command failed!\n", __FUNCTION__, slot_cmd); 813 err("%s: Write %x command failed!\n", __FUNCTION__, slot_cmd);
814 return -1; 814 return -1;
815 } 815 }
816 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 816 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
817 817
818 DBG_LEAVE_ROUTINE 818 DBG_LEAVE_ROUTINE
819 819
@@ -842,13 +842,13 @@ static int hpc_power_off_slot(struct slot * slot)
842 err("%s: Invalid HPC slot number!\n", __FUNCTION__); 842 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
843 return -1; 843 return -1;
844 } 844 }
845 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 845 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
846 846
847 if (retval) { 847 if (retval) {
848 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 848 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
849 return retval; 849 return retval;
850 } 850 }
851 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__, SLOT_CTRL, 851 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base),
852 slot_ctrl); 852 slot_ctrl);
853 853
854 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF; 854 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF;
@@ -862,7 +862,7 @@ static int hpc_power_off_slot(struct slot * slot)
862 err("%s: Write command failed!\n", __FUNCTION__); 862 err("%s: Write command failed!\n", __FUNCTION__);
863 return -1; 863 return -1;
864 } 864 }
865 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 865 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
866 866
867 DBG_LEAVE_ROUTINE 867 DBG_LEAVE_ROUTINE
868 868
@@ -900,7 +900,7 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
900 return IRQ_NONE; 900 return IRQ_NONE;
901 } 901 }
902 902
903 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 903 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
904 if (rc) { 904 if (rc) {
905 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 905 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
906 return IRQ_NONE; 906 return IRQ_NONE;
@@ -918,7 +918,7 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
918 dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc); 918 dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc);
919 /* Mask Hot-plug Interrupt Enable */ 919 /* Mask Hot-plug Interrupt Enable */
920 if (!pciehp_poll_mode) { 920 if (!pciehp_poll_mode) {
921 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 921 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
922 if (rc) { 922 if (rc) {
923 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 923 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
924 return IRQ_NONE; 924 return IRQ_NONE;
@@ -928,14 +928,14 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
928 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 928 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
929 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 929 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00;
930 930
931 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 931 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
932 if (rc) { 932 if (rc) {
933 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 933 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
934 return IRQ_NONE; 934 return IRQ_NONE;
935 } 935 }
936 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 936 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
937 937
938 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 938 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
939 if (rc) { 939 if (rc) {
940 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 940 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
941 return IRQ_NONE; 941 return IRQ_NONE;
@@ -944,7 +944,7 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
944 944
945 /* Clear command complete interrupt caused by this write */ 945 /* Clear command complete interrupt caused by this write */
946 temp_word = 0x1f; 946 temp_word = 0x1f;
947 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 947 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
948 if (rc) { 948 if (rc) {
949 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 949 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
950 return IRQ_NONE; 950 return IRQ_NONE;
@@ -975,14 +975,14 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
975 975
976 /* Clear all events after serving them */ 976 /* Clear all events after serving them */
977 temp_word = 0x1F; 977 temp_word = 0x1F;
978 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 978 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
979 if (rc) { 979 if (rc) {
980 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 980 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
981 return IRQ_NONE; 981 return IRQ_NONE;
982 } 982 }
983 /* Unmask Hot-plug Interrupt Enable */ 983 /* Unmask Hot-plug Interrupt Enable */
984 if (!pciehp_poll_mode) { 984 if (!pciehp_poll_mode) {
985 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 985 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
986 if (rc) { 986 if (rc) {
987 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 987 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
988 return IRQ_NONE; 988 return IRQ_NONE;
@@ -992,14 +992,14 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
992 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 992 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
993 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE; 993 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE;
994 994
995 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 995 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
996 if (rc) { 996 if (rc) {
997 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 997 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
998 return IRQ_NONE; 998 return IRQ_NONE;
999 } 999 }
1000 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 1000 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
1001 1001
1002 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1002 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1003 if (rc) { 1003 if (rc) {
1004 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1004 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1005 return IRQ_NONE; 1005 return IRQ_NONE;
@@ -1008,7 +1008,7 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
1008 1008
1009 /* Clear command complete interrupt caused by this write */ 1009 /* Clear command complete interrupt caused by this write */
1010 temp_word = 0x1F; 1010 temp_word = 0x1F;
1011 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1011 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
1012 if (rc) { 1012 if (rc) {
1013 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1013 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
1014 return IRQ_NONE; 1014 return IRQ_NONE;
@@ -1038,7 +1038,7 @@ static int hpc_get_max_lnk_speed (struct slot *slot, enum pci_bus_speed *value)
1038 return -1; 1038 return -1;
1039 } 1039 }
1040 1040
1041 retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP, lnk_cap); 1041 retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP(slot->ctrl->cap_base), lnk_cap);
1042 1042
1043 if (retval) { 1043 if (retval) {
1044 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); 1044 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__);
@@ -1079,7 +1079,7 @@ static int hpc_get_max_lnk_width (struct slot *slot, enum pcie_link_width *value
1079 return -1; 1079 return -1;
1080 } 1080 }
1081 1081
1082 retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP, lnk_cap); 1082 retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP(slot->ctrl->cap_base), lnk_cap);
1083 1083
1084 if (retval) { 1084 if (retval) {
1085 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); 1085 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__);
@@ -1141,7 +1141,7 @@ static int hpc_get_cur_lnk_speed (struct slot *slot, enum pci_bus_speed *value)
1141 return -1; 1141 return -1;
1142 } 1142 }
1143 1143
1144 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 1144 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(slot->ctrl->cap_base), lnk_status);
1145 1145
1146 if (retval) { 1146 if (retval) {
1147 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); 1147 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__);
@@ -1182,7 +1182,7 @@ static int hpc_get_cur_lnk_width (struct slot *slot, enum pcie_link_width *value
1182 return -1; 1182 return -1;
1183 } 1183 }
1184 1184
1185 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 1185 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(slot->ctrl->cap_base), lnk_status);
1186 1186
1187 if (retval) { 1187 if (retval) {
1188 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); 1188 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__);
@@ -1292,47 +1292,48 @@ int pcie_init(struct controller * ctrl,
1292 goto abort_free_ctlr; 1292 goto abort_free_ctlr;
1293 } 1293 }
1294 1294
1295 pcie_cap_base = cap_base; 1295 ctrl->cap_base = cap_base;
1296 1296
1297 dbg("%s: pcie_cap_base %x\n", __FUNCTION__, pcie_cap_base); 1297 dbg("%s: pcie_cap_base %x\n", __FUNCTION__, pcie_cap_base);
1298 1298
1299 rc = hp_register_read_word(pdev, CAP_REG, cap_reg); 1299 rc = hp_register_read_word(pdev, CAP_REG(ctrl->cap_base), cap_reg);
1300 if (rc) { 1300 if (rc) {
1301 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1301 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__);
1302 goto abort_free_ctlr; 1302 goto abort_free_ctlr;
1303 } 1303 }
1304 dbg("%s: CAP_REG offset %x cap_reg %x\n", __FUNCTION__, CAP_REG, cap_reg); 1304 dbg("%s: CAP_REG offset %x cap_reg %x\n", __FUNCTION__, CAP_REG(ctrl->cap_base), cap_reg);
1305 1305
1306 if (((cap_reg & SLOT_IMPL) == 0) || ((cap_reg & DEV_PORT_TYPE) != 0x0040)){ 1306 if (((cap_reg & SLOT_IMPL) == 0) || (((cap_reg & DEV_PORT_TYPE) != 0x0040)
1307 && ((cap_reg & DEV_PORT_TYPE) != 0x0060))) {
1307 dbg("%s : This is not a root port or the port is not connected to a slot\n", __FUNCTION__); 1308 dbg("%s : This is not a root port or the port is not connected to a slot\n", __FUNCTION__);
1308 goto abort_free_ctlr; 1309 goto abort_free_ctlr;
1309 } 1310 }
1310 1311
1311 rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP, slot_cap); 1312 rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP(ctrl->cap_base), slot_cap);
1312 if (rc) { 1313 if (rc) {
1313 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1314 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__);
1314 goto abort_free_ctlr; 1315 goto abort_free_ctlr;
1315 } 1316 }
1316 dbg("%s: SLOT_CAP offset %x slot_cap %x\n", __FUNCTION__, SLOT_CAP, slot_cap); 1317 dbg("%s: SLOT_CAP offset %x slot_cap %x\n", __FUNCTION__, SLOT_CAP(ctrl->cap_base), slot_cap);
1317 1318
1318 if (!(slot_cap & HP_CAP)) { 1319 if (!(slot_cap & HP_CAP)) {
1319 dbg("%s : This slot is not hot-plug capable\n", __FUNCTION__); 1320 dbg("%s : This slot is not hot-plug capable\n", __FUNCTION__);
1320 goto abort_free_ctlr; 1321 goto abort_free_ctlr;
1321 } 1322 }
1322 /* For debugging purpose */ 1323 /* For debugging purpose */
1323 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1324 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1324 if (rc) { 1325 if (rc) {
1325 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1326 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1326 goto abort_free_ctlr; 1327 goto abort_free_ctlr;
1327 } 1328 }
1328 dbg("%s: SLOT_STATUS offset %x slot_status %x\n", __FUNCTION__, SLOT_STATUS, slot_status); 1329 dbg("%s: SLOT_STATUS offset %x slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), slot_status);
1329 1330
1330 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 1331 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl);
1331 if (rc) { 1332 if (rc) {
1332 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1333 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
1333 goto abort_free_ctlr; 1334 goto abort_free_ctlr;
1334 } 1335 }
1335 dbg("%s: SLOT_CTRL offset %x slot_ctrl %x\n", __FUNCTION__, SLOT_CTRL, slot_ctrl); 1336 dbg("%s: SLOT_CTRL offset %x slot_ctrl %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), slot_ctrl);
1336 1337
1337 if (first) { 1338 if (first) {
1338 spin_lock_init(&hpc_event_lock); 1339 spin_lock_init(&hpc_event_lock);
@@ -1372,36 +1373,37 @@ int pcie_init(struct controller * ctrl,
1372 php_ctlr->num_slots = 1; 1373 php_ctlr->num_slots = 1;
1373 1374
1374 /* Mask Hot-plug Interrupt Enable */ 1375 /* Mask Hot-plug Interrupt Enable */
1375 rc = hp_register_read_word(pdev, SLOT_CTRL, temp_word); 1376 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1376 if (rc) { 1377 if (rc) {
1377 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1378 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
1378 goto abort_free_ctlr; 1379 goto abort_free_ctlr;
1379 } 1380 }
1380 1381
1381 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, temp_word); 1382 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), temp_word);
1382 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 1383 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00;
1383 1384
1384 rc = hp_register_write_word(pdev, SLOT_CTRL, temp_word); 1385 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1385 if (rc) { 1386 if (rc) {
1386 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1387 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
1387 goto abort_free_ctlr; 1388 goto abort_free_ctlr;
1388 } 1389 }
1389 dbg("%s : Mask HPIE hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, temp_word); 1390 dbg("%s : Mask HPIE hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, temp_word);
1390 1391
1391 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1392 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1392 if (rc) { 1393 if (rc) {
1393 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1394 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1394 goto abort_free_ctlr; 1395 goto abort_free_ctlr;
1395 } 1396 }
1396 dbg("%s: Mask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, SLOT_STATUS, slot_status); 1397 dbg("%s: Mask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base)
1398 , slot_status);
1397 1399
1398 temp_word = 0x1F; /* Clear all events */ 1400 temp_word = 0x1F; /* Clear all events */
1399 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1401 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
1400 if (rc) { 1402 if (rc) {
1401 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1403 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
1402 goto abort_free_ctlr; 1404 goto abort_free_ctlr;
1403 } 1405 }
1404 dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS, temp_word); 1406 dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), temp_word);
1405 1407
1406 if (pciehp_poll_mode) {/* Install interrupt polling code */ 1408 if (pciehp_poll_mode) {/* Install interrupt polling code */
1407 /* Install and start the interrupt polling timer */ 1409 /* Install and start the interrupt polling timer */
@@ -1417,12 +1419,12 @@ int pcie_init(struct controller * ctrl,
1417 } 1419 }
1418 } 1420 }
1419 1421
1420 rc = hp_register_read_word(pdev, SLOT_CTRL, temp_word); 1422 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1421 if (rc) { 1423 if (rc) {
1422 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1424 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
1423 goto abort_free_ctlr; 1425 goto abort_free_ctlr;
1424 } 1426 }
1425 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, temp_word); 1427 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), temp_word);
1426 dbg("%s: slot_cap %x\n", __FUNCTION__, slot_cap); 1428 dbg("%s: slot_cap %x\n", __FUNCTION__, slot_cap);
1427 1429
1428 intr_enable = intr_enable | PRSN_DETECT_ENABLE; 1430 intr_enable = intr_enable | PRSN_DETECT_ENABLE;
@@ -1446,27 +1448,27 @@ int pcie_init(struct controller * ctrl,
1446 dbg("%s: temp_word %x\n", __FUNCTION__, temp_word); 1448 dbg("%s: temp_word %x\n", __FUNCTION__, temp_word);
1447 1449
1448 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */ 1450 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */
1449 rc = hp_register_write_word(pdev, SLOT_CTRL, temp_word); 1451 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1450 if (rc) { 1452 if (rc) {
1451 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1453 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
1452 goto abort_free_ctlr; 1454 goto abort_free_ctlr;
1453 } 1455 }
1454 dbg("%s : Unmask HPIE hp_register_write_word SLOT_CTRL with %x\n", __FUNCTION__, temp_word); 1456 dbg("%s : Unmask HPIE hp_register_write_word SLOT_CTRL with %x\n", __FUNCTION__, temp_word);
1455 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1457 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1456 if (rc) { 1458 if (rc) {
1457 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1459 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1458 goto abort_free_ctlr; 1460 goto abort_free_ctlr;
1459 } 1461 }
1460 dbg("%s: Unmask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, 1462 dbg("%s: Unmask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__,
1461 SLOT_STATUS, slot_status); 1463 SLOT_STATUS(ctrl->cap_base), slot_status);
1462 1464
1463 temp_word = 0x1F; /* Clear all events */ 1465 temp_word = 0x1F; /* Clear all events */
1464 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1466 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
1465 if (rc) { 1467 if (rc) {
1466 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1468 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
1467 goto abort_free_ctlr; 1469 goto abort_free_ctlr;
1468 } 1470 }
1469 dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS, temp_word); 1471 dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), temp_word);
1470 1472
1471 /* Add this HPC instance into the HPC list */ 1473 /* Add this HPC instance into the HPC list */
1472 spin_lock(&list_lock); 1474 spin_lock(&list_lock);
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index f0c53f850aed..a70a5c5705f2 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -95,7 +95,7 @@ static struct hotplug_slot_ops shpchp_hotplug_slot_ops = {
95 */ 95 */
96static void release_slot(struct hotplug_slot *hotplug_slot) 96static void release_slot(struct hotplug_slot *hotplug_slot)
97{ 97{
98 struct slot *slot = (struct slot *)hotplug_slot->private; 98 struct slot *slot = hotplug_slot->private;
99 99
100 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 100 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
101 101
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 9f90eb8e6ecd..490a9553a062 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -1885,7 +1885,7 @@ int shpchp_enable_slot (struct slot *p_slot)
1885 func = shpchp_slot_find(p_slot->bus, p_slot->device, 0); 1885 func = shpchp_slot_find(p_slot->bus, p_slot->device, 0);
1886 if (!func) { 1886 if (!func) {
1887 dbg("%s: Error! slot NULL\n", __FUNCTION__); 1887 dbg("%s: Error! slot NULL\n", __FUNCTION__);
1888 return 1; 1888 return -ENODEV;
1889 } 1889 }
1890 1890
1891 /* Check to see if (latch closed, card present, power off) */ 1891 /* Check to see if (latch closed, card present, power off) */
@@ -1894,19 +1894,19 @@ int shpchp_enable_slot (struct slot *p_slot)
1894 if (rc || !getstatus) { 1894 if (rc || !getstatus) {
1895 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1895 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
1896 up(&p_slot->ctrl->crit_sect); 1896 up(&p_slot->ctrl->crit_sect);
1897 return 1; 1897 return -ENODEV;
1898 } 1898 }
1899 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1899 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1900 if (rc || getstatus) { 1900 if (rc || getstatus) {
1901 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1901 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
1902 up(&p_slot->ctrl->crit_sect); 1902 up(&p_slot->ctrl->crit_sect);
1903 return 1; 1903 return -ENODEV;
1904 } 1904 }
1905 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1905 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
1906 if (rc || getstatus) { 1906 if (rc || getstatus) {
1907 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); 1907 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
1908 up(&p_slot->ctrl->crit_sect); 1908 up(&p_slot->ctrl->crit_sect);
1909 return 1; 1909 return -ENODEV;
1910 } 1910 }
1911 up(&p_slot->ctrl->crit_sect); 1911 up(&p_slot->ctrl->crit_sect);
1912 1912
@@ -1914,7 +1914,7 @@ int shpchp_enable_slot (struct slot *p_slot)
1914 1914
1915 func = shpchp_slot_create(p_slot->bus); 1915 func = shpchp_slot_create(p_slot->bus);
1916 if (func == NULL) 1916 if (func == NULL)
1917 return 1; 1917 return -ENOMEM;
1918 1918
1919 func->bus = p_slot->bus; 1919 func->bus = p_slot->bus;
1920 func->device = p_slot->device; 1920 func->device = p_slot->device;
@@ -1939,7 +1939,7 @@ int shpchp_enable_slot (struct slot *p_slot)
1939 /* Setup slot structure with entry for empty slot */ 1939 /* Setup slot structure with entry for empty slot */
1940 func = shpchp_slot_create(p_slot->bus); 1940 func = shpchp_slot_create(p_slot->bus);
1941 if (func == NULL) 1941 if (func == NULL)
1942 return (1); /* Out of memory */ 1942 return -ENOMEM; /* Out of memory */
1943 1943
1944 func->bus = p_slot->bus; 1944 func->bus = p_slot->bus;
1945 func->device = p_slot->device; 1945 func->device = p_slot->device;
@@ -1972,7 +1972,7 @@ int shpchp_disable_slot (struct slot *p_slot)
1972 struct pci_func *func; 1972 struct pci_func *func;
1973 1973
1974 if (!p_slot->ctrl) 1974 if (!p_slot->ctrl)
1975 return 1; 1975 return -ENODEV;
1976 1976
1977 pci_bus = p_slot->ctrl->pci_dev->subordinate; 1977 pci_bus = p_slot->ctrl->pci_dev->subordinate;
1978 1978
@@ -1983,19 +1983,19 @@ int shpchp_disable_slot (struct slot *p_slot)
1983 if (ret || !getstatus) { 1983 if (ret || !getstatus) {
1984 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1984 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
1985 up(&p_slot->ctrl->crit_sect); 1985 up(&p_slot->ctrl->crit_sect);
1986 return 1; 1986 return -ENODEV;
1987 } 1987 }
1988 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1988 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1989 if (ret || getstatus) { 1989 if (ret || getstatus) {
1990 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1990 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
1991 up(&p_slot->ctrl->crit_sect); 1991 up(&p_slot->ctrl->crit_sect);
1992 return 1; 1992 return -ENODEV;
1993 } 1993 }
1994 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1994 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
1995 if (ret || !getstatus) { 1995 if (ret || !getstatus) {
1996 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); 1996 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
1997 up(&p_slot->ctrl->crit_sect); 1997 up(&p_slot->ctrl->crit_sect);
1998 return 1; 1998 return -ENODEV;
1999 } 1999 }
2000 up(&p_slot->ctrl->crit_sect); 2000 up(&p_slot->ctrl->crit_sect);
2001 2001
@@ -2011,7 +2011,7 @@ int shpchp_disable_slot (struct slot *p_slot)
2011 /* Check the Class Code */ 2011 /* Check the Class Code */
2012 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); 2012 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
2013 if (rc) 2013 if (rc)
2014 return rc; 2014 return -ENODEV;
2015 2015
2016 if (class_code == PCI_BASE_CLASS_DISPLAY) { 2016 if (class_code == PCI_BASE_CLASS_DISPLAY) {
2017 /* Display/Video adapter (not supported) */ 2017 /* Display/Video adapter (not supported) */
@@ -2020,13 +2020,13 @@ int shpchp_disable_slot (struct slot *p_slot)
2020 /* See if it's a bridge */ 2020 /* See if it's a bridge */
2021 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); 2021 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
2022 if (rc) 2022 if (rc)
2023 return rc; 2023 return -ENODEV;
2024 2024
2025 /* If it's a bridge, check the VGA Enable bit */ 2025 /* If it's a bridge, check the VGA Enable bit */
2026 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 2026 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
2027 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR); 2027 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR);
2028 if (rc) 2028 if (rc)
2029 return rc; 2029 return -ENODEV;
2030 2030
2031 /* If the VGA Enable bit is set, remove isn't supported */ 2031 /* If the VGA Enable bit is set, remove isn't supported */
2032 if (BCR & PCI_BRIDGE_CTL_VGA) { 2032 if (BCR & PCI_BRIDGE_CTL_VGA) {
@@ -2042,12 +2042,12 @@ int shpchp_disable_slot (struct slot *p_slot)
2042 if ((func != NULL) && !rc) { 2042 if ((func != NULL) && !rc) {
2043 rc = remove_board(func, p_slot->ctrl); 2043 rc = remove_board(func, p_slot->ctrl);
2044 } else if (!rc) 2044 } else if (!rc)
2045 rc = 1; 2045 rc = -ENODEV;
2046 2046
2047 if (p_slot) 2047 if (p_slot)
2048 update_slot_info(p_slot); 2048 update_slot_info(p_slot);
2049 2049
2050 return(rc); 2050 return rc;
2051} 2051}
2052 2052
2053 2053
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 8568b207f189..6ca0061137a6 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -73,6 +73,17 @@ resource_show(struct device * dev, char * buf)
73 return (str - buf); 73 return (str - buf);
74} 74}
75 75
76static ssize_t modalias_show(struct device *dev, char *buf)
77{
78 struct pci_dev *pci_dev = to_pci_dev(dev);
79
80 return sprintf(buf, "pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n",
81 pci_dev->vendor, pci_dev->device,
82 pci_dev->subsystem_vendor, pci_dev->subsystem_device,
83 (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
84 (u8)(pci_dev->class));
85}
86
76struct device_attribute pci_dev_attrs[] = { 87struct device_attribute pci_dev_attrs[] = {
77 __ATTR_RO(resource), 88 __ATTR_RO(resource),
78 __ATTR_RO(vendor), 89 __ATTR_RO(vendor),
@@ -82,6 +93,7 @@ struct device_attribute pci_dev_attrs[] = {
82 __ATTR_RO(class), 93 __ATTR_RO(class),
83 __ATTR_RO(irq), 94 __ATTR_RO(irq),
84 __ATTR_RO(local_cpus), 95 __ATTR_RO(local_cpus),
96 __ATTR_RO(modalias),
85 __ATTR_NULL, 97 __ATTR_NULL,
86}; 98};
87 99
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 79cdc16c52c8..744da0d4ae5f 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -32,33 +32,6 @@ extern unsigned char pci_max_busnr(void);
32extern unsigned char pci_bus_max_busnr(struct pci_bus *bus); 32extern unsigned char pci_bus_max_busnr(struct pci_bus *bus);
33extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); 33extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap);
34 34
35struct pci_dev_wrapped {
36 struct pci_dev *dev;
37 void *data;
38};
39
40struct pci_bus_wrapped {
41 struct pci_bus *bus;
42 void *data;
43};
44
45struct pci_visit {
46 int (* pre_visit_pci_bus) (struct pci_bus_wrapped *,
47 struct pci_dev_wrapped *);
48 int (* post_visit_pci_bus) (struct pci_bus_wrapped *,
49 struct pci_dev_wrapped *);
50
51 int (* pre_visit_pci_dev) (struct pci_dev_wrapped *,
52 struct pci_bus_wrapped *);
53 int (* visit_pci_dev) (struct pci_dev_wrapped *,
54 struct pci_bus_wrapped *);
55 int (* post_visit_pci_dev) (struct pci_dev_wrapped *,
56 struct pci_bus_wrapped *);
57};
58
59extern int pci_visit_dev(struct pci_visit *fn,
60 struct pci_dev_wrapped *wrapped_dev,
61 struct pci_bus_wrapped *wrapped_parent);
62extern void pci_remove_legacy_files(struct pci_bus *bus); 35extern void pci_remove_legacy_files(struct pci_bus *bus);
63 36
64/* Lock for read/write access to pci device and bus lists */ 37/* Lock for read/write access to pci device and bus lists */
diff --git a/drivers/pci/pcie/portdrv_bus.c b/drivers/pci/pcie/portdrv_bus.c
index 4037a3e568de..3e84b501e6a4 100644
--- a/drivers/pci/pcie/portdrv_bus.c
+++ b/drivers/pci/pcie/portdrv_bus.c
@@ -39,7 +39,8 @@ static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
39 driver->id_table->vendor != pciedev->id.vendor) || 39 driver->id_table->vendor != pciedev->id.vendor) ||
40 (driver->id_table->device != PCI_ANY_ID && 40 (driver->id_table->device != PCI_ANY_ID &&
41 driver->id_table->device != pciedev->id.device) || 41 driver->id_table->device != pciedev->id.device) ||
42 driver->id_table->port_type != pciedev->id.port_type || 42 (driver->id_table->port_type != PCIE_ANY_PORT &&
43 driver->id_table->port_type != pciedev->id.port_type) ||
43 driver->id_table->service_type != pciedev->id.service_type ) 44 driver->id_table->service_type != pciedev->id.service_type )
44 return 0; 45 return 0;
45 46
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 026aa04669a2..637e9493034b 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -18,6 +18,7 @@
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/acpi.h>
21#include "pci.h" 22#include "pci.h"
22 23
23/* Deal with broken BIOS'es that neglect to enable passive release, 24/* Deal with broken BIOS'es that neglect to enable passive release,
@@ -467,9 +468,6 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_APIC,
467 * non-x86 architectures (yes Via exists on PPC among other places), 468 * non-x86 architectures (yes Via exists on PPC among other places),
468 * we must mask the PCI_INTERRUPT_LINE value versus 0xf to get 469 * we must mask the PCI_INTERRUPT_LINE value versus 0xf to get
469 * interrupts delivered properly. 470 * interrupts delivered properly.
470 *
471 * TODO: When we have device-specific interrupt routers,
472 * quirk_via_irqpic will go away from quirks.
473 */ 471 */
474 472
475/* 473/*
@@ -494,6 +492,29 @@ static void __devinit quirk_via_acpi(struct pci_dev *d)
494DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_via_acpi ); 492DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_via_acpi );
495DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_acpi ); 493DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_acpi );
496 494
495static void quirk_via_irqpic(struct pci_dev *dev)
496{
497 u8 irq, new_irq;
498
499#ifdef CONFIG_X86_IO_APIC
500 if (nr_ioapics && !skip_ioapic_setup)
501 return;
502#endif
503#ifdef CONFIG_ACPI
504 if (acpi_irq_model != ACPI_IRQ_MODEL_PIC)
505 return;
506#endif
507 new_irq = dev->irq & 0xf;
508 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
509 if (new_irq != irq) {
510 printk(KERN_INFO "PCI: Via PIC IRQ fixup for %s, from %d to %d\n",
511 pci_name(dev), irq, new_irq);
512 udelay(15); /* unknown if delay really needed */
513 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq);
514 }
515}
516DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_irqpic);
517
497/* 518/*
498 * PIIX3 USB: We have to disable USB interrupts that are 519 * PIIX3 USB: We have to disable USB interrupts that are
499 * hardwired to PIRQD# and may be shared with an 520 * hardwired to PIRQD# and may be shared with an
@@ -683,19 +704,6 @@ static void __init quirk_disable_pxb(struct pci_dev *pdev)
683} 704}
684DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb ); 705DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb );
685 706
686/*
687 * VIA northbridges care about PCI_INTERRUPT_LINE
688 */
689int via_interrupt_line_quirk;
690
691static void __devinit quirk_via_bridge(struct pci_dev *pdev)
692{
693 if(pdev->devfn == 0) {
694 printk(KERN_INFO "PCI: Via IRQ fixup\n");
695 via_interrupt_line_quirk = 1;
696 }
697}
698DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_bridge );
699 707
700/* 708/*
701 * Serverworks CSB5 IDE does not fully support native mode 709 * Serverworks CSB5 IDE does not fully support native mode
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 66150d08b5c7..c4ade288c5da 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1592,9 +1592,9 @@ static int __init init_pcmcia_bus(void)
1592 1592
1593 /* Set up character device for user mode clients */ 1593 /* Set up character device for user mode clients */
1594 i = register_chrdev(0, "pcmcia", &ds_fops); 1594 i = register_chrdev(0, "pcmcia", &ds_fops);
1595 if (i == -EBUSY) 1595 if (i < 0)
1596 printk(KERN_NOTICE "unable to find a free device # for " 1596 printk(KERN_NOTICE "unable to find a free device # for "
1597 "Driver Services\n"); 1597 "Driver Services (error=%d)\n", i);
1598 else 1598 else
1599 major_dev = i; 1599 major_dev = i;
1600 1600
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 02cfe244e069..ceeb3cf64a16 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -7,7 +7,7 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.161 $ 10 * $Revision: 1.164 $
11 */ 11 */
12 12
13#include <linux/config.h> 13#include <linux/config.h>
@@ -1766,10 +1766,10 @@ dasd_generic_probe (struct ccw_device *cdev,
1766 printk(KERN_WARNING 1766 printk(KERN_WARNING
1767 "dasd_generic_probe: could not add sysfs entries " 1767 "dasd_generic_probe: could not add sysfs entries "
1768 "for %s\n", cdev->dev.bus_id); 1768 "for %s\n", cdev->dev.bus_id);
1769 } else {
1770 cdev->handler = &dasd_int_handler;
1769 } 1771 }
1770 1772
1771 cdev->handler = &dasd_int_handler;
1772
1773 return ret; 1773 return ret;
1774} 1774}
1775 1775
@@ -1780,6 +1780,8 @@ dasd_generic_remove (struct ccw_device *cdev)
1780{ 1780{
1781 struct dasd_device *device; 1781 struct dasd_device *device;
1782 1782
1783 cdev->handler = NULL;
1784
1783 dasd_remove_sysfs_files(cdev); 1785 dasd_remove_sysfs_files(cdev);
1784 device = dasd_device_from_cdev(cdev); 1786 device = dasd_device_from_cdev(cdev);
1785 if (IS_ERR(device)) 1787 if (IS_ERR(device))
@@ -1810,14 +1812,14 @@ dasd_generic_set_online (struct ccw_device *cdev,
1810 struct dasd_device *device; 1812 struct dasd_device *device;
1811 int feature_diag, rc; 1813 int feature_diag, rc;
1812 1814
1813 feature_diag = dasd_get_feature(cdev, DASD_FEATURE_USEDIAG);
1814 if (feature_diag < 0)
1815 return feature_diag;
1816
1817 device = dasd_create_device(cdev); 1815 device = dasd_create_device(cdev);
1818 if (IS_ERR(device)) 1816 if (IS_ERR(device))
1819 return PTR_ERR(device); 1817 return PTR_ERR(device);
1820 1818
1819 feature_diag = dasd_get_feature(cdev, DASD_FEATURE_USEDIAG);
1820 if (feature_diag < 0)
1821 return feature_diag;
1822
1821 if (feature_diag) { 1823 if (feature_diag) {
1822 if (!dasd_diag_discipline_pointer) { 1824 if (!dasd_diag_discipline_pointer) {
1823 printk (KERN_WARNING 1825 printk (KERN_WARNING
diff --git a/drivers/s390/net/Makefile b/drivers/s390/net/Makefile
index 7cabb80a2e41..90d4d0ef3dd4 100644
--- a/drivers/s390/net/Makefile
+++ b/drivers/s390/net/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_NETIUCV) += netiucv.o fsm.o
9obj-$(CONFIG_SMSGIUCV) += smsgiucv.o 9obj-$(CONFIG_SMSGIUCV) += smsgiucv.o
10obj-$(CONFIG_CTC) += ctc.o fsm.o cu3088.o 10obj-$(CONFIG_CTC) += ctc.o fsm.o cu3088.o
11obj-$(CONFIG_LCS) += lcs.o cu3088.o 11obj-$(CONFIG_LCS) += lcs.o cu3088.o
12qeth-y := qeth_main.o qeth_mpc.o qeth_sys.o qeth_eddp.o qeth_tso.o 12obj-$(CONFIG_CLAW) += claw.o cu3088.o
13qeth-y := qeth_main.o qeth_mpc.o qeth_sys.o qeth_eddp.o
13qeth-$(CONFIG_PROC_FS) += qeth_proc.o 14qeth-$(CONFIG_PROC_FS) += qeth_proc.o
14obj-$(CONFIG_QETH) += qeth.o 15obj-$(CONFIG_QETH) += qeth.o
diff --git a/drivers/s390/net/ctcdbug.h b/drivers/s390/net/ctcdbug.h
index ef8883951720..7fe2ebd1792d 100644
--- a/drivers/s390/net/ctcdbug.h
+++ b/drivers/s390/net/ctcdbug.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/ctcdbug.h ($Revision: 1.4 $) 3 * linux/drivers/s390/net/ctcdbug.h ($Revision: 1.5 $)
4 * 4 *
5 * CTC / ESCON network driver - s390 dbf exploit. 5 * CTC / ESCON network driver - s390 dbf exploit.
6 * 6 *
@@ -9,7 +9,7 @@
9 * Author(s): Original Code written by 9 * Author(s): Original Code written by
10 * Peter Tiedemann (ptiedem@de.ibm.com) 10 * Peter Tiedemann (ptiedem@de.ibm.com)
11 * 11 *
12 * $Revision: 1.4 $ $Date: 2004/10/15 09:26:58 $ 12 * $Revision: 1.5 $ $Date: 2005/02/27 19:46:44 $
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
@@ -25,9 +25,11 @@
25 * along with this program; if not, write to the Free Software 25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 */ 27 */
28 28#ifndef _CTCDBUG_H_
29#define _CTCDBUG_H_
29 30
30#include <asm/debug.h> 31#include <asm/debug.h>
32#include "ctcmain.h"
31/** 33/**
32 * Debug Facility stuff 34 * Debug Facility stuff
33 */ 35 */
@@ -41,7 +43,7 @@
41#define CTC_DBF_DATA_LEN 128 43#define CTC_DBF_DATA_LEN 128
42#define CTC_DBF_DATA_INDEX 3 44#define CTC_DBF_DATA_INDEX 3
43#define CTC_DBF_DATA_NR_AREAS 1 45#define CTC_DBF_DATA_NR_AREAS 1
44#define CTC_DBF_DATA_LEVEL 2 46#define CTC_DBF_DATA_LEVEL 3
45 47
46#define CTC_DBF_TRACE_NAME "ctc_trace" 48#define CTC_DBF_TRACE_NAME "ctc_trace"
47#define CTC_DBF_TRACE_LEN 16 49#define CTC_DBF_TRACE_LEN 16
@@ -121,3 +123,5 @@ hex_dump(unsigned char *buf, size_t len)
121 printk("\n"); 123 printk("\n");
122} 124}
123 125
126
127#endif
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
index 7266bf5ea659..ff3e95e07e89 100644
--- a/drivers/s390/net/ctcmain.c
+++ b/drivers/s390/net/ctcmain.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ctcmain.c,v 1.72 2005/03/17 10:51:52 ptiedem Exp $ 2 * $Id: ctcmain.c,v 1.74 2005/03/24 09:04:17 mschwide Exp $
3 * 3 *
4 * CTC / ESCON network driver 4 * CTC / ESCON network driver
5 * 5 *
@@ -37,12 +37,11 @@
37 * along with this program; if not, write to the Free Software 37 * along with this program; if not, write to the Free Software
38 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 38 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
39 * 39 *
40 * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.72 $ 40 * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.74 $
41 * 41 *
42 */ 42 */
43 43
44#undef DEBUG 44#undef DEBUG
45
46#include <linux/module.h> 45#include <linux/module.h>
47#include <linux/init.h> 46#include <linux/init.h>
48#include <linux/kernel.h> 47#include <linux/kernel.h>
@@ -74,288 +73,13 @@
74#include "ctctty.h" 73#include "ctctty.h"
75#include "fsm.h" 74#include "fsm.h"
76#include "cu3088.h" 75#include "cu3088.h"
76
77#include "ctcdbug.h" 77#include "ctcdbug.h"
78#include "ctcmain.h"
78 79
79MODULE_AUTHOR("(C) 2000 IBM Corp. by Fritz Elfert (felfert@millenux.com)"); 80MODULE_AUTHOR("(C) 2000 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
80MODULE_DESCRIPTION("Linux for S/390 CTC/Escon Driver"); 81MODULE_DESCRIPTION("Linux for S/390 CTC/Escon Driver");
81MODULE_LICENSE("GPL"); 82MODULE_LICENSE("GPL");
82
83/**
84 * CCW commands, used in this driver.
85 */
86#define CCW_CMD_WRITE 0x01
87#define CCW_CMD_READ 0x02
88#define CCW_CMD_SET_EXTENDED 0xc3
89#define CCW_CMD_PREPARE 0xe3
90
91#define CTC_PROTO_S390 0
92#define CTC_PROTO_LINUX 1
93#define CTC_PROTO_LINUX_TTY 2
94#define CTC_PROTO_OS390 3
95#define CTC_PROTO_MAX 3
96
97#define CTC_BUFSIZE_LIMIT 65535
98#define CTC_BUFSIZE_DEFAULT 32768
99
100#define CTC_TIMEOUT_5SEC 5000
101
102#define CTC_INITIAL_BLOCKLEN 2
103
104#define READ 0
105#define WRITE 1
106
107#define CTC_ID_SIZE BUS_ID_SIZE+3
108
109
110struct ctc_profile {
111 unsigned long maxmulti;
112 unsigned long maxcqueue;
113 unsigned long doios_single;
114 unsigned long doios_multi;
115 unsigned long txlen;
116 unsigned long tx_time;
117 struct timespec send_stamp;
118};
119
120/**
121 * Definition of one channel
122 */
123struct channel {
124
125 /**
126 * Pointer to next channel in list.
127 */
128 struct channel *next;
129 char id[CTC_ID_SIZE];
130 struct ccw_device *cdev;
131
132 /**
133 * Type of this channel.
134 * CTC/A or Escon for valid channels.
135 */
136 enum channel_types type;
137
138 /**
139 * Misc. flags. See CHANNEL_FLAGS_... below
140 */
141 __u32 flags;
142
143 /**
144 * The protocol of this channel
145 */
146 __u16 protocol;
147
148 /**
149 * I/O and irq related stuff
150 */
151 struct ccw1 *ccw;
152 struct irb *irb;
153
154 /**
155 * RX/TX buffer size
156 */
157 int max_bufsize;
158
159 /**
160 * Transmit/Receive buffer.
161 */
162 struct sk_buff *trans_skb;
163
164 /**
165 * Universal I/O queue.
166 */
167 struct sk_buff_head io_queue;
168
169 /**
170 * TX queue for collecting skb's during busy.
171 */
172 struct sk_buff_head collect_queue;
173
174 /**
175 * Amount of data in collect_queue.
176 */
177 int collect_len;
178
179 /**
180 * spinlock for collect_queue and collect_len
181 */
182 spinlock_t collect_lock;
183
184 /**
185 * Timer for detecting unresposive
186 * I/O operations.
187 */
188 fsm_timer timer;
189
190 /**
191 * Retry counter for misc. operations.
192 */
193 int retry;
194
195 /**
196 * The finite state machine of this channel
197 */
198 fsm_instance *fsm;
199
200 /**
201 * The corresponding net_device this channel
202 * belongs to.
203 */
204 struct net_device *netdev;
205
206 struct ctc_profile prof;
207
208 unsigned char *trans_skb_data;
209
210 __u16 logflags;
211};
212
213#define CHANNEL_FLAGS_READ 0
214#define CHANNEL_FLAGS_WRITE 1
215#define CHANNEL_FLAGS_INUSE 2
216#define CHANNEL_FLAGS_BUFSIZE_CHANGED 4
217#define CHANNEL_FLAGS_FAILED 8
218#define CHANNEL_FLAGS_WAITIRQ 16
219#define CHANNEL_FLAGS_RWMASK 1
220#define CHANNEL_DIRECTION(f) (f & CHANNEL_FLAGS_RWMASK)
221
222#define LOG_FLAG_ILLEGALPKT 1
223#define LOG_FLAG_ILLEGALSIZE 2
224#define LOG_FLAG_OVERRUN 4
225#define LOG_FLAG_NOMEM 8
226
227#define CTC_LOGLEVEL_INFO 1
228#define CTC_LOGLEVEL_NOTICE 2
229#define CTC_LOGLEVEL_WARN 4
230#define CTC_LOGLEVEL_EMERG 8
231#define CTC_LOGLEVEL_ERR 16
232#define CTC_LOGLEVEL_DEBUG 32
233#define CTC_LOGLEVEL_CRIT 64
234
235#define CTC_LOGLEVEL_DEFAULT \
236(CTC_LOGLEVEL_INFO | CTC_LOGLEVEL_NOTICE | CTC_LOGLEVEL_WARN | CTC_LOGLEVEL_CRIT)
237
238#define CTC_LOGLEVEL_MAX ((CTC_LOGLEVEL_CRIT<<1)-1)
239
240static int loglevel = CTC_LOGLEVEL_DEFAULT;
241
242#define ctc_pr_debug(fmt, arg...) \
243do { if (loglevel & CTC_LOGLEVEL_DEBUG) printk(KERN_DEBUG fmt,##arg); } while (0)
244
245#define ctc_pr_info(fmt, arg...) \
246do { if (loglevel & CTC_LOGLEVEL_INFO) printk(KERN_INFO fmt,##arg); } while (0)
247
248#define ctc_pr_notice(fmt, arg...) \
249do { if (loglevel & CTC_LOGLEVEL_NOTICE) printk(KERN_NOTICE fmt,##arg); } while (0)
250
251#define ctc_pr_warn(fmt, arg...) \
252do { if (loglevel & CTC_LOGLEVEL_WARN) printk(KERN_WARNING fmt,##arg); } while (0)
253
254#define ctc_pr_emerg(fmt, arg...) \
255do { if (loglevel & CTC_LOGLEVEL_EMERG) printk(KERN_EMERG fmt,##arg); } while (0)
256
257#define ctc_pr_err(fmt, arg...) \
258do { if (loglevel & CTC_LOGLEVEL_ERR) printk(KERN_ERR fmt,##arg); } while (0)
259
260#define ctc_pr_crit(fmt, arg...) \
261do { if (loglevel & CTC_LOGLEVEL_CRIT) printk(KERN_CRIT fmt,##arg); } while (0)
262
263/**
264 * Linked list of all detected channels.
265 */
266static struct channel *channels = NULL;
267
268struct ctc_priv {
269 struct net_device_stats stats;
270 unsigned long tbusy;
271 /**
272 * The finite state machine of this interface.
273 */
274 fsm_instance *fsm;
275 /**
276 * The protocol of this device
277 */
278 __u16 protocol;
279 /**
280 * Timer for restarting after I/O Errors
281 */
282 fsm_timer restart_timer;
283
284 int buffer_size;
285
286 struct channel *channel[2];
287};
288
289/**
290 * Definition of our link level header.
291 */
292struct ll_header {
293 __u16 length;
294 __u16 type;
295 __u16 unused;
296};
297#define LL_HEADER_LENGTH (sizeof(struct ll_header))
298
299/**
300 * Compatibility macros for busy handling
301 * of network devices.
302 */
303static __inline__ void
304ctc_clear_busy(struct net_device * dev)
305{
306 clear_bit(0, &(((struct ctc_priv *) dev->priv)->tbusy));
307 if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY)
308 netif_wake_queue(dev);
309}
310
311static __inline__ int
312ctc_test_and_set_busy(struct net_device * dev)
313{
314 if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY)
315 netif_stop_queue(dev);
316 return test_and_set_bit(0, &((struct ctc_priv *) dev->priv)->tbusy);
317}
318
319/**
320 * Print Banner.
321 */
322static void
323print_banner(void)
324{
325 static int printed = 0;
326 char vbuf[] = "$Revision: 1.72 $";
327 char *version = vbuf;
328
329 if (printed)
330 return;
331 if ((version = strchr(version, ':'))) {
332 char *p = strchr(version + 1, '$');
333 if (p)
334 *p = '\0';
335 } else
336 version = " ??? ";
337 printk(KERN_INFO "CTC driver Version%s"
338#ifdef DEBUG
339 " (DEBUG-VERSION, " __DATE__ __TIME__ ")"
340#endif
341 " initialized\n", version);
342 printed = 1;
343}
344
345/**
346 * Return type of a detected device.
347 */
348static enum channel_types
349get_channel_type(struct ccw_device_id *id)
350{
351 enum channel_types type = (enum channel_types) id->driver_info;
352
353 if (type == channel_type_ficon)
354 type = channel_type_escon;
355
356 return type;
357}
358
359/** 83/**
360 * States of the interface statemachine. 84 * States of the interface statemachine.
361 */ 85 */
@@ -371,7 +95,7 @@ enum dev_states {
371 /** 95 /**
372 * MUST be always the last element!! 96 * MUST be always the last element!!
373 */ 97 */
374 NR_DEV_STATES 98 CTC_NR_DEV_STATES
375}; 99};
376 100
377static const char *dev_state_names[] = { 101static const char *dev_state_names[] = {
@@ -399,7 +123,7 @@ enum dev_events {
399 /** 123 /**
400 * MUST be always the last element!! 124 * MUST be always the last element!!
401 */ 125 */
402 NR_DEV_EVENTS 126 CTC_NR_DEV_EVENTS
403}; 127};
404 128
405static const char *dev_event_names[] = { 129static const char *dev_event_names[] = {
@@ -476,40 +200,6 @@ enum ch_events {
476 NR_CH_EVENTS, 200 NR_CH_EVENTS,
477}; 201};
478 202
479static const char *ch_event_names[] = {
480 "ccw_device success",
481 "ccw_device busy",
482 "ccw_device enodev",
483 "ccw_device ioerr",
484 "ccw_device unknown",
485
486 "Status ATTN & BUSY",
487 "Status ATTN",
488 "Status BUSY",
489
490 "Unit check remote reset",
491 "Unit check remote system reset",
492 "Unit check TX timeout",
493 "Unit check TX parity",
494 "Unit check Hardware failure",
495 "Unit check RX parity",
496 "Unit check ZERO",
497 "Unit check Unknown",
498
499 "SubChannel check Unknown",
500
501 "Machine check failure",
502 "Machine check operational",
503
504 "IRQ normal",
505 "IRQ final",
506
507 "Timer",
508
509 "Start",
510 "Stop",
511};
512
513/** 203/**
514 * States of the channel statemachine. 204 * States of the channel statemachine.
515 */ 205 */
@@ -545,6 +235,87 @@ enum ch_states {
545 NR_CH_STATES, 235 NR_CH_STATES,
546}; 236};
547 237
238static int loglevel = CTC_LOGLEVEL_DEFAULT;
239
240/**
241 * Linked list of all detected channels.
242 */
243static struct channel *channels = NULL;
244
245/**
246 * Print Banner.
247 */
248static void
249print_banner(void)
250{
251 static int printed = 0;
252 char vbuf[] = "$Revision: 1.74 $";
253 char *version = vbuf;
254
255 if (printed)
256 return;
257 if ((version = strchr(version, ':'))) {
258 char *p = strchr(version + 1, '$');
259 if (p)
260 *p = '\0';
261 } else
262 version = " ??? ";
263 printk(KERN_INFO "CTC driver Version%s"
264#ifdef DEBUG
265 " (DEBUG-VERSION, " __DATE__ __TIME__ ")"
266#endif
267 " initialized\n", version);
268 printed = 1;
269}
270
271/**
272 * Return type of a detected device.
273 */
274static enum channel_types
275get_channel_type(struct ccw_device_id *id)
276{
277 enum channel_types type = (enum channel_types) id->driver_info;
278
279 if (type == channel_type_ficon)
280 type = channel_type_escon;
281
282 return type;
283}
284
285static const char *ch_event_names[] = {
286 "ccw_device success",
287 "ccw_device busy",
288 "ccw_device enodev",
289 "ccw_device ioerr",
290 "ccw_device unknown",
291
292 "Status ATTN & BUSY",
293 "Status ATTN",
294 "Status BUSY",
295
296 "Unit check remote reset",
297 "Unit check remote system reset",
298 "Unit check TX timeout",
299 "Unit check TX parity",
300 "Unit check Hardware failure",
301 "Unit check RX parity",
302 "Unit check ZERO",
303 "Unit check Unknown",
304
305 "SubChannel check Unknown",
306
307 "Machine check failure",
308 "Machine check operational",
309
310 "IRQ normal",
311 "IRQ final",
312
313 "Timer",
314
315 "Start",
316 "Stop",
317};
318
548static const char *ch_state_names[] = { 319static const char *ch_state_names[] = {
549 "Idle", 320 "Idle",
550 "Stopped", 321 "Stopped",
@@ -1934,7 +1705,6 @@ add_channel(struct ccw_device *cdev, enum channel_types type)
1934 ch->cdev = cdev; 1705 ch->cdev = cdev;
1935 snprintf(ch->id, CTC_ID_SIZE, "ch-%s", cdev->dev.bus_id); 1706 snprintf(ch->id, CTC_ID_SIZE, "ch-%s", cdev->dev.bus_id);
1936 ch->type = type; 1707 ch->type = type;
1937 loglevel = CTC_LOGLEVEL_DEFAULT;
1938 ch->fsm = init_fsm(ch->id, ch_state_names, 1708 ch->fsm = init_fsm(ch->id, ch_state_names,
1939 ch_event_names, NR_CH_STATES, NR_CH_EVENTS, 1709 ch_event_names, NR_CH_STATES, NR_CH_EVENTS,
1940 ch_fsm, CH_FSM_LEN, GFP_KERNEL); 1710 ch_fsm, CH_FSM_LEN, GFP_KERNEL);
@@ -2697,6 +2467,7 @@ ctc_stats(struct net_device * dev)
2697/* 2467/*
2698 * sysfs attributes 2468 * sysfs attributes
2699 */ 2469 */
2470
2700static ssize_t 2471static ssize_t
2701buffer_show(struct device *dev, char *buf) 2472buffer_show(struct device *dev, char *buf)
2702{ 2473{
@@ -2715,57 +2486,61 @@ buffer_write(struct device *dev, const char *buf, size_t count)
2715 struct ctc_priv *priv; 2486 struct ctc_priv *priv;
2716 struct net_device *ndev; 2487 struct net_device *ndev;
2717 int bs1; 2488 int bs1;
2489 char buffer[16];
2718 2490
2719 DBF_TEXT(trace, 3, __FUNCTION__); 2491 DBF_TEXT(trace, 3, __FUNCTION__);
2492 DBF_TEXT(trace, 3, buf);
2720 priv = dev->driver_data; 2493 priv = dev->driver_data;
2721 if (!priv) 2494 if (!priv) {
2495 DBF_TEXT(trace, 3, "bfnopriv");
2722 return -ENODEV; 2496 return -ENODEV;
2497 }
2498
2499 sscanf(buf, "%u", &bs1);
2500 if (bs1 > CTC_BUFSIZE_LIMIT)
2501 goto einval;
2502 if (bs1 < (576 + LL_HEADER_LENGTH + 2))
2503 goto einval;
2504 priv->buffer_size = bs1; // just to overwrite the default
2505
2723 ndev = priv->channel[READ]->netdev; 2506 ndev = priv->channel[READ]->netdev;
2724 if (!ndev) 2507 if (!ndev) {
2508 DBF_TEXT(trace, 3, "bfnondev");
2725 return -ENODEV; 2509 return -ENODEV;
2726 sscanf(buf, "%u", &bs1); 2510 }
2727 2511
2728 if (bs1 > CTC_BUFSIZE_LIMIT)
2729 return -EINVAL;
2730 if ((ndev->flags & IFF_RUNNING) && 2512 if ((ndev->flags & IFF_RUNNING) &&
2731 (bs1 < (ndev->mtu + LL_HEADER_LENGTH + 2))) 2513 (bs1 < (ndev->mtu + LL_HEADER_LENGTH + 2)))
2732 return -EINVAL; 2514 goto einval;
2733 if (bs1 < (576 + LL_HEADER_LENGTH + 2))
2734 return -EINVAL;
2735 2515
2736 priv->buffer_size = bs1; 2516 priv->channel[READ]->max_bufsize = bs1;
2737 priv->channel[READ]->max_bufsize = 2517 priv->channel[WRITE]->max_bufsize = bs1;
2738 priv->channel[WRITE]->max_bufsize = bs1;
2739 if (!(ndev->flags & IFF_RUNNING)) 2518 if (!(ndev->flags & IFF_RUNNING))
2740 ndev->mtu = bs1 - LL_HEADER_LENGTH - 2; 2519 ndev->mtu = bs1 - LL_HEADER_LENGTH - 2;
2741 priv->channel[READ]->flags |= CHANNEL_FLAGS_BUFSIZE_CHANGED; 2520 priv->channel[READ]->flags |= CHANNEL_FLAGS_BUFSIZE_CHANGED;
2742 priv->channel[WRITE]->flags |= CHANNEL_FLAGS_BUFSIZE_CHANGED; 2521 priv->channel[WRITE]->flags |= CHANNEL_FLAGS_BUFSIZE_CHANGED;
2743 2522
2523 sprintf(buffer, "%d",priv->buffer_size);
2524 DBF_TEXT(trace, 3, buffer);
2744 return count; 2525 return count;
2745 2526
2527einval:
2528 DBF_TEXT(trace, 3, "buff_err");
2529 return -EINVAL;
2746} 2530}
2747 2531
2748static ssize_t 2532static ssize_t
2749loglevel_show(struct device *dev, char *buf) 2533loglevel_show(struct device *dev, char *buf)
2750{ 2534{
2751 struct ctc_priv *priv;
2752
2753 priv = dev->driver_data;
2754 if (!priv)
2755 return -ENODEV;
2756 return sprintf(buf, "%d\n", loglevel); 2535 return sprintf(buf, "%d\n", loglevel);
2757} 2536}
2758 2537
2759static ssize_t 2538static ssize_t
2760loglevel_write(struct device *dev, const char *buf, size_t count) 2539loglevel_write(struct device *dev, const char *buf, size_t count)
2761{ 2540{
2762 struct ctc_priv *priv;
2763 int ll1; 2541 int ll1;
2764 2542
2765 DBF_TEXT(trace, 5, __FUNCTION__); 2543 DBF_TEXT(trace, 5, __FUNCTION__);
2766 priv = dev->driver_data;
2767 if (!priv)
2768 return -ENODEV;
2769 sscanf(buf, "%i", &ll1); 2544 sscanf(buf, "%i", &ll1);
2770 2545
2771 if ((ll1 > CTC_LOGLEVEL_MAX) || (ll1 < 0)) 2546 if ((ll1 > CTC_LOGLEVEL_MAX) || (ll1 < 0))
@@ -2835,27 +2610,6 @@ stats_write(struct device *dev, const char *buf, size_t count)
2835 return count; 2610 return count;
2836} 2611}
2837 2612
2838static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write);
2839static DEVICE_ATTR(loglevel, 0644, loglevel_show, loglevel_write);
2840static DEVICE_ATTR(stats, 0644, stats_show, stats_write);
2841
2842static int
2843ctc_add_attributes(struct device *dev)
2844{
2845// device_create_file(dev, &dev_attr_buffer);
2846 device_create_file(dev, &dev_attr_loglevel);
2847 device_create_file(dev, &dev_attr_stats);
2848 return 0;
2849}
2850
2851static void
2852ctc_remove_attributes(struct device *dev)
2853{
2854 device_remove_file(dev, &dev_attr_stats);
2855 device_remove_file(dev, &dev_attr_loglevel);
2856// device_remove_file(dev, &dev_attr_buffer);
2857}
2858
2859 2613
2860static void 2614static void
2861ctc_netdev_unregister(struct net_device * dev) 2615ctc_netdev_unregister(struct net_device * dev)
@@ -2899,52 +2653,6 @@ ctc_free_netdevice(struct net_device * dev, int free_dev)
2899#endif 2653#endif
2900} 2654}
2901 2655
2902/**
2903 * Initialize everything of the net device except the name and the
2904 * channel structs.
2905 */
2906static struct net_device *
2907ctc_init_netdevice(struct net_device * dev, int alloc_device,
2908 struct ctc_priv *privptr)
2909{
2910 if (!privptr)
2911 return NULL;
2912
2913 DBF_TEXT(setup, 3, __FUNCTION__);
2914 if (alloc_device) {
2915 dev = kmalloc(sizeof (struct net_device), GFP_KERNEL);
2916 if (!dev)
2917 return NULL;
2918 memset(dev, 0, sizeof (struct net_device));
2919 }
2920
2921 dev->priv = privptr;
2922 privptr->fsm = init_fsm("ctcdev", dev_state_names,
2923 dev_event_names, NR_DEV_STATES, NR_DEV_EVENTS,
2924 dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
2925 if (privptr->fsm == NULL) {
2926 if (alloc_device)
2927 kfree(dev);
2928 return NULL;
2929 }
2930 fsm_newstate(privptr->fsm, DEV_STATE_STOPPED);
2931 fsm_settimer(privptr->fsm, &privptr->restart_timer);
2932 if (dev->mtu == 0)
2933 dev->mtu = CTC_BUFSIZE_DEFAULT - LL_HEADER_LENGTH - 2;
2934 dev->hard_start_xmit = ctc_tx;
2935 dev->open = ctc_open;
2936 dev->stop = ctc_close;
2937 dev->get_stats = ctc_stats;
2938 dev->change_mtu = ctc_change_mtu;
2939 dev->hard_header_len = LL_HEADER_LENGTH + 2;
2940 dev->addr_len = 0;
2941 dev->type = ARPHRD_SLIP;
2942 dev->tx_queue_len = 100;
2943 dev->flags = IFF_POINTOPOINT | IFF_NOARP;
2944 SET_MODULE_OWNER(dev);
2945 return dev;
2946}
2947
2948static ssize_t 2656static ssize_t
2949ctc_proto_show(struct device *dev, char *buf) 2657ctc_proto_show(struct device *dev, char *buf)
2950{ 2658{
@@ -2977,7 +2685,6 @@ ctc_proto_store(struct device *dev, const char *buf, size_t count)
2977 return count; 2685 return count;
2978} 2686}
2979 2687
2980static DEVICE_ATTR(protocol, 0644, ctc_proto_show, ctc_proto_store);
2981 2688
2982static ssize_t 2689static ssize_t
2983ctc_type_show(struct device *dev, char *buf) 2690ctc_type_show(struct device *dev, char *buf)
@@ -2991,8 +2698,13 @@ ctc_type_show(struct device *dev, char *buf)
2991 return sprintf(buf, "%s\n", cu3088_type[cgdev->cdev[0]->id.driver_info]); 2698 return sprintf(buf, "%s\n", cu3088_type[cgdev->cdev[0]->id.driver_info]);
2992} 2699}
2993 2700
2701static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write);
2702static DEVICE_ATTR(protocol, 0644, ctc_proto_show, ctc_proto_store);
2994static DEVICE_ATTR(type, 0444, ctc_type_show, NULL); 2703static DEVICE_ATTR(type, 0444, ctc_type_show, NULL);
2995 2704
2705static DEVICE_ATTR(loglevel, 0644, loglevel_show, loglevel_write);
2706static DEVICE_ATTR(stats, 0644, stats_show, stats_write);
2707
2996static struct attribute *ctc_attr[] = { 2708static struct attribute *ctc_attr[] = {
2997 &dev_attr_protocol.attr, 2709 &dev_attr_protocol.attr,
2998 &dev_attr_type.attr, 2710 &dev_attr_type.attr,
@@ -3005,6 +2717,21 @@ static struct attribute_group ctc_attr_group = {
3005}; 2717};
3006 2718
3007static int 2719static int
2720ctc_add_attributes(struct device *dev)
2721{
2722 device_create_file(dev, &dev_attr_loglevel);
2723 device_create_file(dev, &dev_attr_stats);
2724 return 0;
2725}
2726
2727static void
2728ctc_remove_attributes(struct device *dev)
2729{
2730 device_remove_file(dev, &dev_attr_stats);
2731 device_remove_file(dev, &dev_attr_loglevel);
2732}
2733
2734static int
3008ctc_add_files(struct device *dev) 2735ctc_add_files(struct device *dev)
3009{ 2736{
3010 pr_debug("%s() called\n", __FUNCTION__); 2737 pr_debug("%s() called\n", __FUNCTION__);
@@ -3028,15 +2755,15 @@ ctc_remove_files(struct device *dev)
3028 * 2755 *
3029 * @returns 0 on success, !0 on failure. 2756 * @returns 0 on success, !0 on failure.
3030 */ 2757 */
3031
3032static int 2758static int
3033ctc_probe_device(struct ccwgroup_device *cgdev) 2759ctc_probe_device(struct ccwgroup_device *cgdev)
3034{ 2760{
3035 struct ctc_priv *priv; 2761 struct ctc_priv *priv;
3036 int rc; 2762 int rc;
2763 char buffer[16];
3037 2764
3038 pr_debug("%s() called\n", __FUNCTION__); 2765 pr_debug("%s() called\n", __FUNCTION__);
3039 DBF_TEXT(trace, 3, __FUNCTION__); 2766 DBF_TEXT(setup, 3, __FUNCTION__);
3040 2767
3041 if (!get_device(&cgdev->dev)) 2768 if (!get_device(&cgdev->dev))
3042 return -ENODEV; 2769 return -ENODEV;
@@ -3060,10 +2787,70 @@ ctc_probe_device(struct ccwgroup_device *cgdev)
3060 cgdev->cdev[1]->handler = ctc_irq_handler; 2787 cgdev->cdev[1]->handler = ctc_irq_handler;
3061 cgdev->dev.driver_data = priv; 2788 cgdev->dev.driver_data = priv;
3062 2789
2790 sprintf(buffer, "%p", priv);
2791 DBF_TEXT(data, 3, buffer);
2792
2793 sprintf(buffer, "%u", (unsigned int)sizeof(struct ctc_priv));
2794 DBF_TEXT(data, 3, buffer);
2795
2796 sprintf(buffer, "%p", &channels);
2797 DBF_TEXT(data, 3, buffer);
2798
2799 sprintf(buffer, "%u", (unsigned int)sizeof(struct channel));
2800 DBF_TEXT(data, 3, buffer);
2801
3063 return 0; 2802 return 0;
3064} 2803}
3065 2804
3066/** 2805/**
2806 * Initialize everything of the net device except the name and the
2807 * channel structs.
2808 */
2809static struct net_device *
2810ctc_init_netdevice(struct net_device * dev, int alloc_device,
2811 struct ctc_priv *privptr)
2812{
2813 if (!privptr)
2814 return NULL;
2815
2816 DBF_TEXT(setup, 3, __FUNCTION__);
2817
2818 if (alloc_device) {
2819 dev = kmalloc(sizeof (struct net_device), GFP_KERNEL);
2820 if (!dev)
2821 return NULL;
2822 memset(dev, 0, sizeof (struct net_device));
2823 }
2824
2825 dev->priv = privptr;
2826 privptr->fsm = init_fsm("ctcdev", dev_state_names,
2827 dev_event_names, CTC_NR_DEV_STATES, CTC_NR_DEV_EVENTS,
2828 dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
2829 if (privptr->fsm == NULL) {
2830 if (alloc_device)
2831 kfree(dev);
2832 return NULL;
2833 }
2834 fsm_newstate(privptr->fsm, DEV_STATE_STOPPED);
2835 fsm_settimer(privptr->fsm, &privptr->restart_timer);
2836 if (dev->mtu == 0)
2837 dev->mtu = CTC_BUFSIZE_DEFAULT - LL_HEADER_LENGTH - 2;
2838 dev->hard_start_xmit = ctc_tx;
2839 dev->open = ctc_open;
2840 dev->stop = ctc_close;
2841 dev->get_stats = ctc_stats;
2842 dev->change_mtu = ctc_change_mtu;
2843 dev->hard_header_len = LL_HEADER_LENGTH + 2;
2844 dev->addr_len = 0;
2845 dev->type = ARPHRD_SLIP;
2846 dev->tx_queue_len = 100;
2847 dev->flags = IFF_POINTOPOINT | IFF_NOARP;
2848 SET_MODULE_OWNER(dev);
2849 return dev;
2850}
2851
2852
2853/**
3067 * 2854 *
3068 * Setup an interface. 2855 * Setup an interface.
3069 * 2856 *
@@ -3081,6 +2868,7 @@ ctc_new_device(struct ccwgroup_device *cgdev)
3081 struct ctc_priv *privptr; 2868 struct ctc_priv *privptr;
3082 struct net_device *dev; 2869 struct net_device *dev;
3083 int ret; 2870 int ret;
2871 char buffer[16];
3084 2872
3085 pr_debug("%s() called\n", __FUNCTION__); 2873 pr_debug("%s() called\n", __FUNCTION__);
3086 DBF_TEXT(setup, 3, __FUNCTION__); 2874 DBF_TEXT(setup, 3, __FUNCTION__);
@@ -3089,6 +2877,9 @@ ctc_new_device(struct ccwgroup_device *cgdev)
3089 if (!privptr) 2877 if (!privptr)
3090 return -ENODEV; 2878 return -ENODEV;
3091 2879
2880 sprintf(buffer, "%d", privptr->buffer_size);
2881 DBF_TEXT(setup, 3, buffer);
2882
3092 type = get_channel_type(&cgdev->cdev[0]->id); 2883 type = get_channel_type(&cgdev->cdev[0]->id);
3093 2884
3094 snprintf(read_id, CTC_ID_SIZE, "ch-%s", cgdev->cdev[0]->dev.bus_id); 2885 snprintf(read_id, CTC_ID_SIZE, "ch-%s", cgdev->cdev[0]->dev.bus_id);
@@ -3177,9 +2968,10 @@ ctc_shutdown_device(struct ccwgroup_device *cgdev)
3177 struct ctc_priv *priv; 2968 struct ctc_priv *priv;
3178 struct net_device *ndev; 2969 struct net_device *ndev;
3179 2970
3180 DBF_TEXT(trace, 3, __FUNCTION__); 2971 DBF_TEXT(setup, 3, __FUNCTION__);
3181 pr_debug("%s() called\n", __FUNCTION__); 2972 pr_debug("%s() called\n", __FUNCTION__);
3182 2973
2974
3183 priv = cgdev->dev.driver_data; 2975 priv = cgdev->dev.driver_data;
3184 ndev = NULL; 2976 ndev = NULL;
3185 if (!priv) 2977 if (!priv)
@@ -3215,7 +3007,6 @@ ctc_shutdown_device(struct ccwgroup_device *cgdev)
3215 channel_remove(priv->channel[READ]); 3007 channel_remove(priv->channel[READ]);
3216 if (priv->channel[WRITE]) 3008 if (priv->channel[WRITE])
3217 channel_remove(priv->channel[WRITE]); 3009 channel_remove(priv->channel[WRITE]);
3218
3219 priv->channel[READ] = priv->channel[WRITE] = NULL; 3010 priv->channel[READ] = priv->channel[WRITE] = NULL;
3220 3011
3221 return 0; 3012 return 0;
@@ -3228,7 +3019,7 @@ ctc_remove_device(struct ccwgroup_device *cgdev)
3228 struct ctc_priv *priv; 3019 struct ctc_priv *priv;
3229 3020
3230 pr_debug("%s() called\n", __FUNCTION__); 3021 pr_debug("%s() called\n", __FUNCTION__);
3231 DBF_TEXT(trace, 3, __FUNCTION__); 3022 DBF_TEXT(setup, 3, __FUNCTION__);
3232 3023
3233 priv = cgdev->dev.driver_data; 3024 priv = cgdev->dev.driver_data;
3234 if (!priv) 3025 if (!priv)
@@ -3265,6 +3056,7 @@ static struct ccwgroup_driver ctc_group_driver = {
3265static void __exit 3056static void __exit
3266ctc_exit(void) 3057ctc_exit(void)
3267{ 3058{
3059 DBF_TEXT(setup, 3, __FUNCTION__);
3268 unregister_cu3088_discipline(&ctc_group_driver); 3060 unregister_cu3088_discipline(&ctc_group_driver);
3269 ctc_tty_cleanup(); 3061 ctc_tty_cleanup();
3270 ctc_unregister_dbf_views(); 3062 ctc_unregister_dbf_views();
@@ -3282,6 +3074,10 @@ ctc_init(void)
3282{ 3074{
3283 int ret = 0; 3075 int ret = 0;
3284 3076
3077 loglevel = CTC_LOGLEVEL_DEFAULT;
3078
3079 DBF_TEXT(setup, 3, __FUNCTION__);
3080
3285 print_banner(); 3081 print_banner();
3286 3082
3287 ret = ctc_register_dbf_views(); 3083 ret = ctc_register_dbf_views();
diff --git a/drivers/s390/net/ctcmain.h b/drivers/s390/net/ctcmain.h
new file mode 100644
index 000000000000..ba3605f16335
--- /dev/null
+++ b/drivers/s390/net/ctcmain.h
@@ -0,0 +1,276 @@
1/*
2 * $Id: ctcmain.h,v 1.4 2005/03/24 09:04:17 mschwide Exp $
3 *
4 * CTC / ESCON network driver
5 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
8 Peter Tiedemann (ptiedem@de.ibm.com)
9 *
10 *
11 * Documentation used:
12 * - Principles of Operation (IBM doc#: SA22-7201-06)
13 * - Common IO/-Device Commands and Self Description (IBM doc#: SA22-7204-02)
14 * - Common IO/-Device Commands and Self Description (IBM doc#: SN22-5535)
15 * - ESCON Channel-to-Channel Adapter (IBM doc#: SA22-7203-00)
16 * - ESCON I/O Interface (IBM doc#: SA22-7202-029
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2, or (at your option)
21 * any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 *
32 * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.4 $
33 *
34 */
35
36#ifndef _CTCMAIN_H_
37#define _CTCMAIN_H_
38
39#include <asm/ccwdev.h>
40#include <asm/ccwgroup.h>
41
42#include "ctctty.h"
43#include "fsm.h"
44#include "cu3088.h"
45
46
47/**
48 * CCW commands, used in this driver.
49 */
50#define CCW_CMD_WRITE 0x01
51#define CCW_CMD_READ 0x02
52#define CCW_CMD_SET_EXTENDED 0xc3
53#define CCW_CMD_PREPARE 0xe3
54
55#define CTC_PROTO_S390 0
56#define CTC_PROTO_LINUX 1
57#define CTC_PROTO_LINUX_TTY 2
58#define CTC_PROTO_OS390 3
59#define CTC_PROTO_MAX 3
60
61#define CTC_BUFSIZE_LIMIT 65535
62#define CTC_BUFSIZE_DEFAULT 32768
63
64#define CTC_TIMEOUT_5SEC 5000
65
66#define CTC_INITIAL_BLOCKLEN 2
67
68#define READ 0
69#define WRITE 1
70
71#define CTC_ID_SIZE BUS_ID_SIZE+3
72
73
74struct ctc_profile {
75 unsigned long maxmulti;
76 unsigned long maxcqueue;
77 unsigned long doios_single;
78 unsigned long doios_multi;
79 unsigned long txlen;
80 unsigned long tx_time;
81 struct timespec send_stamp;
82};
83
84/**
85 * Definition of one channel
86 */
87struct channel {
88
89 /**
90 * Pointer to next channel in list.
91 */
92 struct channel *next;
93 char id[CTC_ID_SIZE];
94 struct ccw_device *cdev;
95
96 /**
97 * Type of this channel.
98 * CTC/A or Escon for valid channels.
99 */
100 enum channel_types type;
101
102 /**
103 * Misc. flags. See CHANNEL_FLAGS_... below
104 */
105 __u32 flags;
106
107 /**
108 * The protocol of this channel
109 */
110 __u16 protocol;
111
112 /**
113 * I/O and irq related stuff
114 */
115 struct ccw1 *ccw;
116 struct irb *irb;
117
118 /**
119 * RX/TX buffer size
120 */
121 int max_bufsize;
122
123 /**
124 * Transmit/Receive buffer.
125 */
126 struct sk_buff *trans_skb;
127
128 /**
129 * Universal I/O queue.
130 */
131 struct sk_buff_head io_queue;
132
133 /**
134 * TX queue for collecting skb's during busy.
135 */
136 struct sk_buff_head collect_queue;
137
138 /**
139 * Amount of data in collect_queue.
140 */
141 int collect_len;
142
143 /**
144 * spinlock for collect_queue and collect_len
145 */
146 spinlock_t collect_lock;
147
148 /**
149 * Timer for detecting unresposive
150 * I/O operations.
151 */
152 fsm_timer timer;
153
154 /**
155 * Retry counter for misc. operations.
156 */
157 int retry;
158
159 /**
160 * The finite state machine of this channel
161 */
162 fsm_instance *fsm;
163
164 /**
165 * The corresponding net_device this channel
166 * belongs to.
167 */
168 struct net_device *netdev;
169
170 struct ctc_profile prof;
171
172 unsigned char *trans_skb_data;
173
174 __u16 logflags;
175};
176
177#define CHANNEL_FLAGS_READ 0
178#define CHANNEL_FLAGS_WRITE 1
179#define CHANNEL_FLAGS_INUSE 2
180#define CHANNEL_FLAGS_BUFSIZE_CHANGED 4
181#define CHANNEL_FLAGS_FAILED 8
182#define CHANNEL_FLAGS_WAITIRQ 16
183#define CHANNEL_FLAGS_RWMASK 1
184#define CHANNEL_DIRECTION(f) (f & CHANNEL_FLAGS_RWMASK)
185
186#define LOG_FLAG_ILLEGALPKT 1
187#define LOG_FLAG_ILLEGALSIZE 2
188#define LOG_FLAG_OVERRUN 4
189#define LOG_FLAG_NOMEM 8
190
191#define CTC_LOGLEVEL_INFO 1
192#define CTC_LOGLEVEL_NOTICE 2
193#define CTC_LOGLEVEL_WARN 4
194#define CTC_LOGLEVEL_EMERG 8
195#define CTC_LOGLEVEL_ERR 16
196#define CTC_LOGLEVEL_DEBUG 32
197#define CTC_LOGLEVEL_CRIT 64
198
199#define CTC_LOGLEVEL_DEFAULT \
200(CTC_LOGLEVEL_INFO | CTC_LOGLEVEL_NOTICE | CTC_LOGLEVEL_WARN | CTC_LOGLEVEL_CRIT)
201
202#define CTC_LOGLEVEL_MAX ((CTC_LOGLEVEL_CRIT<<1)-1)
203
204#define ctc_pr_debug(fmt, arg...) \
205do { if (loglevel & CTC_LOGLEVEL_DEBUG) printk(KERN_DEBUG fmt,##arg); } while (0)
206
207#define ctc_pr_info(fmt, arg...) \
208do { if (loglevel & CTC_LOGLEVEL_INFO) printk(KERN_INFO fmt,##arg); } while (0)
209
210#define ctc_pr_notice(fmt, arg...) \
211do { if (loglevel & CTC_LOGLEVEL_NOTICE) printk(KERN_NOTICE fmt,##arg); } while (0)
212
213#define ctc_pr_warn(fmt, arg...) \
214do { if (loglevel & CTC_LOGLEVEL_WARN) printk(KERN_WARNING fmt,##arg); } while (0)
215
216#define ctc_pr_emerg(fmt, arg...) \
217do { if (loglevel & CTC_LOGLEVEL_EMERG) printk(KERN_EMERG fmt,##arg); } while (0)
218
219#define ctc_pr_err(fmt, arg...) \
220do { if (loglevel & CTC_LOGLEVEL_ERR) printk(KERN_ERR fmt,##arg); } while (0)
221
222#define ctc_pr_crit(fmt, arg...) \
223do { if (loglevel & CTC_LOGLEVEL_CRIT) printk(KERN_CRIT fmt,##arg); } while (0)
224
225struct ctc_priv {
226 struct net_device_stats stats;
227 unsigned long tbusy;
228 /**
229 * The finite state machine of this interface.
230 */
231 fsm_instance *fsm;
232 /**
233 * The protocol of this device
234 */
235 __u16 protocol;
236 /**
237 * Timer for restarting after I/O Errors
238 */
239 fsm_timer restart_timer;
240
241 int buffer_size;
242
243 struct channel *channel[2];
244};
245
246/**
247 * Definition of our link level header.
248 */
249struct ll_header {
250 __u16 length;
251 __u16 type;
252 __u16 unused;
253};
254#define LL_HEADER_LENGTH (sizeof(struct ll_header))
255
256/**
257 * Compatibility macros for busy handling
258 * of network devices.
259 */
260static __inline__ void
261ctc_clear_busy(struct net_device * dev)
262{
263 clear_bit(0, &(((struct ctc_priv *) dev->priv)->tbusy));
264 if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY)
265 netif_wake_queue(dev);
266}
267
268static __inline__ int
269ctc_test_and_set_busy(struct net_device * dev)
270{
271 if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY)
272 netif_stop_queue(dev);
273 return test_and_set_bit(0, &((struct ctc_priv *) dev->priv)->tbusy);
274}
275
276#endif
diff --git a/drivers/s390/net/ctctty.c b/drivers/s390/net/ctctty.c
index 9257d60c7833..3080393e823d 100644
--- a/drivers/s390/net/ctctty.c
+++ b/drivers/s390/net/ctctty.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ctctty.c,v 1.26 2004/08/04 11:06:55 mschwide Exp $ 2 * $Id: ctctty.c,v 1.29 2005/04/05 08:50:44 mschwide Exp $
3 * 3 *
4 * CTC / ESCON network driver, tty interface. 4 * CTC / ESCON network driver, tty interface.
5 * 5 *
@@ -1056,8 +1056,7 @@ ctc_tty_close(struct tty_struct *tty, struct file *filp)
1056 info->tty = 0; 1056 info->tty = 0;
1057 tty->closing = 0; 1057 tty->closing = 0;
1058 if (info->blocked_open) { 1058 if (info->blocked_open) {
1059 set_current_state(TASK_INTERRUPTIBLE); 1059 msleep_interruptible(500);
1060 schedule_timeout(HZ/2);
1061 wake_up_interruptible(&info->open_wait); 1060 wake_up_interruptible(&info->open_wait);
1062 } 1061 }
1063 info->flags &= ~(CTC_ASYNC_NORMAL_ACTIVE | CTC_ASYNC_CLOSING); 1062 info->flags &= ~(CTC_ASYNC_NORMAL_ACTIVE | CTC_ASYNC_CLOSING);
diff --git a/drivers/s390/net/cu3088.c b/drivers/s390/net/cu3088.c
index 1b0a9f16024c..0075894c71db 100644
--- a/drivers/s390/net/cu3088.c
+++ b/drivers/s390/net/cu3088.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cu3088.c,v 1.34 2004/06/15 13:16:27 pavlic Exp $ 2 * $Id: cu3088.c,v 1.35 2005/03/30 19:28:52 richtera Exp $
3 * 3 *
4 * CTC / LCS ccw_device driver 4 * CTC / LCS ccw_device driver
5 * 5 *
@@ -39,6 +39,7 @@ const char *cu3088_type[] = {
39 "FICON channel", 39 "FICON channel",
40 "P390 LCS card", 40 "P390 LCS card",
41 "OSA LCS card", 41 "OSA LCS card",
42 "CLAW channel device",
42 "unknown channel type", 43 "unknown channel type",
43 "unsupported channel type", 44 "unsupported channel type",
44}; 45};
@@ -51,6 +52,7 @@ static struct ccw_device_id cu3088_ids[] = {
51 { CCW_DEVICE(0x3088, 0x1e), .driver_info = channel_type_ficon }, 52 { CCW_DEVICE(0x3088, 0x1e), .driver_info = channel_type_ficon },
52 { CCW_DEVICE(0x3088, 0x01), .driver_info = channel_type_p390 }, 53 { CCW_DEVICE(0x3088, 0x01), .driver_info = channel_type_p390 },
53 { CCW_DEVICE(0x3088, 0x60), .driver_info = channel_type_osa2 }, 54 { CCW_DEVICE(0x3088, 0x60), .driver_info = channel_type_osa2 },
55 { CCW_DEVICE(0x3088, 0x61), .driver_info = channel_type_claw },
54 { /* end of list */ } 56 { /* end of list */ }
55}; 57};
56 58
diff --git a/drivers/s390/net/cu3088.h b/drivers/s390/net/cu3088.h
index 0ec49a8b3adc..1753661f702a 100644
--- a/drivers/s390/net/cu3088.h
+++ b/drivers/s390/net/cu3088.h
@@ -23,6 +23,9 @@ enum channel_types {
23 /* Device is a OSA2 card */ 23 /* Device is a OSA2 card */
24 channel_type_osa2, 24 channel_type_osa2,
25 25
26 /* Device is a CLAW channel device */
27 channel_type_claw,
28
26 /* Device is a channel, but we don't know 29 /* Device is a channel, but we don't know
27 * anything about it */ 30 * anything about it */
28 channel_type_unknown, 31 channel_type_unknown,
diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c
index 1ac6563ee3e0..e08e74e16124 100644
--- a/drivers/s390/net/iucv.c
+++ b/drivers/s390/net/iucv.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: iucv.c,v 1.43 2005/02/09 14:47:43 braunu Exp $ 2 * $Id: iucv.c,v 1.45 2005/04/26 22:59:06 braunu Exp $
3 * 3 *
4 * IUCV network driver 4 * IUCV network driver
5 * 5 *
@@ -29,7 +29,7 @@
29 * along with this program; if not, write to the Free Software 29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 * 31 *
32 * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.43 $ 32 * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.45 $
33 * 33 *
34 */ 34 */
35 35
@@ -355,7 +355,7 @@ do { \
355static void 355static void
356iucv_banner(void) 356iucv_banner(void)
357{ 357{
358 char vbuf[] = "$Revision: 1.43 $"; 358 char vbuf[] = "$Revision: 1.45 $";
359 char *version = vbuf; 359 char *version = vbuf;
360 360
361 if ((version = strchr(version, ':'))) { 361 if ((version = strchr(version, ':'))) {
@@ -2553,12 +2553,12 @@ EXPORT_SYMBOL (iucv_resume);
2553#endif 2553#endif
2554EXPORT_SYMBOL (iucv_reply_prmmsg); 2554EXPORT_SYMBOL (iucv_reply_prmmsg);
2555EXPORT_SYMBOL (iucv_send); 2555EXPORT_SYMBOL (iucv_send);
2556#if 0
2557EXPORT_SYMBOL (iucv_send2way); 2556EXPORT_SYMBOL (iucv_send2way);
2558EXPORT_SYMBOL (iucv_send2way_array); 2557EXPORT_SYMBOL (iucv_send2way_array);
2559EXPORT_SYMBOL (iucv_send_array);
2560EXPORT_SYMBOL (iucv_send2way_prmmsg); 2558EXPORT_SYMBOL (iucv_send2way_prmmsg);
2561EXPORT_SYMBOL (iucv_send2way_prmmsg_array); 2559EXPORT_SYMBOL (iucv_send2way_prmmsg_array);
2560#if 0
2561EXPORT_SYMBOL (iucv_send_array);
2562EXPORT_SYMBOL (iucv_send_prmmsg); 2562EXPORT_SYMBOL (iucv_send_prmmsg);
2563EXPORT_SYMBOL (iucv_setmask); 2563EXPORT_SYMBOL (iucv_setmask);
2564#endif 2564#endif
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 0f76e945b984..cccfed248e70 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -11,7 +11,7 @@
11 * Frank Pavlic (pavlic@de.ibm.com) and 11 * Frank Pavlic (pavlic@de.ibm.com) and
12 * Martin Schwidefsky <schwidefsky@de.ibm.com> 12 * Martin Schwidefsky <schwidefsky@de.ibm.com>
13 * 13 *
14 * $Revision: 1.96 $ $Date: 2004/11/11 13:42:33 $ 14 * $Revision: 1.98 $ $Date: 2005/04/18 13:41:29 $
15 * 15 *
16 * This program is free software; you can redistribute it and/or modify 16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by 17 * it under the terms of the GNU General Public License as published by
@@ -59,7 +59,7 @@
59/** 59/**
60 * initialization string for output 60 * initialization string for output
61 */ 61 */
62#define VERSION_LCS_C "$Revision: 1.96 $" 62#define VERSION_LCS_C "$Revision: 1.98 $"
63 63
64static char version[] __initdata = "LCS driver ("VERSION_LCS_C "/" VERSION_LCS_H ")"; 64static char version[] __initdata = "LCS driver ("VERSION_LCS_C "/" VERSION_LCS_H ")";
65static char debug_buffer[255]; 65static char debug_buffer[255];
@@ -1098,14 +1098,6 @@ lcs_check_multicast_support(struct lcs_card *card)
1098 PRINT_ERR("Query IPAssist failed. Assuming unsupported!\n"); 1098 PRINT_ERR("Query IPAssist failed. Assuming unsupported!\n");
1099 return -EOPNOTSUPP; 1099 return -EOPNOTSUPP;
1100 } 1100 }
1101 /* Print out supported assists: IPv6 */
1102 PRINT_INFO("LCS device %s %s IPv6 support\n", card->dev->name,
1103 (card->ip_assists_supported & LCS_IPASS_IPV6_SUPPORT) ?
1104 "with" : "without");
1105 /* Print out supported assist: Multicast */
1106 PRINT_INFO("LCS device %s %s Multicast support\n", card->dev->name,
1107 (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) ?
1108 "with" : "without");
1109 if (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) 1101 if (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT)
1110 return 0; 1102 return 0;
1111 return -EOPNOTSUPP; 1103 return -EOPNOTSUPP;
@@ -1160,7 +1152,7 @@ list_modified:
1160 } 1152 }
1161 } 1153 }
1162 /* re-insert all entries from the failed_list into ipm_list */ 1154 /* re-insert all entries from the failed_list into ipm_list */
1163 list_for_each_entry(ipm, &failed_list, list) { 1155 list_for_each_entry_safe(ipm, tmp, &failed_list, list) {
1164 list_del_init(&ipm->list); 1156 list_del_init(&ipm->list);
1165 list_add_tail(&ipm->list, &card->ipm_list); 1157 list_add_tail(&ipm->list, &card->ipm_list);
1166 } 1158 }
@@ -2198,30 +2190,39 @@ lcs_new_device(struct ccwgroup_device *ccwgdev)
2198 if (!dev) 2190 if (!dev)
2199 goto out; 2191 goto out;
2200 card->dev = dev; 2192 card->dev = dev;
2201netdev_out:
2202 card->dev->priv = card; 2193 card->dev->priv = card;
2203 card->dev->open = lcs_open_device; 2194 card->dev->open = lcs_open_device;
2204 card->dev->stop = lcs_stop_device; 2195 card->dev->stop = lcs_stop_device;
2205 card->dev->hard_start_xmit = lcs_start_xmit; 2196 card->dev->hard_start_xmit = lcs_start_xmit;
2206 card->dev->get_stats = lcs_getstats; 2197 card->dev->get_stats = lcs_getstats;
2207 SET_MODULE_OWNER(dev); 2198 SET_MODULE_OWNER(dev);
2208 if (lcs_register_netdev(ccwgdev) != 0)
2209 goto out;
2210 memcpy(card->dev->dev_addr, card->mac, LCS_MAC_LENGTH); 2199 memcpy(card->dev->dev_addr, card->mac, LCS_MAC_LENGTH);
2211#ifdef CONFIG_IP_MULTICAST 2200#ifdef CONFIG_IP_MULTICAST
2212 if (!lcs_check_multicast_support(card)) 2201 if (!lcs_check_multicast_support(card))
2213 card->dev->set_multicast_list = lcs_set_multicast_list; 2202 card->dev->set_multicast_list = lcs_set_multicast_list;
2214#endif 2203#endif
2215 netif_stop_queue(card->dev); 2204netdev_out:
2216 lcs_set_allowed_threads(card,0xffffffff); 2205 lcs_set_allowed_threads(card,0xffffffff);
2217 if (recover_state == DEV_STATE_RECOVER) { 2206 if (recover_state == DEV_STATE_RECOVER) {
2218 lcs_set_multicast_list(card->dev); 2207 lcs_set_multicast_list(card->dev);
2219 card->dev->flags |= IFF_UP; 2208 card->dev->flags |= IFF_UP;
2220 netif_wake_queue(card->dev); 2209 netif_wake_queue(card->dev);
2221 card->state = DEV_STATE_UP; 2210 card->state = DEV_STATE_UP;
2222 } else 2211 } else {
2223 lcs_stopcard(card); 2212 lcs_stopcard(card);
2213 }
2224 2214
2215 if (lcs_register_netdev(ccwgdev) != 0)
2216 goto out;
2217
2218 /* Print out supported assists: IPv6 */
2219 PRINT_INFO("LCS device %s %s IPv6 support\n", card->dev->name,
2220 (card->ip_assists_supported & LCS_IPASS_IPV6_SUPPORT) ?
2221 "with" : "without");
2222 /* Print out supported assist: Multicast */
2223 PRINT_INFO("LCS device %s %s Multicast support\n", card->dev->name,
2224 (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) ?
2225 "with" : "without");
2225 return 0; 2226 return 0;
2226out: 2227out:
2227 2228
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h
index a341041a6cf7..a755b57db46b 100644
--- a/drivers/s390/net/qeth.h
+++ b/drivers/s390/net/qeth.h
@@ -24,7 +24,7 @@
24 24
25#include "qeth_mpc.h" 25#include "qeth_mpc.h"
26 26
27#define VERSION_QETH_H "$Revision: 1.135 $" 27#define VERSION_QETH_H "$Revision: 1.139 $"
28 28
29#ifdef CONFIG_QETH_IPV6 29#ifdef CONFIG_QETH_IPV6
30#define QETH_VERSION_IPV6 ":IPv6" 30#define QETH_VERSION_IPV6 ":IPv6"
@@ -288,7 +288,8 @@ qeth_is_ipa_enabled(struct qeth_ipa_info *ipa, enum qeth_ipa_funcs func)
288#define QETH_TX_TIMEOUT 100 * HZ 288#define QETH_TX_TIMEOUT 100 * HZ
289#define QETH_HEADER_SIZE 32 289#define QETH_HEADER_SIZE 32
290#define MAX_PORTNO 15 290#define MAX_PORTNO 15
291#define QETH_FAKE_LL_LEN ETH_HLEN 291#define QETH_FAKE_LL_LEN_ETH ETH_HLEN
292#define QETH_FAKE_LL_LEN_TR (sizeof(struct trh_hdr)-TR_MAXRIFLEN+sizeof(struct trllc))
292#define QETH_FAKE_LL_V6_ADDR_POS 24 293#define QETH_FAKE_LL_V6_ADDR_POS 24
293 294
294/*IPv6 address autoconfiguration stuff*/ 295/*IPv6 address autoconfiguration stuff*/
@@ -369,6 +370,25 @@ struct qeth_hdr {
369 } hdr; 370 } hdr;
370} __attribute__ ((packed)); 371} __attribute__ ((packed));
371 372
373/*TCP Segmentation Offload header*/
374struct qeth_hdr_ext_tso {
375 __u16 hdr_tot_len;
376 __u8 imb_hdr_no;
377 __u8 reserved;
378 __u8 hdr_type;
379 __u8 hdr_version;
380 __u16 hdr_len;
381 __u32 payload_len;
382 __u16 mss;
383 __u16 dg_hdr_len;
384 __u8 padding[16];
385} __attribute__ ((packed));
386
387struct qeth_hdr_tso {
388 struct qeth_hdr hdr; /*hdr->hdr.l3.xxx*/
389 struct qeth_hdr_ext_tso ext;
390} __attribute__ ((packed));
391
372 392
373/* flags for qeth_hdr.flags */ 393/* flags for qeth_hdr.flags */
374#define QETH_HDR_PASSTHRU 0x10 394#define QETH_HDR_PASSTHRU 0x10
@@ -866,6 +886,7 @@ qeth_push_skb(struct qeth_card *card, struct sk_buff **skb, int size)
866 return hdr; 886 return hdr;
867} 887}
868 888
889
869inline static int 890inline static int
870qeth_get_hlen(__u8 link_type) 891qeth_get_hlen(__u8 link_type)
871{ 892{
@@ -873,19 +894,19 @@ qeth_get_hlen(__u8 link_type)
873 switch (link_type) { 894 switch (link_type) {
874 case QETH_LINK_TYPE_HSTR: 895 case QETH_LINK_TYPE_HSTR:
875 case QETH_LINK_TYPE_LANE_TR: 896 case QETH_LINK_TYPE_LANE_TR:
876 return sizeof(struct qeth_hdr) + TR_HLEN; 897 return sizeof(struct qeth_hdr_tso) + TR_HLEN;
877 default: 898 default:
878#ifdef CONFIG_QETH_VLAN 899#ifdef CONFIG_QETH_VLAN
879 return sizeof(struct qeth_hdr) + VLAN_ETH_HLEN; 900 return sizeof(struct qeth_hdr_tso) + VLAN_ETH_HLEN;
880#else 901#else
881 return sizeof(struct qeth_hdr) + ETH_HLEN; 902 return sizeof(struct qeth_hdr_tso) + ETH_HLEN;
882#endif 903#endif
883 } 904 }
884#else /* CONFIG_QETH_IPV6 */ 905#else /* CONFIG_QETH_IPV6 */
885#ifdef CONFIG_QETH_VLAN 906#ifdef CONFIG_QETH_VLAN
886 return sizeof(struct qeth_hdr) + VLAN_HLEN; 907 return sizeof(struct qeth_hdr_tso) + VLAN_HLEN;
887#else 908#else
888 return sizeof(struct qeth_hdr); 909 return sizeof(struct qeth_hdr_tso);
889#endif 910#endif
890#endif /* CONFIG_QETH_IPV6 */ 911#endif /* CONFIG_QETH_IPV6 */
891} 912}
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
index 7ee1c06ed68a..f94f1f25eec6 100644
--- a/drivers/s390/net/qeth_eddp.c
+++ b/drivers/s390/net/qeth_eddp.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/qeth_eddp.c ($Revision: 1.11 $) 3 * linux/drivers/s390/net/qeth_eddp.c ($Revision: 1.13 $)
4 * 4 *
5 * Enhanced Device Driver Packing (EDDP) support for the qeth driver. 5 * Enhanced Device Driver Packing (EDDP) support for the qeth driver.
6 * 6 *
@@ -8,7 +8,7 @@
8 * 8 *
9 * Author(s): Thomas Spatzier <tspat@de.ibm.com> 9 * Author(s): Thomas Spatzier <tspat@de.ibm.com>
10 * 10 *
11 * $Revision: 1.11 $ $Date: 2005/03/24 09:04:18 $ 11 * $Revision: 1.13 $ $Date: 2005/05/04 20:19:18 $
12 * 12 *
13 */ 13 */
14#include <linux/config.h> 14#include <linux/config.h>
@@ -85,7 +85,7 @@ void
85qeth_eddp_buf_release_contexts(struct qeth_qdio_out_buffer *buf) 85qeth_eddp_buf_release_contexts(struct qeth_qdio_out_buffer *buf)
86{ 86{
87 struct qeth_eddp_context_reference *ref; 87 struct qeth_eddp_context_reference *ref;
88 88
89 QETH_DBF_TEXT(trace, 6, "eddprctx"); 89 QETH_DBF_TEXT(trace, 6, "eddprctx");
90 while (!list_empty(&buf->ctx_list)){ 90 while (!list_empty(&buf->ctx_list)){
91 ref = list_entry(buf->ctx_list.next, 91 ref = list_entry(buf->ctx_list.next,
@@ -139,7 +139,7 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
139 "buffer!\n"); 139 "buffer!\n");
140 goto out; 140 goto out;
141 } 141 }
142 } 142 }
143 /* check if the whole next skb fits into current buffer */ 143 /* check if the whole next skb fits into current buffer */
144 if ((QETH_MAX_BUFFER_ELEMENTS(queue->card) - 144 if ((QETH_MAX_BUFFER_ELEMENTS(queue->card) -
145 buf->next_element_to_fill) 145 buf->next_element_to_fill)
@@ -152,7 +152,7 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
152 * and increment ctx's refcnt */ 152 * and increment ctx's refcnt */
153 must_refcnt = 1; 153 must_refcnt = 1;
154 continue; 154 continue;
155 } 155 }
156 if (must_refcnt){ 156 if (must_refcnt){
157 must_refcnt = 0; 157 must_refcnt = 0;
158 if (qeth_eddp_buf_ref_context(buf, ctx)){ 158 if (qeth_eddp_buf_ref_context(buf, ctx)){
@@ -202,40 +202,29 @@ out:
202 return flush_cnt; 202 return flush_cnt;
203} 203}
204 204
205static inline int
206qeth_get_skb_data_len(struct sk_buff *skb)
207{
208 int len = skb->len;
209 int i;
210
211 for (i = 0; i < skb_shinfo(skb)->nr_frags; ++i)
212 len -= skb_shinfo(skb)->frags[i].size;
213 return len;
214}
215
216static inline void 205static inline void
217qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx, 206qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx,
218 struct qeth_eddp_data *eddp) 207 struct qeth_eddp_data *eddp, int data_len)
219{ 208{
220 u8 *page; 209 u8 *page;
221 int page_remainder; 210 int page_remainder;
222 int page_offset; 211 int page_offset;
223 int hdr_len; 212 int pkt_len;
224 struct qeth_eddp_element *element; 213 struct qeth_eddp_element *element;
225 214
226 QETH_DBF_TEXT(trace, 5, "eddpcrsh"); 215 QETH_DBF_TEXT(trace, 5, "eddpcrsh");
227 page = ctx->pages[ctx->offset >> PAGE_SHIFT]; 216 page = ctx->pages[ctx->offset >> PAGE_SHIFT];
228 page_offset = ctx->offset % PAGE_SIZE; 217 page_offset = ctx->offset % PAGE_SIZE;
229 element = &ctx->elements[ctx->num_elements]; 218 element = &ctx->elements[ctx->num_elements];
230 hdr_len = eddp->nhl + eddp->thl; 219 pkt_len = eddp->nhl + eddp->thl + data_len;
231 /* FIXME: layer2 and VLAN !!! */ 220 /* FIXME: layer2 and VLAN !!! */
232 if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2) 221 if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2)
233 hdr_len += ETH_HLEN; 222 pkt_len += ETH_HLEN;
234 if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) 223 if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q))
235 hdr_len += VLAN_HLEN; 224 pkt_len += VLAN_HLEN;
236 /* does complete header fit in current page ? */ 225 /* does complete packet fit in current page ? */
237 page_remainder = PAGE_SIZE - page_offset; 226 page_remainder = PAGE_SIZE - page_offset;
238 if (page_remainder < (sizeof(struct qeth_hdr) + hdr_len)){ 227 if (page_remainder < (sizeof(struct qeth_hdr) + pkt_len)){
239 /* no -> go to start of next page */ 228 /* no -> go to start of next page */
240 ctx->offset += page_remainder; 229 ctx->offset += page_remainder;
241 page = ctx->pages[ctx->offset >> PAGE_SHIFT]; 230 page = ctx->pages[ctx->offset >> PAGE_SHIFT];
@@ -281,7 +270,7 @@ qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
281 int left_in_frag; 270 int left_in_frag;
282 int copy_len; 271 int copy_len;
283 u8 *src; 272 u8 *src;
284 273
285 QETH_DBF_TEXT(trace, 5, "eddpcdtc"); 274 QETH_DBF_TEXT(trace, 5, "eddpcdtc");
286 if (skb_shinfo(eddp->skb)->nr_frags == 0) { 275 if (skb_shinfo(eddp->skb)->nr_frags == 0) {
287 memcpy(dst, eddp->skb->data + eddp->skb_offset, len); 276 memcpy(dst, eddp->skb->data + eddp->skb_offset, len);
@@ -292,7 +281,7 @@ qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
292 while (len > 0) { 281 while (len > 0) {
293 if (eddp->frag < 0) { 282 if (eddp->frag < 0) {
294 /* we're in skb->data */ 283 /* we're in skb->data */
295 left_in_frag = qeth_get_skb_data_len(eddp->skb) 284 left_in_frag = (eddp->skb->len - eddp->skb->data_len)
296 - eddp->skb_offset; 285 - eddp->skb_offset;
297 src = eddp->skb->data + eddp->skb_offset; 286 src = eddp->skb->data + eddp->skb_offset;
298 } else { 287 } else {
@@ -424,7 +413,7 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
424 struct tcphdr *tcph; 413 struct tcphdr *tcph;
425 int data_len; 414 int data_len;
426 u32 hcsum; 415 u32 hcsum;
427 416
428 QETH_DBF_TEXT(trace, 5, "eddpftcp"); 417 QETH_DBF_TEXT(trace, 5, "eddpftcp");
429 eddp->skb_offset = sizeof(struct qeth_hdr) + eddp->nhl + eddp->thl; 418 eddp->skb_offset = sizeof(struct qeth_hdr) + eddp->nhl + eddp->thl;
430 tcph = eddp->skb->h.th; 419 tcph = eddp->skb->h.th;
@@ -464,7 +453,7 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
464 else 453 else
465 hcsum = qeth_eddp_check_tcp6_hdr(eddp, data_len); 454 hcsum = qeth_eddp_check_tcp6_hdr(eddp, data_len);
466 /* fill the next segment into the context */ 455 /* fill the next segment into the context */
467 qeth_eddp_create_segment_hdrs(ctx, eddp); 456 qeth_eddp_create_segment_hdrs(ctx, eddp, data_len);
468 qeth_eddp_create_segment_data_tcp(ctx, eddp, data_len, hcsum); 457 qeth_eddp_create_segment_data_tcp(ctx, eddp, data_len, hcsum);
469 if (eddp->skb_offset >= eddp->skb->len) 458 if (eddp->skb_offset >= eddp->skb->len)
470 break; 459 break;
@@ -474,13 +463,13 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
474 eddp->th.tcp.h.seq += data_len; 463 eddp->th.tcp.h.seq += data_len;
475 } 464 }
476} 465}
477 466
478static inline int 467static inline int
479qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx, 468qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
480 struct sk_buff *skb, struct qeth_hdr *qhdr) 469 struct sk_buff *skb, struct qeth_hdr *qhdr)
481{ 470{
482 struct qeth_eddp_data *eddp = NULL; 471 struct qeth_eddp_data *eddp = NULL;
483 472
484 QETH_DBF_TEXT(trace, 5, "eddpficx"); 473 QETH_DBF_TEXT(trace, 5, "eddpficx");
485 /* create our segmentation headers and copy original headers */ 474 /* create our segmentation headers and copy original headers */
486 if (skb->protocol == ETH_P_IP) 475 if (skb->protocol == ETH_P_IP)
@@ -520,7 +509,7 @@ qeth_eddp_calc_num_pages(struct qeth_eddp_context *ctx, struct sk_buff *skb,
520 int hdr_len) 509 int hdr_len)
521{ 510{
522 int skbs_per_page; 511 int skbs_per_page;
523 512
524 QETH_DBF_TEXT(trace, 5, "eddpcanp"); 513 QETH_DBF_TEXT(trace, 5, "eddpcanp");
525 /* can we put multiple skbs in one page? */ 514 /* can we put multiple skbs in one page? */
526 skbs_per_page = PAGE_SIZE / (skb_shinfo(skb)->tso_size + hdr_len); 515 skbs_per_page = PAGE_SIZE / (skb_shinfo(skb)->tso_size + hdr_len);
@@ -600,7 +589,7 @@ qeth_eddp_create_context_tcp(struct qeth_card *card, struct sk_buff *skb,
600 struct qeth_hdr *qhdr) 589 struct qeth_hdr *qhdr)
601{ 590{
602 struct qeth_eddp_context *ctx = NULL; 591 struct qeth_eddp_context *ctx = NULL;
603 592
604 QETH_DBF_TEXT(trace, 5, "creddpct"); 593 QETH_DBF_TEXT(trace, 5, "creddpct");
605 if (skb->protocol == ETH_P_IP) 594 if (skb->protocol == ETH_P_IP)
606 ctx = qeth_eddp_create_context_generic(card, skb, 595 ctx = qeth_eddp_create_context_generic(card, skb,
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 607b92542df6..208127a5033a 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/qeth_main.c ($Revision: 1.206 $) 3 * linux/drivers/s390/net/qeth_main.c ($Revision: 1.214 $)
4 * 4 *
5 * Linux on zSeries OSA Express and HiperSockets support 5 * Linux on zSeries OSA Express and HiperSockets support
6 * 6 *
@@ -12,7 +12,7 @@
12 * Frank Pavlic (pavlic@de.ibm.com) and 12 * Frank Pavlic (pavlic@de.ibm.com) and
13 * Thomas Spatzier <tspat@de.ibm.com> 13 * Thomas Spatzier <tspat@de.ibm.com>
14 * 14 *
15 * $Revision: 1.206 $ $Date: 2005/03/24 09:04:18 $ 15 * $Revision: 1.214 $ $Date: 2005/05/04 20:19:18 $
16 * 16 *
17 * This program is free software; you can redistribute it and/or modify 17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by 18 * it under the terms of the GNU General Public License as published by
@@ -80,7 +80,7 @@ qeth_eyecatcher(void)
80#include "qeth_eddp.h" 80#include "qeth_eddp.h"
81#include "qeth_tso.h" 81#include "qeth_tso.h"
82 82
83#define VERSION_QETH_C "$Revision: 1.206 $" 83#define VERSION_QETH_C "$Revision: 1.214 $"
84static const char *version = "qeth S/390 OSA-Express driver"; 84static const char *version = "qeth S/390 OSA-Express driver";
85 85
86/** 86/**
@@ -158,6 +158,9 @@ qeth_irq_tasklet(unsigned long);
158static int 158static int
159qeth_set_online(struct ccwgroup_device *); 159qeth_set_online(struct ccwgroup_device *);
160 160
161static int
162__qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode);
163
161static struct qeth_ipaddr * 164static struct qeth_ipaddr *
162qeth_get_addr_buffer(enum qeth_prot_versions); 165qeth_get_addr_buffer(enum qeth_prot_versions);
163 166
@@ -510,10 +513,10 @@ qeth_irq_tasklet(unsigned long data)
510 wake_up(&card->wait_q); 513 wake_up(&card->wait_q);
511} 514}
512 515
513static int qeth_stop_card(struct qeth_card *); 516static int qeth_stop_card(struct qeth_card *, int);
514 517
515static int 518static int
516qeth_set_offline(struct ccwgroup_device *cgdev) 519__qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode)
517{ 520{
518 struct qeth_card *card = (struct qeth_card *) cgdev->dev.driver_data; 521 struct qeth_card *card = (struct qeth_card *) cgdev->dev.driver_data;
519 int rc = 0; 522 int rc = 0;
@@ -523,7 +526,7 @@ qeth_set_offline(struct ccwgroup_device *cgdev)
523 QETH_DBF_HEX(setup, 3, &card, sizeof(void *)); 526 QETH_DBF_HEX(setup, 3, &card, sizeof(void *));
524 527
525 recover_flag = card->state; 528 recover_flag = card->state;
526 if (qeth_stop_card(card) == -ERESTARTSYS){ 529 if (qeth_stop_card(card, recovery_mode) == -ERESTARTSYS){
527 PRINT_WARN("Stopping card %s interrupted by user!\n", 530 PRINT_WARN("Stopping card %s interrupted by user!\n",
528 CARD_BUS_ID(card)); 531 CARD_BUS_ID(card));
529 return -ERESTARTSYS; 532 return -ERESTARTSYS;
@@ -540,6 +543,12 @@ qeth_set_offline(struct ccwgroup_device *cgdev)
540} 543}
541 544
542static int 545static int
546qeth_set_offline(struct ccwgroup_device *cgdev)
547{
548 return __qeth_set_offline(cgdev, 0);
549}
550
551static int
543qeth_wait_for_threads(struct qeth_card *card, unsigned long threads); 552qeth_wait_for_threads(struct qeth_card *card, unsigned long threads);
544 553
545 554
@@ -953,8 +962,8 @@ qeth_recover(void *ptr)
953 PRINT_WARN("Recovery of device %s started ...\n", 962 PRINT_WARN("Recovery of device %s started ...\n",
954 CARD_BUS_ID(card)); 963 CARD_BUS_ID(card));
955 card->use_hard_stop = 1; 964 card->use_hard_stop = 1;
956 qeth_set_offline(card->gdev); 965 __qeth_set_offline(card->gdev,1);
957 rc = qeth_set_online(card->gdev); 966 rc = __qeth_set_online(card->gdev,1);
958 if (!rc) 967 if (!rc)
959 PRINT_INFO("Device %s successfully recovered!\n", 968 PRINT_INFO("Device %s successfully recovered!\n",
960 CARD_BUS_ID(card)); 969 CARD_BUS_ID(card));
@@ -2152,9 +2161,15 @@ qeth_get_next_skb(struct qeth_card *card, struct qdio_buffer *buffer,
2152 if (!skb_len) 2161 if (!skb_len)
2153 return NULL; 2162 return NULL;
2154 if (card->options.fake_ll){ 2163 if (card->options.fake_ll){
2155 if (!(skb = qeth_get_skb(skb_len + QETH_FAKE_LL_LEN))) 2164 if(card->dev->type == ARPHRD_IEEE802_TR){
2156 goto no_mem; 2165 if (!(skb = qeth_get_skb(skb_len+QETH_FAKE_LL_LEN_TR)))
2157 skb_pull(skb, QETH_FAKE_LL_LEN); 2166 goto no_mem;
2167 skb_reserve(skb,QETH_FAKE_LL_LEN_TR);
2168 } else {
2169 if (!(skb = qeth_get_skb(skb_len+QETH_FAKE_LL_LEN_ETH)))
2170 goto no_mem;
2171 skb_reserve(skb,QETH_FAKE_LL_LEN_ETH);
2172 }
2158 } else if (!(skb = qeth_get_skb(skb_len))) 2173 } else if (!(skb = qeth_get_skb(skb_len)))
2159 goto no_mem; 2174 goto no_mem;
2160 data_ptr = element->addr + offset; 2175 data_ptr = element->addr + offset;
@@ -2229,14 +2244,68 @@ qeth_type_trans(struct sk_buff *skb, struct net_device *dev)
2229} 2244}
2230 2245
2231static inline void 2246static inline void
2232qeth_rebuild_skb_fake_ll(struct qeth_card *card, struct sk_buff *skb, 2247qeth_rebuild_skb_fake_ll_tr(struct qeth_card *card, struct sk_buff *skb,
2248 struct qeth_hdr *hdr)
2249{
2250 struct trh_hdr *fake_hdr;
2251 struct trllc *fake_llc;
2252 struct iphdr *ip_hdr;
2253
2254 QETH_DBF_TEXT(trace,5,"skbfktr");
2255 skb->mac.raw = skb->data - QETH_FAKE_LL_LEN_TR;
2256 /* this is a fake ethernet header */
2257 fake_hdr = (struct trh_hdr *) skb->mac.raw;
2258
2259 /* the destination MAC address */
2260 switch (skb->pkt_type){
2261 case PACKET_MULTICAST:
2262 switch (skb->protocol){
2263#ifdef CONFIG_QETH_IPV6
2264 case __constant_htons(ETH_P_IPV6):
2265 ndisc_mc_map((struct in6_addr *)
2266 skb->data + QETH_FAKE_LL_V6_ADDR_POS,
2267 fake_hdr->daddr, card->dev, 0);
2268 break;
2269#endif /* CONFIG_QETH_IPV6 */
2270 case __constant_htons(ETH_P_IP):
2271 ip_hdr = (struct iphdr *)skb->data;
2272 ip_tr_mc_map(ip_hdr->daddr, fake_hdr->daddr);
2273 break;
2274 default:
2275 memcpy(fake_hdr->daddr, card->dev->dev_addr, TR_ALEN);
2276 }
2277 break;
2278 case PACKET_BROADCAST:
2279 memset(fake_hdr->daddr, 0xff, TR_ALEN);
2280 break;
2281 default:
2282 memcpy(fake_hdr->daddr, card->dev->dev_addr, TR_ALEN);
2283 }
2284 /* the source MAC address */
2285 if (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR)
2286 memcpy(fake_hdr->saddr, &hdr->hdr.l3.dest_addr[2], TR_ALEN);
2287 else
2288 memset(fake_hdr->saddr, 0, TR_ALEN);
2289 fake_hdr->rcf=0;
2290 fake_llc = (struct trllc*)&(fake_hdr->rcf);
2291 fake_llc->dsap = EXTENDED_SAP;
2292 fake_llc->ssap = EXTENDED_SAP;
2293 fake_llc->llc = UI_CMD;
2294 fake_llc->protid[0] = 0;
2295 fake_llc->protid[1] = 0;
2296 fake_llc->protid[2] = 0;
2297 fake_llc->ethertype = ETH_P_IP;
2298}
2299
2300static inline void
2301qeth_rebuild_skb_fake_ll_eth(struct qeth_card *card, struct sk_buff *skb,
2233 struct qeth_hdr *hdr) 2302 struct qeth_hdr *hdr)
2234{ 2303{
2235 struct ethhdr *fake_hdr; 2304 struct ethhdr *fake_hdr;
2236 struct iphdr *ip_hdr; 2305 struct iphdr *ip_hdr;
2237 2306
2238 QETH_DBF_TEXT(trace,5,"skbfake"); 2307 QETH_DBF_TEXT(trace,5,"skbfketh");
2239 skb->mac.raw = skb->data - QETH_FAKE_LL_LEN; 2308 skb->mac.raw = skb->data - QETH_FAKE_LL_LEN_ETH;
2240 /* this is a fake ethernet header */ 2309 /* this is a fake ethernet header */
2241 fake_hdr = (struct ethhdr *) skb->mac.raw; 2310 fake_hdr = (struct ethhdr *) skb->mac.raw;
2242 2311
@@ -2253,10 +2322,7 @@ qeth_rebuild_skb_fake_ll(struct qeth_card *card, struct sk_buff *skb,
2253#endif /* CONFIG_QETH_IPV6 */ 2322#endif /* CONFIG_QETH_IPV6 */
2254 case __constant_htons(ETH_P_IP): 2323 case __constant_htons(ETH_P_IP):
2255 ip_hdr = (struct iphdr *)skb->data; 2324 ip_hdr = (struct iphdr *)skb->data;
2256 if (card->dev->type == ARPHRD_IEEE802_TR) 2325 ip_eth_mc_map(ip_hdr->daddr, fake_hdr->h_dest);
2257 ip_tr_mc_map(ip_hdr->daddr, fake_hdr->h_dest);
2258 else
2259 ip_eth_mc_map(ip_hdr->daddr, fake_hdr->h_dest);
2260 break; 2326 break;
2261 default: 2327 default:
2262 memcpy(fake_hdr->h_dest, card->dev->dev_addr, ETH_ALEN); 2328 memcpy(fake_hdr->h_dest, card->dev->dev_addr, ETH_ALEN);
@@ -2278,6 +2344,16 @@ qeth_rebuild_skb_fake_ll(struct qeth_card *card, struct sk_buff *skb,
2278} 2344}
2279 2345
2280static inline void 2346static inline void
2347qeth_rebuild_skb_fake_ll(struct qeth_card *card, struct sk_buff *skb,
2348 struct qeth_hdr *hdr)
2349{
2350 if (card->dev->type == ARPHRD_IEEE802_TR)
2351 qeth_rebuild_skb_fake_ll_tr(card, skb, hdr);
2352 else
2353 qeth_rebuild_skb_fake_ll_eth(card, skb, hdr);
2354}
2355
2356static inline void
2281qeth_rebuild_skb_vlan(struct qeth_card *card, struct sk_buff *skb, 2357qeth_rebuild_skb_vlan(struct qeth_card *card, struct sk_buff *skb,
2282 struct qeth_hdr *hdr) 2358 struct qeth_hdr *hdr)
2283{ 2359{
@@ -3440,16 +3516,25 @@ qeth_fake_header(struct sk_buff *skb, struct net_device *dev,
3440 unsigned short type, void *daddr, void *saddr, 3516 unsigned short type, void *daddr, void *saddr,
3441 unsigned len) 3517 unsigned len)
3442{ 3518{
3443 struct ethhdr *hdr; 3519 if(dev->type == ARPHRD_IEEE802_TR){
3520 struct trh_hdr *hdr;
3521 hdr = (struct trh_hdr *)skb_push(skb, QETH_FAKE_LL_LEN_TR);
3522 memcpy(hdr->saddr, dev->dev_addr, TR_ALEN);
3523 memcpy(hdr->daddr, "FAKELL", TR_ALEN);
3524 return QETH_FAKE_LL_LEN_TR;
3525
3526 } else {
3527 struct ethhdr *hdr;
3528 hdr = (struct ethhdr *)skb_push(skb, QETH_FAKE_LL_LEN_ETH);
3529 memcpy(hdr->h_source, dev->dev_addr, ETH_ALEN);
3530 memcpy(hdr->h_dest, "FAKELL", ETH_ALEN);
3531 if (type != ETH_P_802_3)
3532 hdr->h_proto = htons(type);
3533 else
3534 hdr->h_proto = htons(len);
3535 return QETH_FAKE_LL_LEN_ETH;
3444 3536
3445 hdr = (struct ethhdr *)skb_push(skb, QETH_FAKE_LL_LEN); 3537 }
3446 memcpy(hdr->h_source, dev->dev_addr, ETH_ALEN);
3447 memcpy(hdr->h_dest, "FAKELL", ETH_ALEN);
3448 if (type != ETH_P_802_3)
3449 hdr->h_proto = htons(type);
3450 else
3451 hdr->h_proto = htons(len);
3452 return QETH_FAKE_LL_LEN;
3453} 3538}
3454 3539
3455static inline int 3540static inline int
@@ -3710,16 +3795,12 @@ static inline int
3710qeth_prepare_skb(struct qeth_card *card, struct sk_buff **skb, 3795qeth_prepare_skb(struct qeth_card *card, struct sk_buff **skb,
3711 struct qeth_hdr **hdr, int ipv) 3796 struct qeth_hdr **hdr, int ipv)
3712{ 3797{
3713 int rc = 0;
3714#ifdef CONFIG_QETH_VLAN 3798#ifdef CONFIG_QETH_VLAN
3715 u16 *tag; 3799 u16 *tag;
3716#endif 3800#endif
3717 3801
3718 QETH_DBF_TEXT(trace, 6, "prepskb"); 3802 QETH_DBF_TEXT(trace, 6, "prepskb");
3719 3803
3720 rc = qeth_realloc_headroom(card, skb, sizeof(struct qeth_hdr));
3721 if (rc)
3722 return rc;
3723#ifdef CONFIG_QETH_VLAN 3804#ifdef CONFIG_QETH_VLAN
3724 if (card->vlangrp && vlan_tx_tag_present(*skb) && 3805 if (card->vlangrp && vlan_tx_tag_present(*skb) &&
3725 ((ipv == 6) || card->options.layer2) ) { 3806 ((ipv == 6) || card->options.layer2) ) {
@@ -3882,9 +3963,15 @@ qeth_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
3882 memcpy(hdr->hdr.l3.dest_addr, &skb->nh.ipv6h->daddr, 16); 3963 memcpy(hdr->hdr.l3.dest_addr, &skb->nh.ipv6h->daddr, 16);
3883 } 3964 }
3884 } else { /* passthrough */ 3965 } else { /* passthrough */
3885 if (!memcmp(skb->data + sizeof(struct qeth_hdr), 3966 if((skb->dev->type == ARPHRD_IEEE802_TR) &&
3967 !memcmp(skb->data + sizeof(struct qeth_hdr) +
3968 sizeof(__u16), skb->dev->broadcast, 6)) {
3969 hdr->hdr.l3.flags = QETH_CAST_BROADCAST |
3970 QETH_HDR_PASSTHRU;
3971 } else if (!memcmp(skb->data + sizeof(struct qeth_hdr),
3886 skb->dev->broadcast, 6)) { /* broadcast? */ 3972 skb->dev->broadcast, 6)) { /* broadcast? */
3887 hdr->hdr.l3.flags = QETH_CAST_BROADCAST | QETH_HDR_PASSTHRU; 3973 hdr->hdr.l3.flags = QETH_CAST_BROADCAST |
3974 QETH_HDR_PASSTHRU;
3888 } else { 3975 } else {
3889 hdr->hdr.l3.flags = (cast_type == RTN_MULTICAST) ? 3976 hdr->hdr.l3.flags = (cast_type == RTN_MULTICAST) ?
3890 QETH_CAST_MULTICAST | QETH_HDR_PASSTHRU : 3977 QETH_CAST_MULTICAST | QETH_HDR_PASSTHRU :
@@ -3894,67 +3981,29 @@ qeth_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
3894} 3981}
3895 3982
3896static inline void 3983static inline void
3897__qeth_fill_buffer_frag(struct sk_buff *skb, struct qdio_buffer *buffer,
3898 int *next_element_to_fill)
3899{
3900 int length = skb->len;
3901 struct skb_frag_struct *frag;
3902 int fragno;
3903 unsigned long addr;
3904 int element;
3905 int first_lap = 1;
3906
3907 fragno = skb_shinfo(skb)->nr_frags; /* start with last frag */
3908 element = *next_element_to_fill + fragno;
3909 while (length > 0) {
3910 if (fragno > 0) {
3911 frag = &skb_shinfo(skb)->frags[fragno - 1];
3912 addr = (page_to_pfn(frag->page) << PAGE_SHIFT) +
3913 frag->page_offset;
3914 buffer->element[element].addr = (char *)addr;
3915 buffer->element[element].length = frag->size;
3916 length -= frag->size;
3917 if (first_lap)
3918 buffer->element[element].flags =
3919 SBAL_FLAGS_LAST_FRAG;
3920 else
3921 buffer->element[element].flags =
3922 SBAL_FLAGS_MIDDLE_FRAG;
3923 } else {
3924 buffer->element[element].addr = skb->data;
3925 buffer->element[element].length = length;
3926 length = 0;
3927 buffer->element[element].flags =
3928 SBAL_FLAGS_FIRST_FRAG;
3929 }
3930 element--;
3931 fragno--;
3932 first_lap = 0;
3933 }
3934 *next_element_to_fill += skb_shinfo(skb)->nr_frags + 1;
3935}
3936
3937static inline void
3938__qeth_fill_buffer(struct sk_buff *skb, struct qdio_buffer *buffer, 3984__qeth_fill_buffer(struct sk_buff *skb, struct qdio_buffer *buffer,
3939 int *next_element_to_fill) 3985 int is_tso, int *next_element_to_fill)
3940{ 3986{
3941 int length = skb->len; 3987 int length = skb->len;
3942 int length_here; 3988 int length_here;
3943 int element; 3989 int element;
3944 char *data; 3990 char *data;
3945 int first_lap = 1; 3991 int first_lap ;
3946 3992
3947 element = *next_element_to_fill; 3993 element = *next_element_to_fill;
3948 data = skb->data; 3994 data = skb->data;
3995 first_lap = (is_tso == 0 ? 1 : 0);
3996
3949 while (length > 0) { 3997 while (length > 0) {
3950 /* length_here is the remaining amount of data in this page */ 3998 /* length_here is the remaining amount of data in this page */
3951 length_here = PAGE_SIZE - ((unsigned long) data % PAGE_SIZE); 3999 length_here = PAGE_SIZE - ((unsigned long) data % PAGE_SIZE);
3952 if (length < length_here) 4000 if (length < length_here)
3953 length_here = length; 4001 length_here = length;
4002
3954 buffer->element[element].addr = data; 4003 buffer->element[element].addr = data;
3955 buffer->element[element].length = length_here; 4004 buffer->element[element].length = length_here;
3956 length -= length_here; 4005 length -= length_here;
3957 if (!length){ 4006 if (!length) {
3958 if (first_lap) 4007 if (first_lap)
3959 buffer->element[element].flags = 0; 4008 buffer->element[element].flags = 0;
3960 else 4009 else
@@ -3981,17 +4030,35 @@ qeth_fill_buffer(struct qeth_qdio_out_q *queue,
3981 struct sk_buff *skb) 4030 struct sk_buff *skb)
3982{ 4031{
3983 struct qdio_buffer *buffer; 4032 struct qdio_buffer *buffer;
3984 int flush_cnt = 0; 4033 struct qeth_hdr_tso *hdr;
4034 int flush_cnt = 0, hdr_len, large_send = 0;
3985 4035
3986 QETH_DBF_TEXT(trace, 6, "qdfillbf"); 4036 QETH_DBF_TEXT(trace, 6, "qdfillbf");
4037
3987 buffer = buf->buffer; 4038 buffer = buf->buffer;
3988 atomic_inc(&skb->users); 4039 atomic_inc(&skb->users);
3989 skb_queue_tail(&buf->skb_list, skb); 4040 skb_queue_tail(&buf->skb_list, skb);
4041
4042 hdr = (struct qeth_hdr_tso *) skb->data;
4043 /*check first on TSO ....*/
4044 if (hdr->hdr.hdr.l3.id == QETH_HEADER_TYPE_TSO) {
4045 int element = buf->next_element_to_fill;
4046
4047 hdr_len = sizeof(struct qeth_hdr_tso) + hdr->ext.dg_hdr_len;
4048 /*fill first buffer entry only with header information */
4049 buffer->element[element].addr = skb->data;
4050 buffer->element[element].length = hdr_len;
4051 buffer->element[element].flags = SBAL_FLAGS_FIRST_FRAG;
4052 buf->next_element_to_fill++;
4053 skb->data += hdr_len;
4054 skb->len -= hdr_len;
4055 large_send = 1;
4056 }
3990 if (skb_shinfo(skb)->nr_frags == 0) 4057 if (skb_shinfo(skb)->nr_frags == 0)
3991 __qeth_fill_buffer(skb, buffer, 4058 __qeth_fill_buffer(skb, buffer, large_send,
3992 (int *)&buf->next_element_to_fill); 4059 (int *)&buf->next_element_to_fill);
3993 else 4060 else
3994 __qeth_fill_buffer_frag(skb, buffer, 4061 __qeth_fill_buffer_frag(skb, buffer, large_send,
3995 (int *)&buf->next_element_to_fill); 4062 (int *)&buf->next_element_to_fill);
3996 4063
3997 if (!queue->do_pack) { 4064 if (!queue->do_pack) {
@@ -4184,6 +4251,25 @@ out:
4184} 4251}
4185 4252
4186static inline int 4253static inline int
4254qeth_get_elements_no(struct qeth_card *card, void *hdr, struct sk_buff *skb)
4255{
4256 int elements_needed = 0;
4257
4258 if (skb_shinfo(skb)->nr_frags > 0) {
4259 elements_needed = (skb_shinfo(skb)->nr_frags + 1);
4260 }
4261 if (elements_needed == 0 )
4262 elements_needed = 1 + (((((unsigned long) hdr) % PAGE_SIZE)
4263 + skb->len) >> PAGE_SHIFT);
4264 if (elements_needed > QETH_MAX_BUFFER_ELEMENTS(card)){
4265 PRINT_ERR("qeth_do_send_packet: invalid size of "
4266 "IP packet. Discarded.");
4267 return 0;
4268 }
4269 return elements_needed;
4270}
4271
4272static inline int
4187qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) 4273qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4188{ 4274{
4189 int ipv = 0; 4275 int ipv = 0;
@@ -4205,7 +4291,11 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4205 dev_kfree_skb_irq(skb); 4291 dev_kfree_skb_irq(skb);
4206 return 0; 4292 return 0;
4207 } 4293 }
4208 skb_pull(skb, QETH_FAKE_LL_LEN); 4294 if(card->dev->type == ARPHRD_IEEE802_TR){
4295 skb_pull(skb, QETH_FAKE_LL_LEN_TR);
4296 } else {
4297 skb_pull(skb, QETH_FAKE_LL_LEN_ETH);
4298 }
4209 } 4299 }
4210 } 4300 }
4211 cast_type = qeth_get_cast_type(card, skb); 4301 cast_type = qeth_get_cast_type(card, skb);
@@ -4221,19 +4311,25 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4221 if (skb_shinfo(skb)->tso_size) 4311 if (skb_shinfo(skb)->tso_size)
4222 large_send = card->options.large_send; 4312 large_send = card->options.large_send;
4223 4313
4224 if ((rc = qeth_prepare_skb(card, &skb, &hdr, ipv))){
4225 QETH_DBF_TEXT_(trace, 4, "pskbe%d", rc);
4226 return rc;
4227 }
4228 /*are we able to do TSO ? If so ,prepare and send it from here */ 4314 /*are we able to do TSO ? If so ,prepare and send it from here */
4229 if ((large_send == QETH_LARGE_SEND_TSO) && 4315 if ((large_send == QETH_LARGE_SEND_TSO) &&
4230 (cast_type == RTN_UNSPEC)) { 4316 (cast_type == RTN_UNSPEC)) {
4231 rc = qeth_tso_send_packet(card, skb, queue, 4317 rc = qeth_tso_prepare_packet(card, skb, ipv, cast_type);
4232 ipv, cast_type); 4318 if (rc) {
4233 goto do_statistics; 4319 card->stats.tx_dropped++;
4320 card->stats.tx_errors++;
4321 dev_kfree_skb_any(skb);
4322 return NETDEV_TX_OK;
4323 }
4324 elements_needed++;
4325 } else {
4326 if ((rc = qeth_prepare_skb(card, &skb, &hdr, ipv))) {
4327 QETH_DBF_TEXT_(trace, 4, "pskbe%d", rc);
4328 return rc;
4329 }
4330 qeth_fill_header(card, hdr, skb, ipv, cast_type);
4234 } 4331 }
4235 4332
4236 qeth_fill_header(card, hdr, skb, ipv, cast_type);
4237 if (large_send == QETH_LARGE_SEND_EDDP) { 4333 if (large_send == QETH_LARGE_SEND_EDDP) {
4238 ctx = qeth_eddp_create_context(card, skb, hdr); 4334 ctx = qeth_eddp_create_context(card, skb, hdr);
4239 if (ctx == NULL) { 4335 if (ctx == NULL) {
@@ -4241,7 +4337,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4241 return -EINVAL; 4337 return -EINVAL;
4242 } 4338 }
4243 } else { 4339 } else {
4244 elements_needed = qeth_get_elements_no(card,(void*) hdr, skb); 4340 elements_needed += qeth_get_elements_no(card,(void*) hdr, skb);
4245 if (!elements_needed) 4341 if (!elements_needed)
4246 return -EINVAL; 4342 return -EINVAL;
4247 } 4343 }
@@ -4252,12 +4348,12 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4252 else 4348 else
4253 rc = qeth_do_send_packet_fast(card, queue, skb, hdr, 4349 rc = qeth_do_send_packet_fast(card, queue, skb, hdr,
4254 elements_needed, ctx); 4350 elements_needed, ctx);
4255do_statistics:
4256 if (!rc){ 4351 if (!rc){
4257 card->stats.tx_packets++; 4352 card->stats.tx_packets++;
4258 card->stats.tx_bytes += skb->len; 4353 card->stats.tx_bytes += skb->len;
4259#ifdef CONFIG_QETH_PERF_STATS 4354#ifdef CONFIG_QETH_PERF_STATS
4260 if (skb_shinfo(skb)->tso_size) { 4355 if (skb_shinfo(skb)->tso_size &&
4356 !(large_send == QETH_LARGE_SEND_NO)) {
4261 card->perf_stats.large_send_bytes += skb->len; 4357 card->perf_stats.large_send_bytes += skb->len;
4262 card->perf_stats.large_send_cnt++; 4358 card->perf_stats.large_send_cnt++;
4263 } 4359 }
@@ -7154,7 +7250,7 @@ qeth_wait_for_threads(struct qeth_card *card, unsigned long threads)
7154} 7250}
7155 7251
7156static int 7252static int
7157qeth_stop_card(struct qeth_card *card) 7253qeth_stop_card(struct qeth_card *card, int recovery_mode)
7158{ 7254{
7159 int rc = 0; 7255 int rc = 0;
7160 7256
@@ -7167,9 +7263,13 @@ qeth_stop_card(struct qeth_card *card)
7167 if (card->read.state == CH_STATE_UP && 7263 if (card->read.state == CH_STATE_UP &&
7168 card->write.state == CH_STATE_UP && 7264 card->write.state == CH_STATE_UP &&
7169 (card->state == CARD_STATE_UP)) { 7265 (card->state == CARD_STATE_UP)) {
7170 rtnl_lock(); 7266 if(recovery_mode) {
7171 dev_close(card->dev); 7267 qeth_stop(card->dev);
7172 rtnl_unlock(); 7268 } else {
7269 rtnl_lock();
7270 dev_close(card->dev);
7271 rtnl_unlock();
7272 }
7173 if (!card->use_hard_stop) { 7273 if (!card->use_hard_stop) {
7174 __u8 *mac = &card->dev->dev_addr[0]; 7274 __u8 *mac = &card->dev->dev_addr[0];
7175 rc = qeth_layer2_send_delmac(card, mac); 7275 rc = qeth_layer2_send_delmac(card, mac);
@@ -7341,13 +7441,17 @@ qeth_register_netdev(struct qeth_card *card)
7341} 7441}
7342 7442
7343static void 7443static void
7344qeth_start_again(struct qeth_card *card) 7444qeth_start_again(struct qeth_card *card, int recovery_mode)
7345{ 7445{
7346 QETH_DBF_TEXT(setup ,2, "startag"); 7446 QETH_DBF_TEXT(setup ,2, "startag");
7347 7447
7348 rtnl_lock(); 7448 if(recovery_mode) {
7349 dev_open(card->dev); 7449 qeth_open(card->dev);
7350 rtnl_unlock(); 7450 } else {
7451 rtnl_lock();
7452 dev_open(card->dev);
7453 rtnl_unlock();
7454 }
7351 /* this also sets saved unicast addresses */ 7455 /* this also sets saved unicast addresses */
7352 qeth_set_multicast_list(card->dev); 7456 qeth_set_multicast_list(card->dev);
7353} 7457}
@@ -7404,7 +7508,7 @@ static void qeth_make_parameters_consistent(struct qeth_card *card)
7404 7508
7405 7509
7406static int 7510static int
7407qeth_set_online(struct ccwgroup_device *gdev) 7511__qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode)
7408{ 7512{
7409 struct qeth_card *card = gdev->dev.driver_data; 7513 struct qeth_card *card = gdev->dev.driver_data;
7410 int rc = 0; 7514 int rc = 0;
@@ -7464,12 +7568,12 @@ qeth_set_online(struct ccwgroup_device *gdev)
7464 * we can also use this state for recovery purposes*/ 7568 * we can also use this state for recovery purposes*/
7465 qeth_set_allowed_threads(card, 0xffffffff, 0); 7569 qeth_set_allowed_threads(card, 0xffffffff, 0);
7466 if (recover_flag == CARD_STATE_RECOVER) 7570 if (recover_flag == CARD_STATE_RECOVER)
7467 qeth_start_again(card); 7571 qeth_start_again(card, recovery_mode);
7468 qeth_notify_processes(); 7572 qeth_notify_processes();
7469 return 0; 7573 return 0;
7470out_remove: 7574out_remove:
7471 card->use_hard_stop = 1; 7575 card->use_hard_stop = 1;
7472 qeth_stop_card(card); 7576 qeth_stop_card(card, 0);
7473 ccw_device_set_offline(CARD_DDEV(card)); 7577 ccw_device_set_offline(CARD_DDEV(card));
7474 ccw_device_set_offline(CARD_WDEV(card)); 7578 ccw_device_set_offline(CARD_WDEV(card));
7475 ccw_device_set_offline(CARD_RDEV(card)); 7579 ccw_device_set_offline(CARD_RDEV(card));
@@ -7480,6 +7584,12 @@ out_remove:
7480 return -ENODEV; 7584 return -ENODEV;
7481} 7585}
7482 7586
7587static int
7588qeth_set_online(struct ccwgroup_device *gdev)
7589{
7590 return __qeth_set_online(gdev, 0);
7591}
7592
7483static struct ccw_device_id qeth_ids[] = { 7593static struct ccw_device_id qeth_ids[] = {
7484 {CCW_DEVICE(0x1731, 0x01), driver_info:QETH_CARD_TYPE_OSAE}, 7594 {CCW_DEVICE(0x1731, 0x01), driver_info:QETH_CARD_TYPE_OSAE},
7485 {CCW_DEVICE(0x1731, 0x05), driver_info:QETH_CARD_TYPE_IQD}, 7595 {CCW_DEVICE(0x1731, 0x05), driver_info:QETH_CARD_TYPE_IQD},
diff --git a/drivers/s390/net/qeth_tso.c b/drivers/s390/net/qeth_tso.c
deleted file mode 100644
index c91976274e7b..000000000000
--- a/drivers/s390/net/qeth_tso.c
+++ /dev/null
@@ -1,285 +0,0 @@
1/*
2 * linux/drivers/s390/net/qeth_tso.c ($Revision: 1.6 $)
3 *
4 * Header file for qeth TCP Segmentation Offload support.
5 *
6 * Copyright 2004 IBM Corporation
7 *
8 * Author(s): Frank Pavlic <pavlic@de.ibm.com>
9 *
10 * $Revision: 1.6 $ $Date: 2005/03/24 09:04:18 $
11 *
12 */
13
14#include <linux/skbuff.h>
15#include <linux/tcp.h>
16#include <linux/ip.h>
17#include <linux/ipv6.h>
18#include <net/ip6_checksum.h>
19#include "qeth.h"
20#include "qeth_mpc.h"
21#include "qeth_tso.h"
22
23/**
24 * skb already partially prepared
25 * classic qdio header in skb->data
26 * */
27static inline struct qeth_hdr_tso *
28qeth_tso_prepare_skb(struct qeth_card *card, struct sk_buff **skb)
29{
30 int rc = 0;
31
32 QETH_DBF_TEXT(trace, 5, "tsoprsk");
33 rc = qeth_realloc_headroom(card, skb,sizeof(struct qeth_hdr_ext_tso));
34 if (rc)
35 return NULL;
36
37 return qeth_push_skb(card, skb, sizeof(struct qeth_hdr_ext_tso));
38}
39
40/**
41 * fill header for a TSO packet
42 */
43static inline void
44qeth_tso_fill_header(struct qeth_card *card, struct sk_buff *skb)
45{
46 struct qeth_hdr_tso *hdr;
47 struct tcphdr *tcph;
48 struct iphdr *iph;
49
50 QETH_DBF_TEXT(trace, 5, "tsofhdr");
51
52 hdr = (struct qeth_hdr_tso *) skb->data;
53 iph = skb->nh.iph;
54 tcph = skb->h.th;
55 /*fix header to TSO values ...*/
56 hdr->hdr.hdr.l3.id = QETH_HEADER_TYPE_TSO;
57 /*set values which are fix for the first approach ...*/
58 hdr->ext.hdr_tot_len = (__u16) sizeof(struct qeth_hdr_ext_tso);
59 hdr->ext.imb_hdr_no = 1;
60 hdr->ext.hdr_type = 1;
61 hdr->ext.hdr_version = 1;
62 hdr->ext.hdr_len = 28;
63 /*insert non-fix values */
64 hdr->ext.mss = skb_shinfo(skb)->tso_size;
65 hdr->ext.dg_hdr_len = (__u16)(iph->ihl*4 + tcph->doff*4);
66 hdr->ext.payload_len = (__u16)(skb->len - hdr->ext.dg_hdr_len -
67 sizeof(struct qeth_hdr_tso));
68}
69
70/**
71 * change some header values as requested by hardware
72 */
73static inline void
74qeth_tso_set_tcpip_header(struct qeth_card *card, struct sk_buff *skb)
75{
76 struct iphdr *iph;
77 struct ipv6hdr *ip6h;
78 struct tcphdr *tcph;
79
80 iph = skb->nh.iph;
81 ip6h = skb->nh.ipv6h;
82 tcph = skb->h.th;
83
84 tcph->check = 0;
85 if (skb->protocol == ETH_P_IPV6) {
86 ip6h->payload_len = 0;
87 tcph->check = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
88 0, IPPROTO_TCP, 0);
89 return;
90 }
91 /*OSA want us to set these values ...*/
92 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
93 0, IPPROTO_TCP, 0);
94 iph->tot_len = 0;
95 iph->check = 0;
96}
97
98static inline struct qeth_hdr_tso *
99qeth_tso_prepare_packet(struct qeth_card *card, struct sk_buff *skb,
100 int ipv, int cast_type)
101{
102 struct qeth_hdr_tso *hdr;
103 int rc = 0;
104
105 QETH_DBF_TEXT(trace, 5, "tsoprep");
106
107 /*get headroom for tso qdio header */
108 hdr = (struct qeth_hdr_tso *) qeth_tso_prepare_skb(card, &skb);
109 if (hdr == NULL) {
110 QETH_DBF_TEXT_(trace, 4, "2err%d", rc);
111 return NULL;
112 }
113 memset(hdr, 0, sizeof(struct qeth_hdr_tso));
114 /*fill first 32 bytes of qdio header as used
115 *FIXME: TSO has two struct members
116 * with different names but same size
117 * */
118 qeth_fill_header(card, &hdr->hdr, skb, ipv, cast_type);
119 qeth_tso_fill_header(card, skb);
120 qeth_tso_set_tcpip_header(card, skb);
121 return hdr;
122}
123
124static inline int
125qeth_tso_get_queue_buffer(struct qeth_qdio_out_q *queue)
126{
127 struct qeth_qdio_out_buffer *buffer;
128 int flush_cnt = 0;
129
130 QETH_DBF_TEXT(trace, 5, "tsobuf");
131
132 /* force to non-packing*/
133 if (queue->do_pack)
134 queue->do_pack = 0;
135 buffer = &queue->bufs[queue->next_buf_to_fill];
136 /* get a new buffer if current is already in use*/
137 if ((atomic_read(&buffer->state) == QETH_QDIO_BUF_EMPTY) &&
138 (buffer->next_element_to_fill > 0)) {
139 atomic_set(&buffer->state, QETH_QDIO_BUF_PRIMED);
140 queue->next_buf_to_fill = (queue->next_buf_to_fill + 1) %
141 QDIO_MAX_BUFFERS_PER_Q;
142 flush_cnt++;
143 }
144 return flush_cnt;
145}
146
147static inline void
148__qeth_tso_fill_buffer_frag(struct qeth_qdio_out_buffer *buf,
149 struct sk_buff *skb)
150{
151 struct skb_frag_struct *frag;
152 struct qdio_buffer *buffer;
153 int fragno, cnt, element;
154 unsigned long addr;
155
156 QETH_DBF_TEXT(trace, 6, "tsfilfrg");
157
158 /*initialize variables ...*/
159 fragno = skb_shinfo(skb)->nr_frags;
160 buffer = buf->buffer;
161 element = buf->next_element_to_fill;
162 /*fill buffer elements .....*/
163 for (cnt = 0; cnt < fragno; cnt++) {
164 frag = &skb_shinfo(skb)->frags[cnt];
165 addr = (page_to_pfn(frag->page) << PAGE_SHIFT) +
166 frag->page_offset;
167 buffer->element[element].addr = (char *)addr;
168 buffer->element[element].length = frag->size;
169 if (cnt < (fragno - 1))
170 buffer->element[element].flags =
171 SBAL_FLAGS_MIDDLE_FRAG;
172 else
173 buffer->element[element].flags =
174 SBAL_FLAGS_LAST_FRAG;
175 element++;
176 }
177 buf->next_element_to_fill = element;
178}
179
180static inline int
181qeth_tso_fill_buffer(struct qeth_qdio_out_buffer *buf,
182 struct sk_buff *skb)
183{
184 int length, length_here, element;
185 int hdr_len;
186 struct qdio_buffer *buffer;
187 struct qeth_hdr_tso *hdr;
188 char *data;
189
190 QETH_DBF_TEXT(trace, 3, "tsfilbuf");
191
192 /*increment user count and queue skb ...*/
193 atomic_inc(&skb->users);
194 skb_queue_tail(&buf->skb_list, skb);
195
196 /*initialize all variables...*/
197 buffer = buf->buffer;
198 hdr = (struct qeth_hdr_tso *)skb->data;
199 hdr_len = sizeof(struct qeth_hdr_tso) + hdr->ext.dg_hdr_len;
200 data = skb->data + hdr_len;
201 length = skb->len - hdr_len;
202 element = buf->next_element_to_fill;
203 /*fill first buffer entry only with header information */
204 buffer->element[element].addr = skb->data;
205 buffer->element[element].length = hdr_len;
206 buffer->element[element].flags = SBAL_FLAGS_FIRST_FRAG;
207 buf->next_element_to_fill++;
208
209 if (skb_shinfo(skb)->nr_frags > 0) {
210 __qeth_tso_fill_buffer_frag(buf, skb);
211 goto out;
212 }
213
214 /*start filling buffer entries ...*/
215 element++;
216 while (length > 0) {
217 /* length_here is the remaining amount of data in this page */
218 length_here = PAGE_SIZE - ((unsigned long) data % PAGE_SIZE);
219 if (length < length_here)
220 length_here = length;
221 buffer->element[element].addr = data;
222 buffer->element[element].length = length_here;
223 length -= length_here;
224 if (!length)
225 buffer->element[element].flags =
226 SBAL_FLAGS_LAST_FRAG;
227 else
228 buffer->element[element].flags =
229 SBAL_FLAGS_MIDDLE_FRAG;
230 data += length_here;
231 element++;
232 }
233 /*set the buffer to primed ...*/
234 buf->next_element_to_fill = element;
235out:
236 atomic_set(&buf->state, QETH_QDIO_BUF_PRIMED);
237 return 1;
238}
239
240int
241qeth_tso_send_packet(struct qeth_card *card, struct sk_buff *skb,
242 struct qeth_qdio_out_q *queue, int ipv, int cast_type)
243{
244 int flush_cnt = 0;
245 struct qeth_hdr_tso *hdr;
246 struct qeth_qdio_out_buffer *buffer;
247 int start_index;
248
249 QETH_DBF_TEXT(trace, 3, "tsosend");
250
251 if (!(hdr = qeth_tso_prepare_packet(card, skb, ipv, cast_type)))
252 return -ENOMEM;
253 /*check if skb fits in one SBAL ...*/
254 if (!(qeth_get_elements_no(card, (void*)hdr, skb)))
255 return -EINVAL;
256 /*lock queue, force switching to non-packing and send it ...*/
257 while (atomic_compare_and_swap(QETH_OUT_Q_UNLOCKED,
258 QETH_OUT_Q_LOCKED,
259 &queue->state));
260 start_index = queue->next_buf_to_fill;
261 buffer = &queue->bufs[queue->next_buf_to_fill];
262 /*check if card is too busy ...*/
263 if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY){
264 card->stats.tx_dropped++;
265 goto out;
266 }
267 /*let's force to non-packing and get a new SBAL*/
268 flush_cnt += qeth_tso_get_queue_buffer(queue);
269 buffer = &queue->bufs[queue->next_buf_to_fill];
270 if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) {
271 card->stats.tx_dropped++;
272 goto out;
273 }
274 flush_cnt += qeth_tso_fill_buffer(buffer, skb);
275 queue->next_buf_to_fill = (queue->next_buf_to_fill + 1) %
276 QDIO_MAX_BUFFERS_PER_Q;
277out:
278 atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED);
279 if (flush_cnt)
280 qeth_flush_buffers(queue, 0, start_index, flush_cnt);
281 /*do some statistics */
282 card->stats.tx_packets++;
283 card->stats.tx_bytes += skb->len;
284 return 0;
285}
diff --git a/drivers/s390/net/qeth_tso.h b/drivers/s390/net/qeth_tso.h
index 83504dee3f57..ad33e6f466f1 100644
--- a/drivers/s390/net/qeth_tso.h
+++ b/drivers/s390/net/qeth_tso.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/s390/net/qeth_tso.h ($Revision: 1.4 $) 2 * linux/drivers/s390/net/qeth_tso.h ($Revision: 1.7 $)
3 * 3 *
4 * Header file for qeth TCP Segmentation Offload support. 4 * Header file for qeth TCP Segmentation Offload support.
5 * 5 *
@@ -7,52 +7,148 @@
7 * 7 *
8 * Author(s): Frank Pavlic <pavlic@de.ibm.com> 8 * Author(s): Frank Pavlic <pavlic@de.ibm.com>
9 * 9 *
10 * $Revision: 1.4 $ $Date: 2005/03/24 09:04:18 $ 10 * $Revision: 1.7 $ $Date: 2005/05/04 20:19:18 $
11 * 11 *
12 */ 12 */
13#ifndef __QETH_TSO_H__ 13#ifndef __QETH_TSO_H__
14#define __QETH_TSO_H__ 14#define __QETH_TSO_H__
15 15
16#include <linux/skbuff.h>
17#include <linux/tcp.h>
18#include <linux/ip.h>
19#include <linux/ipv6.h>
20#include <net/ip6_checksum.h>
21#include "qeth.h"
22#include "qeth_mpc.h"
16 23
17extern int
18qeth_tso_send_packet(struct qeth_card *, struct sk_buff *,
19 struct qeth_qdio_out_q *, int , int);
20 24
21struct qeth_hdr_ext_tso { 25static inline struct qeth_hdr_tso *
22 __u16 hdr_tot_len; 26qeth_tso_prepare_skb(struct qeth_card *card, struct sk_buff **skb)
23 __u8 imb_hdr_no; 27{
24 __u8 reserved; 28 QETH_DBF_TEXT(trace, 5, "tsoprsk");
25 __u8 hdr_type; 29 return qeth_push_skb(card, skb, sizeof(struct qeth_hdr_tso));
26 __u8 hdr_version; 30}
27 __u16 hdr_len; 31
28 __u32 payload_len; 32/**
29 __u16 mss; 33 * fill header for a TSO packet
30 __u16 dg_hdr_len; 34 */
31 __u8 padding[16]; 35static inline void
32} __attribute__ ((packed)); 36qeth_tso_fill_header(struct qeth_card *card, struct sk_buff *skb)
37{
38 struct qeth_hdr_tso *hdr;
39 struct tcphdr *tcph;
40 struct iphdr *iph;
41
42 QETH_DBF_TEXT(trace, 5, "tsofhdr");
43
44 hdr = (struct qeth_hdr_tso *) skb->data;
45 iph = skb->nh.iph;
46 tcph = skb->h.th;
47 /*fix header to TSO values ...*/
48 hdr->hdr.hdr.l3.id = QETH_HEADER_TYPE_TSO;
49 /*set values which are fix for the first approach ...*/
50 hdr->ext.hdr_tot_len = (__u16) sizeof(struct qeth_hdr_ext_tso);
51 hdr->ext.imb_hdr_no = 1;
52 hdr->ext.hdr_type = 1;
53 hdr->ext.hdr_version = 1;
54 hdr->ext.hdr_len = 28;
55 /*insert non-fix values */
56 hdr->ext.mss = skb_shinfo(skb)->tso_size;
57 hdr->ext.dg_hdr_len = (__u16)(iph->ihl*4 + tcph->doff*4);
58 hdr->ext.payload_len = (__u16)(skb->len - hdr->ext.dg_hdr_len -
59 sizeof(struct qeth_hdr_tso));
60}
61
62/**
63 * change some header values as requested by hardware
64 */
65static inline void
66qeth_tso_set_tcpip_header(struct qeth_card *card, struct sk_buff *skb)
67{
68 struct iphdr *iph;
69 struct ipv6hdr *ip6h;
70 struct tcphdr *tcph;
33 71
34struct qeth_hdr_tso { 72 iph = skb->nh.iph;
35 struct qeth_hdr hdr; /*hdr->hdr.l3.xxx*/ 73 ip6h = skb->nh.ipv6h;
36 struct qeth_hdr_ext_tso ext; 74 tcph = skb->h.th;
37} __attribute__ ((packed));
38 75
39/*some helper functions*/ 76 tcph->check = 0;
77 if (skb->protocol == ETH_P_IPV6) {
78 ip6h->payload_len = 0;
79 tcph->check = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
80 0, IPPROTO_TCP, 0);
81 return;
82 }
83 /*OSA want us to set these values ...*/
84 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
85 0, IPPROTO_TCP, 0);
86 iph->tot_len = 0;
87 iph->check = 0;
88}
40 89
41static inline int 90static inline int
42qeth_get_elements_no(struct qeth_card *card, void *hdr, struct sk_buff *skb) 91qeth_tso_prepare_packet(struct qeth_card *card, struct sk_buff *skb,
92 int ipv, int cast_type)
93{
94 struct qeth_hdr_tso *hdr;
95
96 QETH_DBF_TEXT(trace, 5, "tsoprep");
97
98 hdr = (struct qeth_hdr_tso *) qeth_tso_prepare_skb(card, &skb);
99 if (hdr == NULL) {
100 QETH_DBF_TEXT(trace, 4, "tsoperr");
101 return -ENOMEM;
102 }
103 memset(hdr, 0, sizeof(struct qeth_hdr_tso));
104 /*fill first 32 bytes of qdio header as used
105 *FIXME: TSO has two struct members
106 * with different names but same size
107 * */
108 qeth_fill_header(card, &hdr->hdr, skb, ipv, cast_type);
109 qeth_tso_fill_header(card, skb);
110 qeth_tso_set_tcpip_header(card, skb);
111 return 0;
112}
113
114static inline void
115__qeth_fill_buffer_frag(struct sk_buff *skb, struct qdio_buffer *buffer,
116 int is_tso, int *next_element_to_fill)
43{ 117{
44 int elements_needed = 0; 118 struct skb_frag_struct *frag;
45 119 int fragno;
46 if (skb_shinfo(skb)->nr_frags > 0) 120 unsigned long addr;
47 elements_needed = (skb_shinfo(skb)->nr_frags + 1); 121 int element, cnt, dlen;
48 if (elements_needed == 0 ) 122
49 elements_needed = 1 + (((((unsigned long) hdr) % PAGE_SIZE) 123 fragno = skb_shinfo(skb)->nr_frags;
50 + skb->len) >> PAGE_SHIFT); 124 element = *next_element_to_fill;
51 if (elements_needed > QETH_MAX_BUFFER_ELEMENTS(card)){ 125 dlen = 0;
52 PRINT_ERR("qeth_do_send_packet: invalid size of " 126
53 "IP packet. Discarded."); 127 if (is_tso)
54 return 0; 128 buffer->element[element].flags =
129 SBAL_FLAGS_MIDDLE_FRAG;
130 else
131 buffer->element[element].flags =
132 SBAL_FLAGS_FIRST_FRAG;
133 if ( (dlen = (skb->len - skb->data_len)) ) {
134 buffer->element[element].addr = skb->data;
135 buffer->element[element].length = dlen;
136 element++;
137 }
138 for (cnt = 0; cnt < fragno; cnt++) {
139 frag = &skb_shinfo(skb)->frags[cnt];
140 addr = (page_to_pfn(frag->page) << PAGE_SHIFT) +
141 frag->page_offset;
142 buffer->element[element].addr = (char *)addr;
143 buffer->element[element].length = frag->size;
144 if (cnt < (fragno - 1))
145 buffer->element[element].flags =
146 SBAL_FLAGS_MIDDLE_FRAG;
147 else
148 buffer->element[element].flags =
149 SBAL_FLAGS_LAST_FRAG;
150 element++;
55 } 151 }
56 return elements_needed; 152 *next_element_to_fill = element;
57} 153}
58#endif /* __QETH_TSO_H__ */ 154#endif /* __QETH_TSO_H__ */
diff --git a/drivers/sbus/char/aurora.c b/drivers/sbus/char/aurora.c
index e5fa1703856b..650d5e924f47 100644
--- a/drivers/sbus/char/aurora.c
+++ b/drivers/sbus/char/aurora.c
@@ -81,10 +81,6 @@ unsigned char irqs[4] = {
81int irqhit=0; 81int irqhit=0;
82#endif 82#endif
83 83
84#ifndef MIN
85#define MIN(a,b) ((a) < (b) ? (a) : (b))
86#endif
87
88static struct tty_driver *aurora_driver; 84static struct tty_driver *aurora_driver;
89static struct Aurora_board aurora_board[AURORA_NBOARD] = { 85static struct Aurora_board aurora_board[AURORA_NBOARD] = {
90 {0,}, 86 {0,},
@@ -594,7 +590,7 @@ static void aurora_transmit(struct Aurora_board const * bp, int chip)
594 &bp->r[chip]->r[CD180_TDR]); 590 &bp->r[chip]->r[CD180_TDR]);
595 port->COR2 &= ~COR2_ETC; 591 port->COR2 &= ~COR2_ETC;
596 } 592 }
597 count = MIN(port->break_length, 0xff); 593 count = min(port->break_length, 0xff);
598 sbus_writeb(CD180_C_ESC, 594 sbus_writeb(CD180_C_ESC,
599 &bp->r[chip]->r[CD180_TDR]); 595 &bp->r[chip]->r[CD180_TDR]);
600 sbus_writeb(CD180_C_DELAY, 596 sbus_writeb(CD180_C_DELAY,
@@ -1575,7 +1571,7 @@ static int aurora_write(struct tty_struct * tty,
1575 save_flags(flags); 1571 save_flags(flags);
1576 while (1) { 1572 while (1) {
1577 cli(); 1573 cli();
1578 c = MIN(count, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1, 1574 c = min(count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
1579 SERIAL_XMIT_SIZE - port->xmit_head)); 1575 SERIAL_XMIT_SIZE - port->xmit_head));
1580 if (c <= 0) { 1576 if (c <= 0) {
1581 restore_flags(flags); 1577 restore_flags(flags);
diff --git a/drivers/scsi/aic7xxx/aic7770_osm.c b/drivers/scsi/aic7xxx/aic7770_osm.c
index c2b47f2bdffd..682ca0b32b44 100644
--- a/drivers/scsi/aic7xxx/aic7770_osm.c
+++ b/drivers/scsi/aic7xxx/aic7770_osm.c
@@ -41,7 +41,6 @@
41 41
42#include "aic7xxx_osm.h" 42#include "aic7xxx_osm.h"
43 43
44#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
45#include <linux/device.h> 44#include <linux/device.h>
46#include <linux/eisa.h> 45#include <linux/eisa.h>
47 46
@@ -62,13 +61,6 @@ static struct eisa_driver aic7770_driver = {
62}; 61};
63 62
64typedef struct device *aic7770_dev_t; 63typedef struct device *aic7770_dev_t;
65#else
66#define MINSLOT 1
67#define NUMSLOTS 16
68#define IDOFFSET 0x80
69
70typedef void *aic7770_dev_t;
71#endif
72 64
73static int aic7770_linux_config(struct aic7770_identity *entry, 65static int aic7770_linux_config(struct aic7770_identity *entry,
74 aic7770_dev_t dev, u_int eisaBase); 66 aic7770_dev_t dev, u_int eisaBase);
@@ -76,7 +68,6 @@ static int aic7770_linux_config(struct aic7770_identity *entry,
76int 68int
77ahc_linux_eisa_init(void) 69ahc_linux_eisa_init(void)
78{ 70{
79#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
80 struct eisa_device_id *eid; 71 struct eisa_device_id *eid;
81 struct aic7770_identity *id; 72 struct aic7770_identity *id;
82 int i; 73 int i;
@@ -110,44 +101,6 @@ ahc_linux_eisa_init(void)
110 eid->sig[0] = 0; 101 eid->sig[0] = 0;
111 102
112 return eisa_driver_register(&aic7770_driver); 103 return eisa_driver_register(&aic7770_driver);
113#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */
114 struct aic7770_identity *entry;
115 u_int slot;
116 u_int eisaBase;
117 u_int i;
118 int ret = -ENODEV;
119
120 if (aic7xxx_probe_eisa_vl == 0)
121 return ret;
122
123 eisaBase = 0x1000 + AHC_EISA_SLOT_OFFSET;
124 for (slot = 1; slot < NUMSLOTS; eisaBase+=0x1000, slot++) {
125 uint32_t eisa_id;
126 size_t id_size;
127
128 if (request_region(eisaBase, AHC_EISA_IOSIZE, "aic7xxx") == 0)
129 continue;
130
131 eisa_id = 0;
132 id_size = sizeof(eisa_id);
133 for (i = 0; i < 4; i++) {
134 /* VLcards require priming*/
135 outb(0x80 + i, eisaBase + IDOFFSET);
136 eisa_id |= inb(eisaBase + IDOFFSET + i)
137 << ((id_size-i-1) * 8);
138 }
139 release_region(eisaBase, AHC_EISA_IOSIZE);
140 if (eisa_id & 0x80000000)
141 continue; /* no EISA card in slot */
142
143 entry = aic7770_find_device(eisa_id);
144 if (entry != NULL) {
145 aic7770_linux_config(entry, NULL, eisaBase);
146 ret = 0;
147 }
148 }
149 return ret;
150#endif
151} 104}
152 105
153void 106void
@@ -187,11 +140,10 @@ aic7770_linux_config(struct aic7770_identity *entry, aic7770_dev_t dev,
187 ahc_free(ahc); 140 ahc_free(ahc);
188 return (error); 141 return (error);
189 } 142 }
190#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 143
191 dev->driver_data = (void *)ahc; 144 dev->driver_data = (void *)ahc;
192 if (aic7xxx_detect_complete) 145 if (aic7xxx_detect_complete)
193 error = ahc_linux_register_host(ahc, &aic7xxx_driver_template); 146 error = ahc_linux_register_host(ahc, &aic7xxx_driver_template);
194#endif
195 return (error); 147 return (error);
196} 148}
197 149
@@ -225,7 +177,6 @@ aic7770_map_int(struct ahc_softc *ahc, u_int irq)
225 return (-error); 177 return (-error);
226} 178}
227 179
228#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
229static int 180static int
230aic7770_eisa_dev_probe(struct device *dev) 181aic7770_eisa_dev_probe(struct device *dev)
231{ 182{
@@ -261,4 +212,3 @@ aic7770_eisa_dev_remove(struct device *dev)
261 212
262 return (0); 213 return (0);
263} 214}
264#endif
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index d978e4a3e973..c13e56320010 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -134,11 +134,6 @@ static struct scsi_transport_template *ahc_linux_transport_template = NULL;
134#include "aiclib.c" 134#include "aiclib.c"
135 135
136#include <linux/init.h> /* __setup */ 136#include <linux/init.h> /* __setup */
137
138#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
139#include "sd.h" /* For geometry detection */
140#endif
141
142#include <linux/mm.h> /* For fetching system memory size */ 137#include <linux/mm.h> /* For fetching system memory size */
143#include <linux/blkdev.h> /* For block_size() */ 138#include <linux/blkdev.h> /* For block_size() */
144#include <linux/delay.h> /* For ssleep/msleep */ 139#include <linux/delay.h> /* For ssleep/msleep */
@@ -148,11 +143,6 @@ static struct scsi_transport_template *ahc_linux_transport_template = NULL;
148 */ 143 */
149spinlock_t ahc_list_spinlock; 144spinlock_t ahc_list_spinlock;
150 145
151#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
152/* For dynamic sglist size calculation. */
153u_int ahc_linux_nseg;
154#endif
155
156/* 146/*
157 * Set this to the delay in seconds after SCSI bus reset. 147 * Set this to the delay in seconds after SCSI bus reset.
158 * Note, we honor this only for the initial bus reset. 148 * Note, we honor this only for the initial bus reset.
@@ -436,15 +426,12 @@ static void ahc_linux_handle_scsi_status(struct ahc_softc *,
436 struct ahc_linux_device *, 426 struct ahc_linux_device *,
437 struct scb *); 427 struct scb *);
438static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, 428static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc,
439 Scsi_Cmnd *cmd); 429 struct scsi_cmnd *cmd);
440static void ahc_linux_sem_timeout(u_long arg); 430static void ahc_linux_sem_timeout(u_long arg);
441static void ahc_linux_freeze_simq(struct ahc_softc *ahc); 431static void ahc_linux_freeze_simq(struct ahc_softc *ahc);
442static void ahc_linux_release_simq(u_long arg); 432static void ahc_linux_release_simq(u_long arg);
443static void ahc_linux_dev_timed_unfreeze(u_long arg); 433static int ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag);
444static int ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag);
445static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc); 434static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc);
446static void ahc_linux_size_nseg(void);
447static void ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc);
448static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc, 435static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc,
449 struct ahc_devinfo *devinfo); 436 struct ahc_devinfo *devinfo);
450static void ahc_linux_device_queue_depth(struct ahc_softc *ahc, 437static void ahc_linux_device_queue_depth(struct ahc_softc *ahc,
@@ -458,54 +445,27 @@ static struct ahc_linux_device* ahc_linux_alloc_device(struct ahc_softc*,
458 u_int); 445 u_int);
459static void ahc_linux_free_device(struct ahc_softc*, 446static void ahc_linux_free_device(struct ahc_softc*,
460 struct ahc_linux_device*); 447 struct ahc_linux_device*);
461static void ahc_linux_run_device_queue(struct ahc_softc*, 448static int ahc_linux_run_command(struct ahc_softc*,
462 struct ahc_linux_device*); 449 struct ahc_linux_device *,
450 struct scsi_cmnd *);
463static void ahc_linux_setup_tag_info_global(char *p); 451static void ahc_linux_setup_tag_info_global(char *p);
464static aic_option_callback_t ahc_linux_setup_tag_info; 452static aic_option_callback_t ahc_linux_setup_tag_info;
465static int aic7xxx_setup(char *s); 453static int aic7xxx_setup(char *s);
466static int ahc_linux_next_unit(void); 454static int ahc_linux_next_unit(void);
467static void ahc_runq_tasklet(unsigned long data);
468static struct ahc_cmd *ahc_linux_run_complete_queue(struct ahc_softc *ahc);
469 455
470/********************************* Inlines ************************************/ 456/********************************* Inlines ************************************/
471static __inline void ahc_schedule_runq(struct ahc_softc *ahc);
472static __inline struct ahc_linux_device* 457static __inline struct ahc_linux_device*
473 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, 458 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel,
474 u_int target, u_int lun, int alloc); 459 u_int target, u_int lun);
475static __inline void ahc_schedule_completeq(struct ahc_softc *ahc);
476static __inline void ahc_linux_check_device_queue(struct ahc_softc *ahc,
477 struct ahc_linux_device *dev);
478static __inline struct ahc_linux_device *
479 ahc_linux_next_device_to_run(struct ahc_softc *ahc);
480static __inline void ahc_linux_run_device_queues(struct ahc_softc *ahc);
481static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*); 460static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*);
482 461
483static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, 462static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
484 struct ahc_dma_seg *sg, 463 struct ahc_dma_seg *sg,
485 dma_addr_t addr, bus_size_t len); 464 dma_addr_t addr, bus_size_t len);
486 465
487static __inline void
488ahc_schedule_completeq(struct ahc_softc *ahc)
489{
490 if ((ahc->platform_data->flags & AHC_RUN_CMPLT_Q_TIMER) == 0) {
491 ahc->platform_data->flags |= AHC_RUN_CMPLT_Q_TIMER;
492 ahc->platform_data->completeq_timer.expires = jiffies;
493 add_timer(&ahc->platform_data->completeq_timer);
494 }
495}
496
497/*
498 * Must be called with our lock held.
499 */
500static __inline void
501ahc_schedule_runq(struct ahc_softc *ahc)
502{
503 tasklet_schedule(&ahc->platform_data->runq_tasklet);
504}
505
506static __inline struct ahc_linux_device* 466static __inline struct ahc_linux_device*
507ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, u_int target, 467ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, u_int target,
508 u_int lun, int alloc) 468 u_int lun)
509{ 469{
510 struct ahc_linux_target *targ; 470 struct ahc_linux_target *targ;
511 struct ahc_linux_device *dev; 471 struct ahc_linux_device *dev;
@@ -515,102 +475,15 @@ ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, u_int target,
515 if (channel != 0) 475 if (channel != 0)
516 target_offset += 8; 476 target_offset += 8;
517 targ = ahc->platform_data->targets[target_offset]; 477 targ = ahc->platform_data->targets[target_offset];
518 if (targ == NULL) { 478 BUG_ON(targ == NULL);
519 if (alloc != 0) {
520 targ = ahc_linux_alloc_target(ahc, channel, target);
521 if (targ == NULL)
522 return (NULL);
523 } else
524 return (NULL);
525 }
526 dev = targ->devices[lun]; 479 dev = targ->devices[lun];
527 if (dev == NULL && alloc != 0) 480 return dev;
528 dev = ahc_linux_alloc_device(ahc, targ, lun);
529 return (dev);
530}
531
532#define AHC_LINUX_MAX_RETURNED_ERRORS 4
533static struct ahc_cmd *
534ahc_linux_run_complete_queue(struct ahc_softc *ahc)
535{
536 struct ahc_cmd *acmd;
537 u_long done_flags;
538 int with_errors;
539
540 with_errors = 0;
541 ahc_done_lock(ahc, &done_flags);
542 while ((acmd = TAILQ_FIRST(&ahc->platform_data->completeq)) != NULL) {
543 Scsi_Cmnd *cmd;
544
545 if (with_errors > AHC_LINUX_MAX_RETURNED_ERRORS) {
546 /*
547 * Linux uses stack recursion to requeue
548 * commands that need to be retried. Avoid
549 * blowing out the stack by "spoon feeding"
550 * commands that completed with error back
551 * the operating system in case they are going
552 * to be retried. "ick"
553 */
554 ahc_schedule_completeq(ahc);
555 break;
556 }
557 TAILQ_REMOVE(&ahc->platform_data->completeq,
558 acmd, acmd_links.tqe);
559 cmd = &acmd_scsi_cmd(acmd);
560 cmd->host_scribble = NULL;
561 if (ahc_cmd_get_transaction_status(cmd) != DID_OK
562 || (cmd->result & 0xFF) != SCSI_STATUS_OK)
563 with_errors++;
564
565 cmd->scsi_done(cmd);
566 }
567 ahc_done_unlock(ahc, &done_flags);
568 return (acmd);
569}
570
571static __inline void
572ahc_linux_check_device_queue(struct ahc_softc *ahc,
573 struct ahc_linux_device *dev)
574{
575 if ((dev->flags & AHC_DEV_FREEZE_TIL_EMPTY) != 0
576 && dev->active == 0) {
577 dev->flags &= ~AHC_DEV_FREEZE_TIL_EMPTY;
578 dev->qfrozen--;
579 }
580
581 if (TAILQ_FIRST(&dev->busyq) == NULL
582 || dev->openings == 0 || dev->qfrozen != 0)
583 return;
584
585 ahc_linux_run_device_queue(ahc, dev);
586}
587
588static __inline struct ahc_linux_device *
589ahc_linux_next_device_to_run(struct ahc_softc *ahc)
590{
591
592 if ((ahc->flags & AHC_RESOURCE_SHORTAGE) != 0
593 || (ahc->platform_data->qfrozen != 0))
594 return (NULL);
595 return (TAILQ_FIRST(&ahc->platform_data->device_runq));
596}
597
598static __inline void
599ahc_linux_run_device_queues(struct ahc_softc *ahc)
600{
601 struct ahc_linux_device *dev;
602
603 while ((dev = ahc_linux_next_device_to_run(ahc)) != NULL) {
604 TAILQ_REMOVE(&ahc->platform_data->device_runq, dev, links);
605 dev->flags &= ~AHC_DEV_ON_RUN_LIST;
606 ahc_linux_check_device_queue(ahc, dev);
607 }
608} 481}
609 482
610static __inline void 483static __inline void
611ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb) 484ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb)
612{ 485{
613 Scsi_Cmnd *cmd; 486 struct scsi_cmnd *cmd;
614 487
615 cmd = scb->io_ctx; 488 cmd = scb->io_ctx;
616 ahc_sync_sglist(ahc, scb, BUS_DMASYNC_POSTWRITE); 489 ahc_sync_sglist(ahc, scb, BUS_DMASYNC_POSTWRITE);
@@ -650,109 +523,15 @@ ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
650 return (consumed); 523 return (consumed);
651} 524}
652 525
653/************************ Host template entry points *************************/
654static int ahc_linux_detect(Scsi_Host_Template *);
655static int ahc_linux_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
656static const char *ahc_linux_info(struct Scsi_Host *);
657#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
658static int ahc_linux_slave_alloc(Scsi_Device *);
659static int ahc_linux_slave_configure(Scsi_Device *);
660static void ahc_linux_slave_destroy(Scsi_Device *);
661#if defined(__i386__)
662static int ahc_linux_biosparam(struct scsi_device*,
663 struct block_device*,
664 sector_t, int[]);
665#endif
666#else
667static int ahc_linux_release(struct Scsi_Host *);
668static void ahc_linux_select_queue_depth(struct Scsi_Host *host,
669 Scsi_Device *scsi_devs);
670#if defined(__i386__)
671static int ahc_linux_biosparam(Disk *, kdev_t, int[]);
672#endif
673#endif
674static int ahc_linux_bus_reset(Scsi_Cmnd *);
675static int ahc_linux_dev_reset(Scsi_Cmnd *);
676static int ahc_linux_abort(Scsi_Cmnd *);
677
678/*
679 * Calculate a safe value for AHC_NSEG (as expressed through ahc_linux_nseg).
680 *
681 * In pre-2.5.X...
682 * The midlayer allocates an S/G array dynamically when a command is issued
683 * using SCSI malloc. This array, which is in an OS dependent format that
684 * must later be copied to our private S/G list, is sized to house just the
685 * number of segments needed for the current transfer. Since the code that
686 * sizes the SCSI malloc pool does not take into consideration fragmentation
687 * of the pool, executing transactions numbering just a fraction of our
688 * concurrent transaction limit with list lengths aproaching AHC_NSEG will
689 * quickly depleat the SCSI malloc pool of usable space. Unfortunately, the
690 * mid-layer does not properly handle this scsi malloc failures for the S/G
691 * array and the result can be a lockup of the I/O subsystem. We try to size
692 * our S/G list so that it satisfies our drivers allocation requirements in
693 * addition to avoiding fragmentation of the SCSI malloc pool.
694 */
695static void
696ahc_linux_size_nseg(void)
697{
698#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
699 u_int cur_size;
700 u_int best_size;
701
702 /*
703 * The SCSI allocator rounds to the nearest 512 bytes
704 * an cannot allocate across a page boundary. Our algorithm
705 * is to start at 1K of scsi malloc space per-command and
706 * loop through all factors of the PAGE_SIZE and pick the best.
707 */
708 best_size = 0;
709 for (cur_size = 1024; cur_size <= PAGE_SIZE; cur_size *= 2) {
710 u_int nseg;
711
712 nseg = cur_size / sizeof(struct scatterlist);
713 if (nseg < AHC_LINUX_MIN_NSEG)
714 continue;
715
716 if (best_size == 0) {
717 best_size = cur_size;
718 ahc_linux_nseg = nseg;
719 } else {
720 u_int best_rem;
721 u_int cur_rem;
722
723 /*
724 * Compare the traits of the current "best_size"
725 * with the current size to determine if the
726 * current size is a better size.
727 */
728 best_rem = best_size % sizeof(struct scatterlist);
729 cur_rem = cur_size % sizeof(struct scatterlist);
730 if (cur_rem < best_rem) {
731 best_size = cur_size;
732 ahc_linux_nseg = nseg;
733 }
734 }
735 }
736#endif
737}
738
739/* 526/*
740 * Try to detect an Adaptec 7XXX controller. 527 * Try to detect an Adaptec 7XXX controller.
741 */ 528 */
742static int 529static int
743ahc_linux_detect(Scsi_Host_Template *template) 530ahc_linux_detect(struct scsi_host_template *template)
744{ 531{
745 struct ahc_softc *ahc; 532 struct ahc_softc *ahc;
746 int found = 0; 533 int found = 0;
747 534
748#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
749 /*
750 * It is a bug that the upper layer takes
751 * this lock just prior to calling us.
752 */
753 spin_unlock_irq(&io_request_lock);
754#endif
755
756 /* 535 /*
757 * Sanity checking of Linux SCSI data structures so 536 * Sanity checking of Linux SCSI data structures so
758 * that some of our hacks^H^H^H^H^Hassumptions aren't 537 * that some of our hacks^H^H^H^H^Hassumptions aren't
@@ -764,7 +543,6 @@ ahc_linux_detect(Scsi_Host_Template *template)
764 printf("ahc_linux_detect: Unable to attach\n"); 543 printf("ahc_linux_detect: Unable to attach\n");
765 return (0); 544 return (0);
766 } 545 }
767 ahc_linux_size_nseg();
768 /* 546 /*
769 * If we've been passed any parameters, process them now. 547 * If we've been passed any parameters, process them now.
770 */ 548 */
@@ -793,48 +571,11 @@ ahc_linux_detect(Scsi_Host_Template *template)
793 found++; 571 found++;
794 } 572 }
795 573
796#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
797 spin_lock_irq(&io_request_lock);
798#endif
799 aic7xxx_detect_complete++; 574 aic7xxx_detect_complete++;
800 575
801 return (found); 576 return (found);
802} 577}
803 578
804#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
805/*
806 * Free the passed in Scsi_Host memory structures prior to unloading the
807 * module.
808 */
809int
810ahc_linux_release(struct Scsi_Host * host)
811{
812 struct ahc_softc *ahc;
813 u_long l;
814
815 ahc_list_lock(&l);
816 if (host != NULL) {
817
818 /*
819 * We should be able to just perform
820 * the free directly, but check our
821 * list for extra sanity.
822 */
823 ahc = ahc_find_softc(*(struct ahc_softc **)host->hostdata);
824 if (ahc != NULL) {
825 u_long s;
826
827 ahc_lock(ahc, &s);
828 ahc_intr_enable(ahc, FALSE);
829 ahc_unlock(ahc, &s);
830 ahc_free(ahc);
831 }
832 }
833 ahc_list_unlock(&l);
834 return (0);
835}
836#endif
837
838/* 579/*
839 * Return a string describing the driver. 580 * Return a string describing the driver.
840 */ 581 */
@@ -867,11 +608,10 @@ ahc_linux_info(struct Scsi_Host *host)
867 * Queue an SCB to the controller. 608 * Queue an SCB to the controller.
868 */ 609 */
869static int 610static int
870ahc_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *)) 611ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *))
871{ 612{
872 struct ahc_softc *ahc; 613 struct ahc_softc *ahc;
873 struct ahc_linux_device *dev; 614 struct ahc_linux_device *dev;
874 u_long flags;
875 615
876 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 616 ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
877 617
@@ -880,205 +620,152 @@ ahc_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *))
880 */ 620 */
881 cmd->scsi_done = scsi_done; 621 cmd->scsi_done = scsi_done;
882 622
883 ahc_midlayer_entrypoint_lock(ahc, &flags);
884
885 /* 623 /*
886 * Close the race of a command that was in the process of 624 * Close the race of a command that was in the process of
887 * being queued to us just as our simq was frozen. Let 625 * being queued to us just as our simq was frozen. Let
888 * DV commands through so long as we are only frozen to 626 * DV commands through so long as we are only frozen to
889 * perform DV. 627 * perform DV.
890 */ 628 */
891 if (ahc->platform_data->qfrozen != 0) { 629 if (ahc->platform_data->qfrozen != 0)
630 return SCSI_MLQUEUE_HOST_BUSY;
892 631
893 ahc_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ);
894 ahc_linux_queue_cmd_complete(ahc, cmd);
895 ahc_schedule_completeq(ahc);
896 ahc_midlayer_entrypoint_unlock(ahc, &flags);
897 return (0);
898 }
899 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id, 632 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id,
900 cmd->device->lun, /*alloc*/TRUE); 633 cmd->device->lun);
901 if (dev == NULL) { 634 BUG_ON(dev == NULL);
902 ahc_cmd_set_transaction_status(cmd, CAM_RESRC_UNAVAIL); 635
903 ahc_linux_queue_cmd_complete(ahc, cmd);
904 ahc_schedule_completeq(ahc);
905 ahc_midlayer_entrypoint_unlock(ahc, &flags);
906 printf("%s: aic7xxx_linux_queue - Unable to allocate device!\n",
907 ahc_name(ahc));
908 return (0);
909 }
910 cmd->result = CAM_REQ_INPROG << 16; 636 cmd->result = CAM_REQ_INPROG << 16;
911 TAILQ_INSERT_TAIL(&dev->busyq, (struct ahc_cmd *)cmd, acmd_links.tqe); 637
912 if ((dev->flags & AHC_DEV_ON_RUN_LIST) == 0) { 638 return ahc_linux_run_command(ahc, dev, cmd);
913 TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, dev, links);
914 dev->flags |= AHC_DEV_ON_RUN_LIST;
915 ahc_linux_run_device_queues(ahc);
916 }
917 ahc_midlayer_entrypoint_unlock(ahc, &flags);
918 return (0);
919} 639}
920 640
921#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
922static int 641static int
923ahc_linux_slave_alloc(Scsi_Device *device) 642ahc_linux_slave_alloc(struct scsi_device *device)
924{ 643{
925 struct ahc_softc *ahc; 644 struct ahc_softc *ahc;
645 struct ahc_linux_target *targ;
646 struct scsi_target *starget = device->sdev_target;
647 struct ahc_linux_device *dev;
648 unsigned int target_offset;
649 unsigned long flags;
650 int retval = -ENOMEM;
651
652 target_offset = starget->id;
653 if (starget->channel != 0)
654 target_offset += 8;
926 655
927 ahc = *((struct ahc_softc **)device->host->hostdata); 656 ahc = *((struct ahc_softc **)device->host->hostdata);
928 if (bootverbose) 657 if (bootverbose)
929 printf("%s: Slave Alloc %d\n", ahc_name(ahc), device->id); 658 printf("%s: Slave Alloc %d\n", ahc_name(ahc), device->id);
930 return (0); 659 ahc_lock(ahc, &flags);
660 targ = ahc->platform_data->targets[target_offset];
661 if (targ == NULL) {
662 struct seeprom_config *sc;
663
664 targ = ahc_linux_alloc_target(ahc, starget->channel,
665 starget->id);
666 sc = ahc->seep_config;
667 if (targ == NULL)
668 goto out;
669
670 if (sc) {
671 unsigned short scsirate;
672 struct ahc_devinfo devinfo;
673 struct ahc_initiator_tinfo *tinfo;
674 struct ahc_tmode_tstate *tstate;
675 char channel = starget->channel + 'A';
676 unsigned int our_id = ahc->our_id;
677
678 if (starget->channel)
679 our_id = ahc->our_id_b;
680
681 if ((ahc->features & AHC_ULTRA2) != 0) {
682 scsirate = sc->device_flags[target_offset] & CFXFER;
683 } else {
684 scsirate = (sc->device_flags[target_offset] & CFXFER) << 4;
685 if (sc->device_flags[target_offset] & CFSYNCH)
686 scsirate |= SOFS;
687 }
688 if (sc->device_flags[target_offset] & CFWIDEB) {
689 scsirate |= WIDEXFER;
690 spi_max_width(starget) = 1;
691 } else
692 spi_max_width(starget) = 0;
693 spi_min_period(starget) =
694 ahc_find_period(ahc, scsirate, AHC_SYNCRATE_DT);
695 tinfo = ahc_fetch_transinfo(ahc, channel, ahc->our_id,
696 targ->target, &tstate);
697 ahc_compile_devinfo(&devinfo, our_id, targ->target,
698 CAM_LUN_WILDCARD, channel,
699 ROLE_INITIATOR);
700 ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0,
701 AHC_TRANS_GOAL, /*paused*/FALSE);
702 ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
703 AHC_TRANS_GOAL, /*paused*/FALSE);
704 }
705
706 }
707 dev = targ->devices[device->lun];
708 if (dev == NULL) {
709 dev = ahc_linux_alloc_device(ahc, targ, device->lun);
710 if (dev == NULL)
711 goto out;
712 }
713 retval = 0;
714
715 out:
716 ahc_unlock(ahc, &flags);
717 return retval;
931} 718}
932 719
933static int 720static int
934ahc_linux_slave_configure(Scsi_Device *device) 721ahc_linux_slave_configure(struct scsi_device *device)
935{ 722{
936 struct ahc_softc *ahc; 723 struct ahc_softc *ahc;
937 struct ahc_linux_device *dev; 724 struct ahc_linux_device *dev;
938 u_long flags;
939 725
940 ahc = *((struct ahc_softc **)device->host->hostdata); 726 ahc = *((struct ahc_softc **)device->host->hostdata);
727
941 if (bootverbose) 728 if (bootverbose)
942 printf("%s: Slave Configure %d\n", ahc_name(ahc), device->id); 729 printf("%s: Slave Configure %d\n", ahc_name(ahc), device->id);
943 ahc_midlayer_entrypoint_lock(ahc, &flags); 730
944 /* 731 dev = ahc_linux_get_device(ahc, device->channel, device->id,
945 * Since Linux has attached to the device, configure 732 device->lun);
946 * it so we don't free and allocate the device 733 dev->scsi_device = device;
947 * structure on every command. 734 ahc_linux_device_queue_depth(ahc, dev);
948 */
949 dev = ahc_linux_get_device(ahc, device->channel,
950 device->id, device->lun,
951 /*alloc*/TRUE);
952 if (dev != NULL) {
953 dev->flags &= ~AHC_DEV_UNCONFIGURED;
954 dev->scsi_device = device;
955 ahc_linux_device_queue_depth(ahc, dev);
956 }
957 ahc_midlayer_entrypoint_unlock(ahc, &flags);
958 735
959 /* Initial Domain Validation */ 736 /* Initial Domain Validation */
960 if (!spi_initial_dv(device->sdev_target)) 737 if (!spi_initial_dv(device->sdev_target))
961 spi_dv_device(device); 738 spi_dv_device(device);
962 739
963 return (0); 740 return 0;
964} 741}
965 742
966static void 743static void
967ahc_linux_slave_destroy(Scsi_Device *device) 744ahc_linux_slave_destroy(struct scsi_device *device)
968{ 745{
969 struct ahc_softc *ahc; 746 struct ahc_softc *ahc;
970 struct ahc_linux_device *dev; 747 struct ahc_linux_device *dev;
971 u_long flags;
972 748
973 ahc = *((struct ahc_softc **)device->host->hostdata); 749 ahc = *((struct ahc_softc **)device->host->hostdata);
974 if (bootverbose) 750 if (bootverbose)
975 printf("%s: Slave Destroy %d\n", ahc_name(ahc), device->id); 751 printf("%s: Slave Destroy %d\n", ahc_name(ahc), device->id);
976 ahc_midlayer_entrypoint_lock(ahc, &flags);
977 dev = ahc_linux_get_device(ahc, device->channel, 752 dev = ahc_linux_get_device(ahc, device->channel,
978 device->id, device->lun, 753 device->id, device->lun);
979 /*alloc*/FALSE);
980 /*
981 * Filter out "silly" deletions of real devices by only
982 * deleting devices that have had slave_configure()
983 * called on them. All other devices that have not
984 * been configured will automatically be deleted by
985 * the refcounting process.
986 */
987 if (dev != NULL
988 && (dev->flags & AHC_DEV_SLAVE_CONFIGURED) != 0) {
989 dev->flags |= AHC_DEV_UNCONFIGURED;
990 if (TAILQ_EMPTY(&dev->busyq)
991 && dev->active == 0
992 && (dev->flags & AHC_DEV_TIMER_ACTIVE) == 0)
993 ahc_linux_free_device(ahc, dev);
994 }
995 ahc_midlayer_entrypoint_unlock(ahc, &flags);
996}
997#else
998/*
999 * Sets the queue depth for each SCSI device hanging
1000 * off the input host adapter.
1001 */
1002static void
1003ahc_linux_select_queue_depth(struct Scsi_Host *host, Scsi_Device *scsi_devs)
1004{
1005 Scsi_Device *device;
1006 Scsi_Device *ldev;
1007 struct ahc_softc *ahc;
1008 u_long flags;
1009 754
1010 ahc = *((struct ahc_softc **)host->hostdata); 755 BUG_ON(dev->active);
1011 ahc_lock(ahc, &flags);
1012 for (device = scsi_devs; device != NULL; device = device->next) {
1013 756
1014 /* 757 ahc_linux_free_device(ahc, dev);
1015 * Watch out for duplicate devices. This works around
1016 * some quirks in how the SCSI scanning code does its
1017 * device management.
1018 */
1019 for (ldev = scsi_devs; ldev != device; ldev = ldev->next) {
1020 if (ldev->host == device->host
1021 && ldev->channel == device->channel
1022 && ldev->id == device->id
1023 && ldev->lun == device->lun)
1024 break;
1025 }
1026 /* Skip duplicate. */
1027 if (ldev != device)
1028 continue;
1029
1030 if (device->host == host) {
1031 struct ahc_linux_device *dev;
1032
1033 /*
1034 * Since Linux has attached to the device, configure
1035 * it so we don't free and allocate the device
1036 * structure on every command.
1037 */
1038 dev = ahc_linux_get_device(ahc, device->channel,
1039 device->id, device->lun,
1040 /*alloc*/TRUE);
1041 if (dev != NULL) {
1042 dev->flags &= ~AHC_DEV_UNCONFIGURED;
1043 dev->scsi_device = device;
1044 ahc_linux_device_queue_depth(ahc, dev);
1045 device->queue_depth = dev->openings
1046 + dev->active;
1047 if ((dev->flags & (AHC_DEV_Q_BASIC
1048 | AHC_DEV_Q_TAGGED)) == 0) {
1049 /*
1050 * We allow the OS to queue 2 untagged
1051 * transactions to us at any time even
1052 * though we can only execute them
1053 * serially on the controller/device.
1054 * This should remove some latency.
1055 */
1056 device->queue_depth = 2;
1057 }
1058 }
1059 }
1060 }
1061 ahc_unlock(ahc, &flags);
1062} 758}
1063#endif
1064 759
1065#if defined(__i386__) 760#if defined(__i386__)
1066/* 761/*
1067 * Return the disk geometry for the given SCSI device. 762 * Return the disk geometry for the given SCSI device.
1068 */ 763 */
1069static int 764static int
1070#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
1071ahc_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev, 765ahc_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev,
1072 sector_t capacity, int geom[]) 766 sector_t capacity, int geom[])
1073{ 767{
1074 uint8_t *bh; 768 uint8_t *bh;
1075#else
1076ahc_linux_biosparam(Disk *disk, kdev_t dev, int geom[])
1077{
1078 struct scsi_device *sdev = disk->device;
1079 u_long capacity = disk->capacity;
1080 struct buffer_head *bh;
1081#endif
1082 int heads; 769 int heads;
1083 int sectors; 770 int sectors;
1084 int cylinders; 771 int cylinders;
@@ -1090,22 +777,11 @@ ahc_linux_biosparam(Disk *disk, kdev_t dev, int geom[])
1090 ahc = *((struct ahc_softc **)sdev->host->hostdata); 777 ahc = *((struct ahc_softc **)sdev->host->hostdata);
1091 channel = sdev->channel; 778 channel = sdev->channel;
1092 779
1093#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
1094 bh = scsi_bios_ptable(bdev); 780 bh = scsi_bios_ptable(bdev);
1095#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17)
1096 bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, block_size(dev));
1097#else
1098 bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, 1024);
1099#endif
1100
1101 if (bh) { 781 if (bh) {
1102 ret = scsi_partsize(bh, capacity, 782 ret = scsi_partsize(bh, capacity,
1103 &geom[2], &geom[0], &geom[1]); 783 &geom[2], &geom[0], &geom[1]);
1104#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
1105 kfree(bh); 784 kfree(bh);
1106#else
1107 brelse(bh);
1108#endif
1109 if (ret != -1) 785 if (ret != -1)
1110 return (ret); 786 return (ret);
1111 } 787 }
@@ -1135,7 +811,7 @@ ahc_linux_biosparam(Disk *disk, kdev_t dev, int geom[])
1135 * Abort the current SCSI command(s). 811 * Abort the current SCSI command(s).
1136 */ 812 */
1137static int 813static int
1138ahc_linux_abort(Scsi_Cmnd *cmd) 814ahc_linux_abort(struct scsi_cmnd *cmd)
1139{ 815{
1140 int error; 816 int error;
1141 817
@@ -1149,7 +825,7 @@ ahc_linux_abort(Scsi_Cmnd *cmd)
1149 * Attempt to send a target reset message to the device that timed out. 825 * Attempt to send a target reset message to the device that timed out.
1150 */ 826 */
1151static int 827static int
1152ahc_linux_dev_reset(Scsi_Cmnd *cmd) 828ahc_linux_dev_reset(struct scsi_cmnd *cmd)
1153{ 829{
1154 int error; 830 int error;
1155 831
@@ -1163,18 +839,14 @@ ahc_linux_dev_reset(Scsi_Cmnd *cmd)
1163 * Reset the SCSI bus. 839 * Reset the SCSI bus.
1164 */ 840 */
1165static int 841static int
1166ahc_linux_bus_reset(Scsi_Cmnd *cmd) 842ahc_linux_bus_reset(struct scsi_cmnd *cmd)
1167{ 843{
1168 struct ahc_softc *ahc; 844 struct ahc_softc *ahc;
1169 u_long s;
1170 int found; 845 int found;
1171 846
1172 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 847 ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
1173 ahc_midlayer_entrypoint_lock(ahc, &s);
1174 found = ahc_reset_channel(ahc, cmd->device->channel + 'A', 848 found = ahc_reset_channel(ahc, cmd->device->channel + 'A',
1175 /*initiate reset*/TRUE); 849 /*initiate reset*/TRUE);
1176 ahc_linux_run_complete_queue(ahc);
1177 ahc_midlayer_entrypoint_unlock(ahc, &s);
1178 850
1179 if (bootverbose) 851 if (bootverbose)
1180 printf("%s: SCSI bus reset delivered. " 852 printf("%s: SCSI bus reset delivered. "
@@ -1183,7 +855,7 @@ ahc_linux_bus_reset(Scsi_Cmnd *cmd)
1183 return SUCCESS; 855 return SUCCESS;
1184} 856}
1185 857
1186Scsi_Host_Template aic7xxx_driver_template = { 858struct scsi_host_template aic7xxx_driver_template = {
1187 .module = THIS_MODULE, 859 .module = THIS_MODULE,
1188 .name = "aic7xxx", 860 .name = "aic7xxx",
1189 .proc_info = ahc_linux_proc_info, 861 .proc_info = ahc_linux_proc_info,
@@ -1206,33 +878,6 @@ Scsi_Host_Template aic7xxx_driver_template = {
1206 878
1207/**************************** Tasklet Handler *********************************/ 879/**************************** Tasklet Handler *********************************/
1208 880
1209/*
1210 * In 2.4.X and above, this routine is called from a tasklet,
1211 * so we must re-acquire our lock prior to executing this code.
1212 * In all prior kernels, ahc_schedule_runq() calls this routine
1213 * directly and ahc_schedule_runq() is called with our lock held.
1214 */
1215static void
1216ahc_runq_tasklet(unsigned long data)
1217{
1218 struct ahc_softc* ahc;
1219 struct ahc_linux_device *dev;
1220 u_long flags;
1221
1222 ahc = (struct ahc_softc *)data;
1223 ahc_lock(ahc, &flags);
1224 while ((dev = ahc_linux_next_device_to_run(ahc)) != NULL) {
1225
1226 TAILQ_REMOVE(&ahc->platform_data->device_runq, dev, links);
1227 dev->flags &= ~AHC_DEV_ON_RUN_LIST;
1228 ahc_linux_check_device_queue(ahc, dev);
1229 /* Yeild to our interrupt handler */
1230 ahc_unlock(ahc, &flags);
1231 ahc_lock(ahc, &flags);
1232 }
1233 ahc_unlock(ahc, &flags);
1234}
1235
1236/******************************** Macros **************************************/ 881/******************************** Macros **************************************/
1237#define BUILD_SCSIID(ahc, cmd) \ 882#define BUILD_SCSIID(ahc, cmd) \
1238 ((((cmd)->device->id << TID_SHIFT) & TID) \ 883 ((((cmd)->device->id << TID_SHIFT) & TID) \
@@ -1278,37 +923,11 @@ int
1278ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr, 923ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr,
1279 int flags, bus_dmamap_t *mapp) 924 int flags, bus_dmamap_t *mapp)
1280{ 925{
1281 bus_dmamap_t map;
1282
1283 map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT);
1284 if (map == NULL)
1285 return (ENOMEM);
1286 /*
1287 * Although we can dma data above 4GB, our
1288 * "consistent" memory is below 4GB for
1289 * space efficiency reasons (only need a 4byte
1290 * address). For this reason, we have to reset
1291 * our dma mask when doing allocations.
1292 */
1293 if (ahc->dev_softc != NULL)
1294 if (pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF)) {
1295 printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
1296 kfree(map);
1297 return (ENODEV);
1298 }
1299 *vaddr = pci_alloc_consistent(ahc->dev_softc, 926 *vaddr = pci_alloc_consistent(ahc->dev_softc,
1300 dmat->maxsize, &map->bus_addr); 927 dmat->maxsize, mapp);
1301 if (ahc->dev_softc != NULL)
1302 if (pci_set_dma_mask(ahc->dev_softc,
1303 ahc->platform_data->hw_dma_mask)) {
1304 printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
1305 kfree(map);
1306 return (ENODEV);
1307 }
1308 if (*vaddr == NULL) 928 if (*vaddr == NULL)
1309 return (ENOMEM); 929 return ENOMEM;
1310 *mapp = map; 930 return 0;
1311 return(0);
1312} 931}
1313 932
1314void 933void
@@ -1316,7 +935,7 @@ ahc_dmamem_free(struct ahc_softc *ahc, bus_dma_tag_t dmat,
1316 void* vaddr, bus_dmamap_t map) 935 void* vaddr, bus_dmamap_t map)
1317{ 936{
1318 pci_free_consistent(ahc->dev_softc, dmat->maxsize, 937 pci_free_consistent(ahc->dev_softc, dmat->maxsize,
1319 vaddr, map->bus_addr); 938 vaddr, map);
1320} 939}
1321 940
1322int 941int
@@ -1330,7 +949,7 @@ ahc_dmamap_load(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map,
1330 */ 949 */
1331 bus_dma_segment_t stack_sg; 950 bus_dma_segment_t stack_sg;
1332 951
1333 stack_sg.ds_addr = map->bus_addr; 952 stack_sg.ds_addr = map;
1334 stack_sg.ds_len = dmat->maxsize; 953 stack_sg.ds_len = dmat->maxsize;
1335 cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0); 954 cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0);
1336 return (0); 955 return (0);
@@ -1339,12 +958,6 @@ ahc_dmamap_load(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map,
1339void 958void
1340ahc_dmamap_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map) 959ahc_dmamap_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map)
1341{ 960{
1342 /*
1343 * The map may is NULL in our < 2.3.X implementation.
1344 * Now it's 2.6.5, but just in case...
1345 */
1346 BUG_ON(map == NULL);
1347 free(map, M_DEVBUF);
1348} 961}
1349 962
1350int 963int
@@ -1550,7 +1163,7 @@ __setup("aic7xxx=", aic7xxx_setup);
1550uint32_t aic7xxx_verbose; 1163uint32_t aic7xxx_verbose;
1551 1164
1552int 1165int
1553ahc_linux_register_host(struct ahc_softc *ahc, Scsi_Host_Template *template) 1166ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *template)
1554{ 1167{
1555 char buf[80]; 1168 char buf[80];
1556 struct Scsi_Host *host; 1169 struct Scsi_Host *host;
@@ -1564,11 +1177,7 @@ ahc_linux_register_host(struct ahc_softc *ahc, Scsi_Host_Template *template)
1564 1177
1565 *((struct ahc_softc **)host->hostdata) = ahc; 1178 *((struct ahc_softc **)host->hostdata) = ahc;
1566 ahc_lock(ahc, &s); 1179 ahc_lock(ahc, &s);
1567#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
1568 scsi_assign_lock(host, &ahc->platform_data->spin_lock); 1180 scsi_assign_lock(host, &ahc->platform_data->spin_lock);
1569#elif AHC_SCSI_HAS_HOST_LOCK != 0
1570 host->lock = &ahc->platform_data->spin_lock;
1571#endif
1572 ahc->platform_data->host = host; 1181 ahc->platform_data->host = host;
1573 host->can_queue = AHC_MAX_QUEUE; 1182 host->can_queue = AHC_MAX_QUEUE;
1574 host->cmd_per_lun = 2; 1183 host->cmd_per_lun = 2;
@@ -1587,19 +1196,14 @@ ahc_linux_register_host(struct ahc_softc *ahc, Scsi_Host_Template *template)
1587 ahc_set_name(ahc, new_name); 1196 ahc_set_name(ahc, new_name);
1588 } 1197 }
1589 host->unique_id = ahc->unit; 1198 host->unique_id = ahc->unit;
1590#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
1591 scsi_set_pci_device(host, ahc->dev_softc);
1592#endif
1593 ahc_linux_initialize_scsi_bus(ahc); 1199 ahc_linux_initialize_scsi_bus(ahc);
1594 ahc_intr_enable(ahc, TRUE); 1200 ahc_intr_enable(ahc, TRUE);
1595 ahc_unlock(ahc, &s); 1201 ahc_unlock(ahc, &s);
1596 1202
1597 host->transportt = ahc_linux_transport_template; 1203 host->transportt = ahc_linux_transport_template;
1598 1204
1599#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
1600 scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); /* XXX handle failure */ 1205 scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); /* XXX handle failure */
1601 scsi_scan_host(host); 1206 scsi_scan_host(host);
1602#endif
1603 return (0); 1207 return (0);
1604} 1208}
1605 1209
@@ -1717,19 +1321,9 @@ ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg)
1717 if (ahc->platform_data == NULL) 1321 if (ahc->platform_data == NULL)
1718 return (ENOMEM); 1322 return (ENOMEM);
1719 memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data)); 1323 memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data));
1720 TAILQ_INIT(&ahc->platform_data->completeq);
1721 TAILQ_INIT(&ahc->platform_data->device_runq);
1722 ahc->platform_data->irq = AHC_LINUX_NOIRQ; 1324 ahc->platform_data->irq = AHC_LINUX_NOIRQ;
1723 ahc->platform_data->hw_dma_mask = 0xFFFFFFFF;
1724 ahc_lockinit(ahc); 1325 ahc_lockinit(ahc);
1725 ahc_done_lockinit(ahc);
1726 init_timer(&ahc->platform_data->completeq_timer);
1727 ahc->platform_data->completeq_timer.data = (u_long)ahc;
1728 ahc->platform_data->completeq_timer.function =
1729 (ahc_linux_callback_t *)ahc_linux_thread_run_complete_queue;
1730 init_MUTEX_LOCKED(&ahc->platform_data->eh_sem); 1326 init_MUTEX_LOCKED(&ahc->platform_data->eh_sem);
1731 tasklet_init(&ahc->platform_data->runq_tasklet, ahc_runq_tasklet,
1732 (unsigned long)ahc);
1733 ahc->seltime = (aic7xxx_seltime & 0x3) << 4; 1327 ahc->seltime = (aic7xxx_seltime & 0x3) << 4;
1734 ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4; 1328 ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4;
1735 if (aic7xxx_pci_parity == 0) 1329 if (aic7xxx_pci_parity == 0)
@@ -1746,12 +1340,8 @@ ahc_platform_free(struct ahc_softc *ahc)
1746 int i, j; 1340 int i, j;
1747 1341
1748 if (ahc->platform_data != NULL) { 1342 if (ahc->platform_data != NULL) {
1749 del_timer_sync(&ahc->platform_data->completeq_timer);
1750 tasklet_kill(&ahc->platform_data->runq_tasklet);
1751 if (ahc->platform_data->host != NULL) { 1343 if (ahc->platform_data->host != NULL) {
1752#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
1753 scsi_remove_host(ahc->platform_data->host); 1344 scsi_remove_host(ahc->platform_data->host);
1754#endif
1755 scsi_host_put(ahc->platform_data->host); 1345 scsi_host_put(ahc->platform_data->host);
1756 } 1346 }
1757 1347
@@ -1787,16 +1377,7 @@ ahc_platform_free(struct ahc_softc *ahc)
1787 release_mem_region(ahc->platform_data->mem_busaddr, 1377 release_mem_region(ahc->platform_data->mem_busaddr,
1788 0x1000); 1378 0x1000);
1789 } 1379 }
1790#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 1380
1791 /*
1792 * In 2.4 we detach from the scsi midlayer before the PCI
1793 * layer invokes our remove callback. No per-instance
1794 * detach is provided, so we must reach inside the PCI
1795 * subsystem's internals and detach our driver manually.
1796 */
1797 if (ahc->dev_softc != NULL)
1798 ahc->dev_softc->driver = NULL;
1799#endif
1800 free(ahc->platform_data, M_DEVBUF); 1381 free(ahc->platform_data, M_DEVBUF);
1801 } 1382 }
1802} 1383}
@@ -1820,7 +1401,7 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
1820 1401
1821 dev = ahc_linux_get_device(ahc, devinfo->channel - 'A', 1402 dev = ahc_linux_get_device(ahc, devinfo->channel - 'A',
1822 devinfo->target, 1403 devinfo->target,
1823 devinfo->lun, /*alloc*/FALSE); 1404 devinfo->lun);
1824 if (dev == NULL) 1405 if (dev == NULL)
1825 return; 1406 return;
1826 was_queuing = dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED); 1407 was_queuing = dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED);
@@ -1873,7 +1454,6 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
1873 dev->maxtags = 0; 1454 dev->maxtags = 0;
1874 dev->openings = 1 - dev->active; 1455 dev->openings = 1 - dev->active;
1875 } 1456 }
1876#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
1877 if (dev->scsi_device != NULL) { 1457 if (dev->scsi_device != NULL) {
1878 switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) { 1458 switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) {
1879 case AHC_DEV_Q_BASIC: 1459 case AHC_DEV_Q_BASIC:
@@ -1899,90 +1479,13 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
1899 break; 1479 break;
1900 } 1480 }
1901 } 1481 }
1902#endif
1903} 1482}
1904 1483
1905int 1484int
1906ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, char channel, 1485ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, char channel,
1907 int lun, u_int tag, role_t role, uint32_t status) 1486 int lun, u_int tag, role_t role, uint32_t status)
1908{ 1487{
1909 int chan; 1488 return 0;
1910 int maxchan;
1911 int targ;
1912 int maxtarg;
1913 int clun;
1914 int maxlun;
1915 int count;
1916
1917 if (tag != SCB_LIST_NULL)
1918 return (0);
1919
1920 chan = 0;
1921 if (channel != ALL_CHANNELS) {
1922 chan = channel - 'A';
1923 maxchan = chan + 1;
1924 } else {
1925 maxchan = (ahc->features & AHC_TWIN) ? 2 : 1;
1926 }
1927 targ = 0;
1928 if (target != CAM_TARGET_WILDCARD) {
1929 targ = target;
1930 maxtarg = targ + 1;
1931 } else {
1932 maxtarg = (ahc->features & AHC_WIDE) ? 16 : 8;
1933 }
1934 clun = 0;
1935 if (lun != CAM_LUN_WILDCARD) {
1936 clun = lun;
1937 maxlun = clun + 1;
1938 } else {
1939 maxlun = AHC_NUM_LUNS;
1940 }
1941
1942 count = 0;
1943 for (; chan < maxchan; chan++) {
1944
1945 for (; targ < maxtarg; targ++) {
1946
1947 for (; clun < maxlun; clun++) {
1948 struct ahc_linux_device *dev;
1949 struct ahc_busyq *busyq;
1950 struct ahc_cmd *acmd;
1951
1952 dev = ahc_linux_get_device(ahc, chan,
1953 targ, clun,
1954 /*alloc*/FALSE);
1955 if (dev == NULL)
1956 continue;
1957
1958 busyq = &dev->busyq;
1959 while ((acmd = TAILQ_FIRST(busyq)) != NULL) {
1960 Scsi_Cmnd *cmd;
1961
1962 cmd = &acmd_scsi_cmd(acmd);
1963 TAILQ_REMOVE(busyq, acmd,
1964 acmd_links.tqe);
1965 count++;
1966 cmd->result = status << 16;
1967 ahc_linux_queue_cmd_complete(ahc, cmd);
1968 }
1969 }
1970 }
1971 }
1972
1973 return (count);
1974}
1975
1976static void
1977ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc)
1978{
1979 u_long flags;
1980
1981 ahc_lock(ahc, &flags);
1982 del_timer(&ahc->platform_data->completeq_timer);
1983 ahc->platform_data->flags &= ~AHC_RUN_CMPLT_Q_TIMER;
1984 ahc_linux_run_complete_queue(ahc);
1985 ahc_unlock(ahc, &flags);
1986} 1489}
1987 1490
1988static u_int 1491static u_int
@@ -2045,213 +1548,200 @@ ahc_linux_device_queue_depth(struct ahc_softc *ahc,
2045 } 1548 }
2046} 1549}
2047 1550
2048static void 1551static int
2049ahc_linux_run_device_queue(struct ahc_softc *ahc, struct ahc_linux_device *dev) 1552ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
1553 struct scsi_cmnd *cmd)
2050{ 1554{
2051 struct ahc_cmd *acmd;
2052 struct scsi_cmnd *cmd;
2053 struct scb *scb; 1555 struct scb *scb;
2054 struct hardware_scb *hscb; 1556 struct hardware_scb *hscb;
2055 struct ahc_initiator_tinfo *tinfo; 1557 struct ahc_initiator_tinfo *tinfo;
2056 struct ahc_tmode_tstate *tstate; 1558 struct ahc_tmode_tstate *tstate;
2057 uint16_t mask; 1559 uint16_t mask;
1560 struct scb_tailq *untagged_q = NULL;
2058 1561
2059 if ((dev->flags & AHC_DEV_ON_RUN_LIST) != 0) 1562 /*
2060 panic("running device on run list"); 1563 * Schedule us to run later. The only reason we are not
1564 * running is because the whole controller Q is frozen.
1565 */
1566 if (ahc->platform_data->qfrozen != 0)
1567 return SCSI_MLQUEUE_HOST_BUSY;
2061 1568
2062 while ((acmd = TAILQ_FIRST(&dev->busyq)) != NULL 1569 /*
2063 && dev->openings > 0 && dev->qfrozen == 0) { 1570 * We only allow one untagged transaction
1571 * per target in the initiator role unless
1572 * we are storing a full busy target *lun*
1573 * table in SCB space.
1574 */
1575 if (!blk_rq_tagged(cmd->request)
1576 && (ahc->features & AHC_SCB_BTT) == 0) {
1577 int target_offset;
2064 1578
2065 /* 1579 target_offset = cmd->device->id + cmd->device->channel * 8;
2066 * Schedule us to run later. The only reason we are not 1580 untagged_q = &(ahc->untagged_queues[target_offset]);
2067 * running is because the whole controller Q is frozen. 1581 if (!TAILQ_EMPTY(untagged_q))
2068 */ 1582 /* if we're already executing an untagged command
2069 if (ahc->platform_data->qfrozen != 0) { 1583 * we're busy to another */
2070 TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, 1584 return SCSI_MLQUEUE_DEVICE_BUSY;
2071 dev, links); 1585 }
2072 dev->flags |= AHC_DEV_ON_RUN_LIST;
2073 return;
2074 }
2075 /*
2076 * Get an scb to use.
2077 */
2078 if ((scb = ahc_get_scb(ahc)) == NULL) {
2079 TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq,
2080 dev, links);
2081 dev->flags |= AHC_DEV_ON_RUN_LIST;
2082 ahc->flags |= AHC_RESOURCE_SHORTAGE;
2083 return;
2084 }
2085 TAILQ_REMOVE(&dev->busyq, acmd, acmd_links.tqe);
2086 cmd = &acmd_scsi_cmd(acmd);
2087 scb->io_ctx = cmd;
2088 scb->platform_data->dev = dev;
2089 hscb = scb->hscb;
2090 cmd->host_scribble = (char *)scb;
2091 1586
2092 /* 1587 /*
2093 * Fill out basics of the HSCB. 1588 * Get an scb to use.
2094 */ 1589 */
2095 hscb->control = 0; 1590 if ((scb = ahc_get_scb(ahc)) == NULL) {
2096 hscb->scsiid = BUILD_SCSIID(ahc, cmd); 1591 ahc->flags |= AHC_RESOURCE_SHORTAGE;
2097 hscb->lun = cmd->device->lun; 1592 return SCSI_MLQUEUE_HOST_BUSY;
2098 mask = SCB_GET_TARGET_MASK(ahc, scb); 1593 }
2099 tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb),
2100 SCB_GET_OUR_ID(scb),
2101 SCB_GET_TARGET(ahc, scb), &tstate);
2102 hscb->scsirate = tinfo->scsirate;
2103 hscb->scsioffset = tinfo->curr.offset;
2104 if ((tstate->ultraenb & mask) != 0)
2105 hscb->control |= ULTRAENB;
2106
2107 if ((ahc->user_discenable & mask) != 0)
2108 hscb->control |= DISCENB;
2109
2110 if ((tstate->auto_negotiate & mask) != 0) {
2111 scb->flags |= SCB_AUTO_NEGOTIATE;
2112 scb->hscb->control |= MK_MESSAGE;
2113 }
2114 1594
2115 if ((dev->flags & (AHC_DEV_Q_TAGGED|AHC_DEV_Q_BASIC)) != 0) { 1595 scb->io_ctx = cmd;
2116#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1596 scb->platform_data->dev = dev;
2117 int msg_bytes; 1597 hscb = scb->hscb;
2118 uint8_t tag_msgs[2]; 1598 cmd->host_scribble = (char *)scb;
2119 1599
2120 msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs); 1600 /*
2121 if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) { 1601 * Fill out basics of the HSCB.
2122 hscb->control |= tag_msgs[0]; 1602 */
2123 if (tag_msgs[0] == MSG_ORDERED_TASK) 1603 hscb->control = 0;
2124 dev->commands_since_idle_or_otag = 0; 1604 hscb->scsiid = BUILD_SCSIID(ahc, cmd);
2125 } else 1605 hscb->lun = cmd->device->lun;
2126#endif 1606 mask = SCB_GET_TARGET_MASK(ahc, scb);
2127 if (dev->commands_since_idle_or_otag == AHC_OTAG_THRESH 1607 tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb),
2128 && (dev->flags & AHC_DEV_Q_TAGGED) != 0) { 1608 SCB_GET_OUR_ID(scb),
2129 hscb->control |= MSG_ORDERED_TASK; 1609 SCB_GET_TARGET(ahc, scb), &tstate);
1610 hscb->scsirate = tinfo->scsirate;
1611 hscb->scsioffset = tinfo->curr.offset;
1612 if ((tstate->ultraenb & mask) != 0)
1613 hscb->control |= ULTRAENB;
1614
1615 if ((ahc->user_discenable & mask) != 0)
1616 hscb->control |= DISCENB;
1617
1618 if ((tstate->auto_negotiate & mask) != 0) {
1619 scb->flags |= SCB_AUTO_NEGOTIATE;
1620 scb->hscb->control |= MK_MESSAGE;
1621 }
1622
1623 if ((dev->flags & (AHC_DEV_Q_TAGGED|AHC_DEV_Q_BASIC)) != 0) {
1624 int msg_bytes;
1625 uint8_t tag_msgs[2];
1626
1627 msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs);
1628 if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) {
1629 hscb->control |= tag_msgs[0];
1630 if (tag_msgs[0] == MSG_ORDERED_TASK)
2130 dev->commands_since_idle_or_otag = 0; 1631 dev->commands_since_idle_or_otag = 0;
2131 } else { 1632 } else if (dev->commands_since_idle_or_otag == AHC_OTAG_THRESH
2132 hscb->control |= MSG_SIMPLE_TASK; 1633 && (dev->flags & AHC_DEV_Q_TAGGED) != 0) {
2133 } 1634 hscb->control |= MSG_ORDERED_TASK;
2134 } 1635 dev->commands_since_idle_or_otag = 0;
2135
2136 hscb->cdb_len = cmd->cmd_len;
2137 if (hscb->cdb_len <= 12) {
2138 memcpy(hscb->shared_data.cdb, cmd->cmnd, hscb->cdb_len);
2139 } else { 1636 } else {
2140 memcpy(hscb->cdb32, cmd->cmnd, hscb->cdb_len); 1637 hscb->control |= MSG_SIMPLE_TASK;
2141 scb->flags |= SCB_CDB32_PTR;
2142 } 1638 }
1639 }
2143 1640
2144 scb->platform_data->xfer_len = 0; 1641 hscb->cdb_len = cmd->cmd_len;
2145 ahc_set_residual(scb, 0); 1642 if (hscb->cdb_len <= 12) {
2146 ahc_set_sense_residual(scb, 0); 1643 memcpy(hscb->shared_data.cdb, cmd->cmnd, hscb->cdb_len);
2147 scb->sg_count = 0; 1644 } else {
2148 if (cmd->use_sg != 0) { 1645 memcpy(hscb->cdb32, cmd->cmnd, hscb->cdb_len);
2149 struct ahc_dma_seg *sg; 1646 scb->flags |= SCB_CDB32_PTR;
2150 struct scatterlist *cur_seg; 1647 }
2151 struct scatterlist *end_seg;
2152 int nseg;
2153
2154 cur_seg = (struct scatterlist *)cmd->request_buffer;
2155 nseg = pci_map_sg(ahc->dev_softc, cur_seg, cmd->use_sg,
2156 cmd->sc_data_direction);
2157 end_seg = cur_seg + nseg;
2158 /* Copy the segments into the SG list. */
2159 sg = scb->sg_list;
2160 /*
2161 * The sg_count may be larger than nseg if
2162 * a transfer crosses a 32bit page.
2163 */
2164 while (cur_seg < end_seg) {
2165 dma_addr_t addr;
2166 bus_size_t len;
2167 int consumed;
2168
2169 addr = sg_dma_address(cur_seg);
2170 len = sg_dma_len(cur_seg);
2171 consumed = ahc_linux_map_seg(ahc, scb,
2172 sg, addr, len);
2173 sg += consumed;
2174 scb->sg_count += consumed;
2175 cur_seg++;
2176 }
2177 sg--;
2178 sg->len |= ahc_htole32(AHC_DMA_LAST_SEG);
2179
2180 /*
2181 * Reset the sg list pointer.
2182 */
2183 scb->hscb->sgptr =
2184 ahc_htole32(scb->sg_list_phys | SG_FULL_RESID);
2185 1648
2186 /* 1649 scb->platform_data->xfer_len = 0;
2187 * Copy the first SG into the "current" 1650 ahc_set_residual(scb, 0);
2188 * data pointer area. 1651 ahc_set_sense_residual(scb, 0);
2189 */ 1652 scb->sg_count = 0;
2190 scb->hscb->dataptr = scb->sg_list->addr; 1653 if (cmd->use_sg != 0) {
2191 scb->hscb->datacnt = scb->sg_list->len; 1654 struct ahc_dma_seg *sg;
2192 } else if (cmd->request_bufflen != 0) { 1655 struct scatterlist *cur_seg;
2193 struct ahc_dma_seg *sg; 1656 struct scatterlist *end_seg;
1657 int nseg;
1658
1659 cur_seg = (struct scatterlist *)cmd->request_buffer;
1660 nseg = pci_map_sg(ahc->dev_softc, cur_seg, cmd->use_sg,
1661 cmd->sc_data_direction);
1662 end_seg = cur_seg + nseg;
1663 /* Copy the segments into the SG list. */
1664 sg = scb->sg_list;
1665 /*
1666 * The sg_count may be larger than nseg if
1667 * a transfer crosses a 32bit page.
1668 */
1669 while (cur_seg < end_seg) {
2194 dma_addr_t addr; 1670 dma_addr_t addr;
2195 1671 bus_size_t len;
2196 sg = scb->sg_list; 1672 int consumed;
2197 addr = pci_map_single(ahc->dev_softc, 1673
2198 cmd->request_buffer, 1674 addr = sg_dma_address(cur_seg);
2199 cmd->request_bufflen, 1675 len = sg_dma_len(cur_seg);
2200 cmd->sc_data_direction); 1676 consumed = ahc_linux_map_seg(ahc, scb,
2201 scb->platform_data->buf_busaddr = addr; 1677 sg, addr, len);
2202 scb->sg_count = ahc_linux_map_seg(ahc, scb, 1678 sg += consumed;
2203 sg, addr, 1679 scb->sg_count += consumed;
2204 cmd->request_bufflen); 1680 cur_seg++;
2205 sg->len |= ahc_htole32(AHC_DMA_LAST_SEG);
2206
2207 /*
2208 * Reset the sg list pointer.
2209 */
2210 scb->hscb->sgptr =
2211 ahc_htole32(scb->sg_list_phys | SG_FULL_RESID);
2212
2213 /*
2214 * Copy the first SG into the "current"
2215 * data pointer area.
2216 */
2217 scb->hscb->dataptr = sg->addr;
2218 scb->hscb->datacnt = sg->len;
2219 } else {
2220 scb->hscb->sgptr = ahc_htole32(SG_LIST_NULL);
2221 scb->hscb->dataptr = 0;
2222 scb->hscb->datacnt = 0;
2223 scb->sg_count = 0;
2224 } 1681 }
1682 sg--;
1683 sg->len |= ahc_htole32(AHC_DMA_LAST_SEG);
2225 1684
2226 ahc_sync_sglist(ahc, scb, BUS_DMASYNC_PREWRITE); 1685 /*
2227 LIST_INSERT_HEAD(&ahc->pending_scbs, scb, pending_links); 1686 * Reset the sg list pointer.
2228 dev->openings--; 1687 */
2229 dev->active++; 1688 scb->hscb->sgptr =
2230 dev->commands_issued++; 1689 ahc_htole32(scb->sg_list_phys | SG_FULL_RESID);
2231 if ((dev->flags & AHC_DEV_PERIODIC_OTAG) != 0) 1690
2232 dev->commands_since_idle_or_otag++; 1691 /*
1692 * Copy the first SG into the "current"
1693 * data pointer area.
1694 */
1695 scb->hscb->dataptr = scb->sg_list->addr;
1696 scb->hscb->datacnt = scb->sg_list->len;
1697 } else if (cmd->request_bufflen != 0) {
1698 struct ahc_dma_seg *sg;
1699 dma_addr_t addr;
1700
1701 sg = scb->sg_list;
1702 addr = pci_map_single(ahc->dev_softc,
1703 cmd->request_buffer,
1704 cmd->request_bufflen,
1705 cmd->sc_data_direction);
1706 scb->platform_data->buf_busaddr = addr;
1707 scb->sg_count = ahc_linux_map_seg(ahc, scb,
1708 sg, addr,
1709 cmd->request_bufflen);
1710 sg->len |= ahc_htole32(AHC_DMA_LAST_SEG);
2233 1711
2234 /* 1712 /*
2235 * We only allow one untagged transaction 1713 * Reset the sg list pointer.
2236 * per target in the initiator role unless
2237 * we are storing a full busy target *lun*
2238 * table in SCB space.
2239 */ 1714 */
2240 if ((scb->hscb->control & (TARGET_SCB|TAG_ENB)) == 0 1715 scb->hscb->sgptr =
2241 && (ahc->features & AHC_SCB_BTT) == 0) { 1716 ahc_htole32(scb->sg_list_phys | SG_FULL_RESID);
2242 struct scb_tailq *untagged_q; 1717
2243 int target_offset; 1718 /*
2244 1719 * Copy the first SG into the "current"
2245 target_offset = SCB_GET_TARGET_OFFSET(ahc, scb); 1720 * data pointer area.
2246 untagged_q = &(ahc->untagged_queues[target_offset]); 1721 */
2247 TAILQ_INSERT_TAIL(untagged_q, scb, links.tqe); 1722 scb->hscb->dataptr = sg->addr;
2248 scb->flags |= SCB_UNTAGGEDQ; 1723 scb->hscb->datacnt = sg->len;
2249 if (TAILQ_FIRST(untagged_q) != scb) 1724 } else {
2250 continue; 1725 scb->hscb->sgptr = ahc_htole32(SG_LIST_NULL);
2251 } 1726 scb->hscb->dataptr = 0;
2252 scb->flags |= SCB_ACTIVE; 1727 scb->hscb->datacnt = 0;
2253 ahc_queue_scb(ahc, scb); 1728 scb->sg_count = 0;
2254 } 1729 }
1730
1731 LIST_INSERT_HEAD(&ahc->pending_scbs, scb, pending_links);
1732 dev->openings--;
1733 dev->active++;
1734 dev->commands_issued++;
1735 if ((dev->flags & AHC_DEV_PERIODIC_OTAG) != 0)
1736 dev->commands_since_idle_or_otag++;
1737
1738 scb->flags |= SCB_ACTIVE;
1739 if (untagged_q) {
1740 TAILQ_INSERT_TAIL(untagged_q, scb, links.tqe);
1741 scb->flags |= SCB_UNTAGGEDQ;
1742 }
1743 ahc_queue_scb(ahc, scb);
1744 return 0;
2255} 1745}
2256 1746
2257/* 1747/*
@@ -2267,9 +1757,6 @@ ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs)
2267 ahc = (struct ahc_softc *) dev_id; 1757 ahc = (struct ahc_softc *) dev_id;
2268 ahc_lock(ahc, &flags); 1758 ahc_lock(ahc, &flags);
2269 ours = ahc_intr(ahc); 1759 ours = ahc_intr(ahc);
2270 if (ahc_linux_next_device_to_run(ahc) != NULL)
2271 ahc_schedule_runq(ahc);
2272 ahc_linux_run_complete_queue(ahc);
2273 ahc_unlock(ahc, &flags); 1760 ahc_unlock(ahc, &flags);
2274 return IRQ_RETVAL(ours); 1761 return IRQ_RETVAL(ours);
2275} 1762}
@@ -2278,8 +1765,6 @@ void
2278ahc_platform_flushwork(struct ahc_softc *ahc) 1765ahc_platform_flushwork(struct ahc_softc *ahc)
2279{ 1766{
2280 1767
2281 while (ahc_linux_run_complete_queue(ahc) != NULL)
2282 ;
2283} 1768}
2284 1769
2285static struct ahc_linux_target* 1770static struct ahc_linux_target*
@@ -2348,9 +1833,6 @@ ahc_linux_alloc_device(struct ahc_softc *ahc,
2348 if (dev == NULL) 1833 if (dev == NULL)
2349 return (NULL); 1834 return (NULL);
2350 memset(dev, 0, sizeof(*dev)); 1835 memset(dev, 0, sizeof(*dev));
2351 init_timer(&dev->timer);
2352 TAILQ_INIT(&dev->busyq);
2353 dev->flags = AHC_DEV_UNCONFIGURED;
2354 dev->lun = lun; 1836 dev->lun = lun;
2355 dev->target = targ; 1837 dev->target = targ;
2356 1838
@@ -2373,7 +1855,7 @@ ahc_linux_alloc_device(struct ahc_softc *ahc,
2373} 1855}
2374 1856
2375static void 1857static void
2376__ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev) 1858ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev)
2377{ 1859{
2378 struct ahc_linux_target *targ; 1860 struct ahc_linux_target *targ;
2379 1861
@@ -2385,13 +1867,6 @@ __ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev)
2385 ahc_linux_free_target(ahc, targ); 1867 ahc_linux_free_target(ahc, targ);
2386} 1868}
2387 1869
2388static void
2389ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev)
2390{
2391 del_timer_sync(&dev->timer);
2392 __ahc_linux_free_device(ahc, dev);
2393}
2394
2395void 1870void
2396ahc_send_async(struct ahc_softc *ahc, char channel, 1871ahc_send_async(struct ahc_softc *ahc, char channel,
2397 u_int target, u_int lun, ac_code code, void *arg) 1872 u_int target, u_int lun, ac_code code, void *arg)
@@ -2463,28 +1938,9 @@ ahc_send_async(struct ahc_softc *ahc, char channel,
2463 } 1938 }
2464 case AC_SENT_BDR: 1939 case AC_SENT_BDR:
2465 { 1940 {
2466#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
2467 WARN_ON(lun != CAM_LUN_WILDCARD); 1941 WARN_ON(lun != CAM_LUN_WILDCARD);
2468 scsi_report_device_reset(ahc->platform_data->host, 1942 scsi_report_device_reset(ahc->platform_data->host,
2469 channel - 'A', target); 1943 channel - 'A', target);
2470#else
2471 Scsi_Device *scsi_dev;
2472
2473 /*
2474 * Find the SCSI device associated with this
2475 * request and indicate that a UA is expected.
2476 */
2477 for (scsi_dev = ahc->platform_data->host->host_queue;
2478 scsi_dev != NULL; scsi_dev = scsi_dev->next) {
2479 if (channel - 'A' == scsi_dev->channel
2480 && target == scsi_dev->id
2481 && (lun == CAM_LUN_WILDCARD
2482 || lun == scsi_dev->lun)) {
2483 scsi_dev->was_reset = 1;
2484 scsi_dev->expecting_cc_ua = 1;
2485 }
2486 }
2487#endif
2488 break; 1944 break;
2489 } 1945 }
2490 case AC_BUS_RESET: 1946 case AC_BUS_RESET:
@@ -2504,7 +1960,7 @@ ahc_send_async(struct ahc_softc *ahc, char channel,
2504void 1960void
2505ahc_done(struct ahc_softc *ahc, struct scb *scb) 1961ahc_done(struct ahc_softc *ahc, struct scb *scb)
2506{ 1962{
2507 Scsi_Cmnd *cmd; 1963 struct scsi_cmnd *cmd;
2508 struct ahc_linux_device *dev; 1964 struct ahc_linux_device *dev;
2509 1965
2510 LIST_REMOVE(scb, pending_links); 1966 LIST_REMOVE(scb, pending_links);
@@ -2515,7 +1971,7 @@ ahc_done(struct ahc_softc *ahc, struct scb *scb)
2515 target_offset = SCB_GET_TARGET_OFFSET(ahc, scb); 1971 target_offset = SCB_GET_TARGET_OFFSET(ahc, scb);
2516 untagged_q = &(ahc->untagged_queues[target_offset]); 1972 untagged_q = &(ahc->untagged_queues[target_offset]);
2517 TAILQ_REMOVE(untagged_q, scb, links.tqe); 1973 TAILQ_REMOVE(untagged_q, scb, links.tqe);
2518 ahc_run_untagged_queue(ahc, untagged_q); 1974 BUG_ON(!TAILQ_EMPTY(untagged_q));
2519 } 1975 }
2520 1976
2521 if ((scb->flags & SCB_ACTIVE) == 0) { 1977 if ((scb->flags & SCB_ACTIVE) == 0) {
@@ -2583,8 +2039,6 @@ ahc_done(struct ahc_softc *ahc, struct scb *scb)
2583 } 2039 }
2584 } else if (ahc_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) { 2040 } else if (ahc_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) {
2585 ahc_linux_handle_scsi_status(ahc, dev, scb); 2041 ahc_linux_handle_scsi_status(ahc, dev, scb);
2586 } else if (ahc_get_transaction_status(scb) == CAM_SEL_TIMEOUT) {
2587 dev->flags |= AHC_DEV_UNCONFIGURED;
2588 } 2042 }
2589 2043
2590 if (dev->openings == 1 2044 if (dev->openings == 1
@@ -2606,16 +2060,6 @@ ahc_done(struct ahc_softc *ahc, struct scb *scb)
2606 if (dev->active == 0) 2060 if (dev->active == 0)
2607 dev->commands_since_idle_or_otag = 0; 2061 dev->commands_since_idle_or_otag = 0;
2608 2062
2609 if (TAILQ_EMPTY(&dev->busyq)) {
2610 if ((dev->flags & AHC_DEV_UNCONFIGURED) != 0
2611 && dev->active == 0
2612 && (dev->flags & AHC_DEV_TIMER_ACTIVE) == 0)
2613 ahc_linux_free_device(ahc, dev);
2614 } else if ((dev->flags & AHC_DEV_ON_RUN_LIST) == 0) {
2615 TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, dev, links);
2616 dev->flags |= AHC_DEV_ON_RUN_LIST;
2617 }
2618
2619 if ((scb->flags & SCB_RECOVERY_SCB) != 0) { 2063 if ((scb->flags & SCB_RECOVERY_SCB) != 0) {
2620 printf("Recovery SCB completes\n"); 2064 printf("Recovery SCB completes\n");
2621 if (ahc_get_transaction_status(scb) == CAM_BDR_SENT 2065 if (ahc_get_transaction_status(scb) == CAM_BDR_SENT
@@ -2659,7 +2103,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
2659 case SCSI_STATUS_CHECK_COND: 2103 case SCSI_STATUS_CHECK_COND:
2660 case SCSI_STATUS_CMD_TERMINATED: 2104 case SCSI_STATUS_CMD_TERMINATED:
2661 { 2105 {
2662 Scsi_Cmnd *cmd; 2106 struct scsi_cmnd *cmd;
2663 2107
2664 /* 2108 /*
2665 * Copy sense information to the OS's cmd 2109 * Copy sense information to the OS's cmd
@@ -2754,52 +2198,15 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
2754 ahc_platform_set_tags(ahc, &devinfo, 2198 ahc_platform_set_tags(ahc, &devinfo,
2755 (dev->flags & AHC_DEV_Q_BASIC) 2199 (dev->flags & AHC_DEV_Q_BASIC)
2756 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED); 2200 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED);
2757 /* FALLTHROUGH */
2758 }
2759 case SCSI_STATUS_BUSY:
2760 {
2761 /*
2762 * Set a short timer to defer sending commands for
2763 * a bit since Linux will not delay in this case.
2764 */
2765 if ((dev->flags & AHC_DEV_TIMER_ACTIVE) != 0) {
2766 printf("%s:%c:%d: Device Timer still active during "
2767 "busy processing\n", ahc_name(ahc),
2768 dev->target->channel, dev->target->target);
2769 break;
2770 }
2771 dev->flags |= AHC_DEV_TIMER_ACTIVE;
2772 dev->qfrozen++;
2773 init_timer(&dev->timer);
2774 dev->timer.data = (u_long)dev;
2775 dev->timer.expires = jiffies + (HZ/2);
2776 dev->timer.function = ahc_linux_dev_timed_unfreeze;
2777 add_timer(&dev->timer);
2778 break; 2201 break;
2779 } 2202 }
2780 } 2203 }
2781} 2204}
2782 2205
2783static void 2206static void
2784ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, Scsi_Cmnd *cmd) 2207ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, struct scsi_cmnd *cmd)
2785{ 2208{
2786 /* 2209 /*
2787 * Typically, the complete queue has very few entries
2788 * queued to it before the queue is emptied by
2789 * ahc_linux_run_complete_queue, so sorting the entries
2790 * by generation number should be inexpensive.
2791 * We perform the sort so that commands that complete
2792 * with an error are retuned in the order origionally
2793 * queued to the controller so that any subsequent retries
2794 * are performed in order. The underlying ahc routines do
2795 * not guarantee the order that aborted commands will be
2796 * returned to us.
2797 */
2798 struct ahc_completeq *completeq;
2799 struct ahc_cmd *list_cmd;
2800 struct ahc_cmd *acmd;
2801
2802 /*
2803 * Map CAM error codes into Linux Error codes. We 2210 * Map CAM error codes into Linux Error codes. We
2804 * avoid the conversion so that the DV code has the 2211 * avoid the conversion so that the DV code has the
2805 * full error information available when making 2212 * full error information available when making
@@ -2852,26 +2259,7 @@ ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, Scsi_Cmnd *cmd)
2852 new_status = DID_ERROR; 2259 new_status = DID_ERROR;
2853 break; 2260 break;
2854 case CAM_REQUEUE_REQ: 2261 case CAM_REQUEUE_REQ:
2855 /* 2262 new_status = DID_REQUEUE;
2856 * If we want the request requeued, make sure there
2857 * are sufficent retries. In the old scsi error code,
2858 * we used to be able to specify a result code that
2859 * bypassed the retry count. Now we must use this
2860 * hack. We also "fake" a check condition with
2861 * a sense code of ABORTED COMMAND. This seems to
2862 * evoke a retry even if this command is being sent
2863 * via the eh thread. Ick! Ick! Ick!
2864 */
2865 if (cmd->retries > 0)
2866 cmd->retries--;
2867 new_status = DID_OK;
2868 ahc_cmd_set_scsi_status(cmd, SCSI_STATUS_CHECK_COND);
2869 cmd->result |= (DRIVER_SENSE << 24);
2870 memset(cmd->sense_buffer, 0,
2871 sizeof(cmd->sense_buffer));
2872 cmd->sense_buffer[0] = SSD_ERRCODE_VALID
2873 | SSD_CURRENT_ERROR;
2874 cmd->sense_buffer[2] = SSD_KEY_ABORTED_COMMAND;
2875 break; 2263 break;
2876 default: 2264 default:
2877 /* We should never get here */ 2265 /* We should never get here */
@@ -2882,17 +2270,7 @@ ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, Scsi_Cmnd *cmd)
2882 ahc_cmd_set_transaction_status(cmd, new_status); 2270 ahc_cmd_set_transaction_status(cmd, new_status);
2883 } 2271 }
2884 2272
2885 completeq = &ahc->platform_data->completeq; 2273 cmd->scsi_done(cmd);
2886 list_cmd = TAILQ_FIRST(completeq);
2887 acmd = (struct ahc_cmd *)cmd;
2888 while (list_cmd != NULL
2889 && acmd_scsi_cmd(list_cmd).serial_number
2890 < acmd_scsi_cmd(acmd).serial_number)
2891 list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe);
2892 if (list_cmd != NULL)
2893 TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe);
2894 else
2895 TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe);
2896} 2274}
2897 2275
2898static void 2276static void
@@ -2940,7 +2318,6 @@ ahc_linux_release_simq(u_long arg)
2940 ahc->platform_data->qfrozen--; 2318 ahc->platform_data->qfrozen--;
2941 if (ahc->platform_data->qfrozen == 0) 2319 if (ahc->platform_data->qfrozen == 0)
2942 unblock_reqs = 1; 2320 unblock_reqs = 1;
2943 ahc_schedule_runq(ahc);
2944 ahc_unlock(ahc, &s); 2321 ahc_unlock(ahc, &s);
2945 /* 2322 /*
2946 * There is still a race here. The mid-layer 2323 * There is still a race here. The mid-layer
@@ -2952,37 +2329,12 @@ ahc_linux_release_simq(u_long arg)
2952 scsi_unblock_requests(ahc->platform_data->host); 2329 scsi_unblock_requests(ahc->platform_data->host);
2953} 2330}
2954 2331
2955static void
2956ahc_linux_dev_timed_unfreeze(u_long arg)
2957{
2958 struct ahc_linux_device *dev;
2959 struct ahc_softc *ahc;
2960 u_long s;
2961
2962 dev = (struct ahc_linux_device *)arg;
2963 ahc = dev->target->ahc;
2964 ahc_lock(ahc, &s);
2965 dev->flags &= ~AHC_DEV_TIMER_ACTIVE;
2966 if (dev->qfrozen > 0)
2967 dev->qfrozen--;
2968 if (dev->qfrozen == 0
2969 && (dev->flags & AHC_DEV_ON_RUN_LIST) == 0)
2970 ahc_linux_run_device_queue(ahc, dev);
2971 if (TAILQ_EMPTY(&dev->busyq)
2972 && dev->active == 0)
2973 __ahc_linux_free_device(ahc, dev);
2974 ahc_unlock(ahc, &s);
2975}
2976
2977static int 2332static int
2978ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag) 2333ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2979{ 2334{
2980 struct ahc_softc *ahc; 2335 struct ahc_softc *ahc;
2981 struct ahc_cmd *acmd;
2982 struct ahc_cmd *list_acmd;
2983 struct ahc_linux_device *dev; 2336 struct ahc_linux_device *dev;
2984 struct scb *pending_scb; 2337 struct scb *pending_scb;
2985 u_long s;
2986 u_int saved_scbptr; 2338 u_int saved_scbptr;
2987 u_int active_scb_index; 2339 u_int active_scb_index;
2988 u_int last_phase; 2340 u_int last_phase;
@@ -2998,7 +2350,6 @@ ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag)
2998 paused = FALSE; 2350 paused = FALSE;
2999 wait = FALSE; 2351 wait = FALSE;
3000 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 2352 ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
3001 acmd = (struct ahc_cmd *)cmd;
3002 2353
3003 printf("%s:%d:%d:%d: Attempting to queue a%s message\n", 2354 printf("%s:%d:%d:%d: Attempting to queue a%s message\n",
3004 ahc_name(ahc), cmd->device->channel, 2355 ahc_name(ahc), cmd->device->channel,
@@ -3011,22 +2362,6 @@ ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag)
3011 printf("\n"); 2362 printf("\n");
3012 2363
3013 /* 2364 /*
3014 * In all versions of Linux, we have to work around
3015 * a major flaw in how the mid-layer is locked down
3016 * if we are to sleep successfully in our error handler
3017 * while allowing our interrupt handler to run. Since
3018 * the midlayer acquires either the io_request_lock or
3019 * our lock prior to calling us, we must use the
3020 * spin_unlock_irq() method for unlocking our lock.
3021 * This will force interrupts to be enabled on the
3022 * current CPU. Since the EH thread should not have
3023 * been running with CPU interrupts disabled other than
3024 * by acquiring either the io_request_lock or our own
3025 * lock, this *should* be safe.
3026 */
3027 ahc_midlayer_entrypoint_lock(ahc, &s);
3028
3029 /*
3030 * First determine if we currently own this command. 2365 * First determine if we currently own this command.
3031 * Start by searching the device queue. If not found 2366 * Start by searching the device queue. If not found
3032 * there, check the pending_scb list. If not found 2367 * there, check the pending_scb list. If not found
@@ -3034,7 +2369,7 @@ ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag)
3034 * command, return success. 2369 * command, return success.
3035 */ 2370 */
3036 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id, 2371 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id,
3037 cmd->device->lun, /*alloc*/FALSE); 2372 cmd->device->lun);
3038 2373
3039 if (dev == NULL) { 2374 if (dev == NULL) {
3040 /* 2375 /*
@@ -3048,24 +2383,6 @@ ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag)
3048 goto no_cmd; 2383 goto no_cmd;
3049 } 2384 }
3050 2385
3051 TAILQ_FOREACH(list_acmd, &dev->busyq, acmd_links.tqe) {
3052 if (list_acmd == acmd)
3053 break;
3054 }
3055
3056 if (list_acmd != NULL) {
3057 printf("%s:%d:%d:%d: Command found on device queue\n",
3058 ahc_name(ahc), cmd->device->channel, cmd->device->id,
3059 cmd->device->lun);
3060 if (flag == SCB_ABORT) {
3061 TAILQ_REMOVE(&dev->busyq, list_acmd, acmd_links.tqe);
3062 cmd->result = DID_ABORT << 16;
3063 ahc_linux_queue_cmd_complete(ahc, cmd);
3064 retval = SUCCESS;
3065 goto done;
3066 }
3067 }
3068
3069 if ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED)) == 0 2386 if ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED)) == 0
3070 && ahc_search_untagged_queues(ahc, cmd, cmd->device->id, 2387 && ahc_search_untagged_queues(ahc, cmd, cmd->device->id,
3071 cmd->device->channel + 'A', 2388 cmd->device->channel + 'A',
@@ -3299,53 +2616,42 @@ done:
3299 } 2616 }
3300 spin_lock_irq(&ahc->platform_data->spin_lock); 2617 spin_lock_irq(&ahc->platform_data->spin_lock);
3301 } 2618 }
3302 ahc_schedule_runq(ahc);
3303 ahc_linux_run_complete_queue(ahc);
3304 ahc_midlayer_entrypoint_unlock(ahc, &s);
3305 return (retval); 2619 return (retval);
3306} 2620}
3307 2621
3308void 2622void
3309ahc_platform_dump_card_state(struct ahc_softc *ahc) 2623ahc_platform_dump_card_state(struct ahc_softc *ahc)
3310{ 2624{
3311 struct ahc_linux_device *dev; 2625}
3312 int channel;
3313 int maxchannel;
3314 int target;
3315 int maxtarget;
3316 int lun;
3317 int i;
3318
3319 maxchannel = (ahc->features & AHC_TWIN) ? 1 : 0;
3320 maxtarget = (ahc->features & AHC_WIDE) ? 15 : 7;
3321 for (channel = 0; channel <= maxchannel; channel++) {
3322 2626
3323 for (target = 0; target <=maxtarget; target++) { 2627static void ahc_linux_exit(void);
3324 2628
3325 for (lun = 0; lun < AHC_NUM_LUNS; lun++) { 2629static void ahc_linux_get_width(struct scsi_target *starget)
3326 struct ahc_cmd *acmd; 2630{
2631 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
2632 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2633 struct ahc_tmode_tstate *tstate;
2634 struct ahc_initiator_tinfo *tinfo
2635 = ahc_fetch_transinfo(ahc,
2636 starget->channel + 'A',
2637 shost->this_id, starget->id, &tstate);
2638 spi_width(starget) = tinfo->curr.width;
2639}
3327 2640
3328 dev = ahc_linux_get_device(ahc, channel, target, 2641static void ahc_linux_set_width(struct scsi_target *starget, int width)
3329 lun, /*alloc*/FALSE); 2642{
3330 if (dev == NULL) 2643 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
3331 continue; 2644 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2645 struct ahc_devinfo devinfo;
2646 unsigned long flags;
3332 2647
3333 printf("DevQ(%d:%d:%d): ", 2648 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
3334 channel, target, lun); 2649 starget->channel + 'A', ROLE_INITIATOR);
3335 i = 0; 2650 ahc_lock(ahc, &flags);
3336 TAILQ_FOREACH(acmd, &dev->busyq, 2651 ahc_set_width(ahc, &devinfo, width, AHC_TRANS_GOAL, FALSE);
3337 acmd_links.tqe) { 2652 ahc_unlock(ahc, &flags);
3338 if (i++ > AHC_SCB_MAX)
3339 break;
3340 }
3341 printf("%d waiting\n", i);
3342 }
3343 }
3344 }
3345} 2653}
3346 2654
3347static void ahc_linux_exit(void);
3348
3349static void ahc_linux_get_period(struct scsi_target *starget) 2655static void ahc_linux_get_period(struct scsi_target *starget)
3350{ 2656{
3351 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2657 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -3376,8 +2682,21 @@ static void ahc_linux_set_period(struct scsi_target *starget, int period)
3376 if (offset == 0) 2682 if (offset == 0)
3377 offset = MAX_OFFSET; 2683 offset = MAX_OFFSET;
3378 2684
2685 if (period < 9)
2686 period = 9; /* 12.5ns is our minimum */
2687 if (period == 9)
2688 ppr_options |= MSG_EXT_PPR_DT_REQ;
2689
3379 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2690 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
3380 starget->channel + 'A', ROLE_INITIATOR); 2691 starget->channel + 'A', ROLE_INITIATOR);
2692
2693 /* all PPR requests apart from QAS require wide transfers */
2694 if (ppr_options & ~MSG_EXT_PPR_QAS_REQ) {
2695 ahc_linux_get_width(starget);
2696 if (spi_width(starget) == 0)
2697 ppr_options &= MSG_EXT_PPR_QAS_REQ;
2698 }
2699
3381 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); 2700 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT);
3382 ahc_lock(ahc, &flags); 2701 ahc_lock(ahc, &flags);
3383 ahc_set_syncrate(ahc, &devinfo, syncrate, period, offset, 2702 ahc_set_syncrate(ahc, &devinfo, syncrate, period, offset,
@@ -3425,32 +2744,6 @@ static void ahc_linux_set_offset(struct scsi_target *starget, int offset)
3425 ahc_unlock(ahc, &flags); 2744 ahc_unlock(ahc, &flags);
3426} 2745}
3427 2746
3428static void ahc_linux_get_width(struct scsi_target *starget)
3429{
3430 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
3431 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
3432 struct ahc_tmode_tstate *tstate;
3433 struct ahc_initiator_tinfo *tinfo
3434 = ahc_fetch_transinfo(ahc,
3435 starget->channel + 'A',
3436 shost->this_id, starget->id, &tstate);
3437 spi_width(starget) = tinfo->curr.width;
3438}
3439
3440static void ahc_linux_set_width(struct scsi_target *starget, int width)
3441{
3442 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
3443 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
3444 struct ahc_devinfo devinfo;
3445 unsigned long flags;
3446
3447 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
3448 starget->channel + 'A', ROLE_INITIATOR);
3449 ahc_lock(ahc, &flags);
3450 ahc_set_width(ahc, &devinfo, width, AHC_TRANS_GOAL, FALSE);
3451 ahc_unlock(ahc, &flags);
3452}
3453
3454static void ahc_linux_get_dt(struct scsi_target *starget) 2747static void ahc_linux_get_dt(struct scsi_target *starget)
3455{ 2748{
3456 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2749 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -3479,10 +2772,15 @@ static void ahc_linux_set_dt(struct scsi_target *starget, int dt)
3479 unsigned long flags; 2772 unsigned long flags;
3480 struct ahc_syncrate *syncrate; 2773 struct ahc_syncrate *syncrate;
3481 2774
2775 if (dt) {
2776 period = 9; /* 12.5ns is the only period valid for DT */
2777 ppr_options |= MSG_EXT_PPR_DT_REQ;
2778 } else if (period == 9)
2779 period = 10; /* if resetting DT, period must be >= 25ns */
2780
3482 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2781 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
3483 starget->channel + 'A', ROLE_INITIATOR); 2782 starget->channel + 'A', ROLE_INITIATOR);
3484 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, 2783 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options,AHC_SYNCRATE_DT);
3485 dt ? AHC_SYNCRATE_DT : AHC_SYNCRATE_ULTRA2);
3486 ahc_lock(ahc, &flags); 2784 ahc_lock(ahc, &flags);
3487 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 2785 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset,
3488 ppr_options, AHC_TRANS_GOAL, FALSE); 2786 ppr_options, AHC_TRANS_GOAL, FALSE);
@@ -3514,7 +2812,6 @@ static void ahc_linux_set_qas(struct scsi_target *starget, int qas)
3514 unsigned int ppr_options = tinfo->curr.ppr_options 2812 unsigned int ppr_options = tinfo->curr.ppr_options
3515 & ~MSG_EXT_PPR_QAS_REQ; 2813 & ~MSG_EXT_PPR_QAS_REQ;
3516 unsigned int period = tinfo->curr.period; 2814 unsigned int period = tinfo->curr.period;
3517 unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ;
3518 unsigned long flags; 2815 unsigned long flags;
3519 struct ahc_syncrate *syncrate; 2816 struct ahc_syncrate *syncrate;
3520 2817
@@ -3523,8 +2820,7 @@ static void ahc_linux_set_qas(struct scsi_target *starget, int qas)
3523 2820
3524 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2821 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
3525 starget->channel + 'A', ROLE_INITIATOR); 2822 starget->channel + 'A', ROLE_INITIATOR);
3526 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, 2823 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT);
3527 dt ? AHC_SYNCRATE_DT : AHC_SYNCRATE_ULTRA2);
3528 ahc_lock(ahc, &flags); 2824 ahc_lock(ahc, &flags);
3529 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 2825 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset,
3530 ppr_options, AHC_TRANS_GOAL, FALSE); 2826 ppr_options, AHC_TRANS_GOAL, FALSE);
@@ -3556,7 +2852,6 @@ static void ahc_linux_set_iu(struct scsi_target *starget, int iu)
3556 unsigned int ppr_options = tinfo->curr.ppr_options 2852 unsigned int ppr_options = tinfo->curr.ppr_options
3557 & ~MSG_EXT_PPR_IU_REQ; 2853 & ~MSG_EXT_PPR_IU_REQ;
3558 unsigned int period = tinfo->curr.period; 2854 unsigned int period = tinfo->curr.period;
3559 unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ;
3560 unsigned long flags; 2855 unsigned long flags;
3561 struct ahc_syncrate *syncrate; 2856 struct ahc_syncrate *syncrate;
3562 2857
@@ -3565,8 +2860,7 @@ static void ahc_linux_set_iu(struct scsi_target *starget, int iu)
3565 2860
3566 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2861 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
3567 starget->channel + 'A', ROLE_INITIATOR); 2862 starget->channel + 'A', ROLE_INITIATOR);
3568 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, 2863 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT);
3569 dt ? AHC_SYNCRATE_DT : AHC_SYNCRATE_ULTRA2);
3570 ahc_lock(ahc, &flags); 2864 ahc_lock(ahc, &flags);
3571 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 2865 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset,
3572 ppr_options, AHC_TRANS_GOAL, FALSE); 2866 ppr_options, AHC_TRANS_GOAL, FALSE);
@@ -3599,7 +2893,6 @@ static struct spi_function_template ahc_linux_transport_functions = {
3599static int __init 2893static int __init
3600ahc_linux_init(void) 2894ahc_linux_init(void)
3601{ 2895{
3602#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
3603 ahc_linux_transport_template = spi_attach_transport(&ahc_linux_transport_functions); 2896 ahc_linux_transport_template = spi_attach_transport(&ahc_linux_transport_functions);
3604 if (!ahc_linux_transport_template) 2897 if (!ahc_linux_transport_template)
3605 return -ENODEV; 2898 return -ENODEV;
@@ -3608,29 +2901,11 @@ ahc_linux_init(void)
3608 spi_release_transport(ahc_linux_transport_template); 2901 spi_release_transport(ahc_linux_transport_template);
3609 ahc_linux_exit(); 2902 ahc_linux_exit();
3610 return -ENODEV; 2903 return -ENODEV;
3611#else
3612 scsi_register_module(MODULE_SCSI_HA, &aic7xxx_driver_template);
3613 if (aic7xxx_driver_template.present == 0) {
3614 scsi_unregister_module(MODULE_SCSI_HA,
3615 &aic7xxx_driver_template);
3616 return (-ENODEV);
3617 }
3618
3619 return (0);
3620#endif
3621} 2904}
3622 2905
3623static void 2906static void
3624ahc_linux_exit(void) 2907ahc_linux_exit(void)
3625{ 2908{
3626#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
3627 /*
3628 * In 2.4 we have to unregister from the PCI core _after_
3629 * unregistering from the scsi midlayer to avoid dangling
3630 * references.
3631 */
3632 scsi_unregister_module(MODULE_SCSI_HA, &aic7xxx_driver_template);
3633#endif
3634 ahc_linux_pci_exit(); 2909 ahc_linux_pci_exit();
3635 ahc_linux_eisa_exit(); 2910 ahc_linux_eisa_exit();
3636 spi_release_transport(ahc_linux_transport_template); 2911 spi_release_transport(ahc_linux_transport_template);
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index ed9027bd8a40..30c200d5bcd5 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -59,6 +59,7 @@
59#ifndef _AIC7XXX_LINUX_H_ 59#ifndef _AIC7XXX_LINUX_H_
60#define _AIC7XXX_LINUX_H_ 60#define _AIC7XXX_LINUX_H_
61 61
62#include <linux/config.h>
62#include <linux/types.h> 63#include <linux/types.h>
63#include <linux/blkdev.h> 64#include <linux/blkdev.h>
64#include <linux/delay.h> 65#include <linux/delay.h>
@@ -66,18 +67,21 @@
66#include <linux/pci.h> 67#include <linux/pci.h>
67#include <linux/smp_lock.h> 68#include <linux/smp_lock.h>
68#include <linux/version.h> 69#include <linux/version.h>
70#include <linux/interrupt.h>
69#include <linux/module.h> 71#include <linux/module.h>
72#include <linux/slab.h>
70#include <asm/byteorder.h> 73#include <asm/byteorder.h>
71#include <asm/io.h> 74#include <asm/io.h>
72 75
73#include <linux/interrupt.h> /* For tasklet support. */ 76#include <scsi/scsi.h>
74#include <linux/config.h> 77#include <scsi/scsi_cmnd.h>
75#include <linux/slab.h> 78#include <scsi/scsi_eh.h>
79#include <scsi/scsi_device.h>
80#include <scsi/scsi_host.h>
81#include <scsi/scsi_tcq.h>
76 82
77/* Core SCSI definitions */ 83/* Core SCSI definitions */
78#define AIC_LIB_PREFIX ahc 84#define AIC_LIB_PREFIX ahc
79#include "scsi.h"
80#include <scsi/scsi_host.h>
81 85
82/* Name space conflict with BSD queue macros */ 86/* Name space conflict with BSD queue macros */
83#ifdef LIST_HEAD 87#ifdef LIST_HEAD
@@ -106,7 +110,7 @@
106/************************* Forward Declarations *******************************/ 110/************************* Forward Declarations *******************************/
107struct ahc_softc; 111struct ahc_softc;
108typedef struct pci_dev *ahc_dev_softc_t; 112typedef struct pci_dev *ahc_dev_softc_t;
109typedef Scsi_Cmnd *ahc_io_ctx_t; 113typedef struct scsi_cmnd *ahc_io_ctx_t;
110 114
111/******************************* Byte Order ***********************************/ 115/******************************* Byte Order ***********************************/
112#define ahc_htobe16(x) cpu_to_be16(x) 116#define ahc_htobe16(x) cpu_to_be16(x)
@@ -144,7 +148,7 @@ typedef Scsi_Cmnd *ahc_io_ctx_t;
144extern u_int aic7xxx_no_probe; 148extern u_int aic7xxx_no_probe;
145extern u_int aic7xxx_allow_memio; 149extern u_int aic7xxx_allow_memio;
146extern int aic7xxx_detect_complete; 150extern int aic7xxx_detect_complete;
147extern Scsi_Host_Template aic7xxx_driver_template; 151extern struct scsi_host_template aic7xxx_driver_template;
148 152
149/***************************** Bus Space/DMA **********************************/ 153/***************************** Bus Space/DMA **********************************/
150 154
@@ -174,11 +178,7 @@ struct ahc_linux_dma_tag
174}; 178};
175typedef struct ahc_linux_dma_tag* bus_dma_tag_t; 179typedef struct ahc_linux_dma_tag* bus_dma_tag_t;
176 180
177struct ahc_linux_dmamap 181typedef dma_addr_t bus_dmamap_t;
178{
179 dma_addr_t bus_addr;
180};
181typedef struct ahc_linux_dmamap* bus_dmamap_t;
182 182
183typedef int bus_dma_filter_t(void*, dma_addr_t); 183typedef int bus_dma_filter_t(void*, dma_addr_t);
184typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); 184typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
@@ -281,12 +281,6 @@ ahc_scb_timer_reset(struct scb *scb, u_int usec)
281/***************************** SMP support ************************************/ 281/***************************** SMP support ************************************/
282#include <linux/spinlock.h> 282#include <linux/spinlock.h>
283 283
284#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) || defined(SCSI_HAS_HOST_LOCK))
285#define AHC_SCSI_HAS_HOST_LOCK 1
286#else
287#define AHC_SCSI_HAS_HOST_LOCK 0
288#endif
289
290#define AIC7XXX_DRIVER_VERSION "6.2.36" 284#define AIC7XXX_DRIVER_VERSION "6.2.36"
291 285
292/**************************** Front End Queues ********************************/ 286/**************************** Front End Queues ********************************/
@@ -328,20 +322,15 @@ struct ahc_cmd {
328 */ 322 */
329TAILQ_HEAD(ahc_busyq, ahc_cmd); 323TAILQ_HEAD(ahc_busyq, ahc_cmd);
330typedef enum { 324typedef enum {
331 AHC_DEV_UNCONFIGURED = 0x01,
332 AHC_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */ 325 AHC_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */
333 AHC_DEV_TIMER_ACTIVE = 0x04, /* Our timer is active */
334 AHC_DEV_ON_RUN_LIST = 0x08, /* Queued to be run later */
335 AHC_DEV_Q_BASIC = 0x10, /* Allow basic device queuing */ 326 AHC_DEV_Q_BASIC = 0x10, /* Allow basic device queuing */
336 AHC_DEV_Q_TAGGED = 0x20, /* Allow full SCSI2 command queueing */ 327 AHC_DEV_Q_TAGGED = 0x20, /* Allow full SCSI2 command queueing */
337 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ 328 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */
338 AHC_DEV_SLAVE_CONFIGURED = 0x80 /* slave_configure() has been called */
339} ahc_linux_dev_flags; 329} ahc_linux_dev_flags;
340 330
341struct ahc_linux_target; 331struct ahc_linux_target;
342struct ahc_linux_device { 332struct ahc_linux_device {
343 TAILQ_ENTRY(ahc_linux_device) links; 333 TAILQ_ENTRY(ahc_linux_device) links;
344 struct ahc_busyq busyq;
345 334
346 /* 335 /*
347 * The number of transactions currently 336 * The number of transactions currently
@@ -382,11 +371,6 @@ struct ahc_linux_device {
382 ahc_linux_dev_flags flags; 371 ahc_linux_dev_flags flags;
383 372
384 /* 373 /*
385 * Per device timer.
386 */
387 struct timer_list timer;
388
389 /*
390 * The high limit for the tags variable. 374 * The high limit for the tags variable.
391 */ 375 */
392 u_int maxtags; 376 u_int maxtags;
@@ -419,7 +403,7 @@ struct ahc_linux_device {
419#define AHC_OTAG_THRESH 500 403#define AHC_OTAG_THRESH 500
420 404
421 int lun; 405 int lun;
422 Scsi_Device *scsi_device; 406 struct scsi_device *scsi_device;
423 struct ahc_linux_target *target; 407 struct ahc_linux_target *target;
424}; 408};
425 409
@@ -439,32 +423,16 @@ struct ahc_linux_target {
439 * manner and are allocated below 4GB, the number of S/G segments is 423 * manner and are allocated below 4GB, the number of S/G segments is
440 * unrestricted. 424 * unrestricted.
441 */ 425 */
442#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
443/*
444 * We dynamically adjust the number of segments in pre-2.5 kernels to
445 * avoid fragmentation issues in the SCSI mid-layer's private memory
446 * allocator. See aic7xxx_osm.c ahc_linux_size_nseg() for details.
447 */
448extern u_int ahc_linux_nseg;
449#define AHC_NSEG ahc_linux_nseg
450#define AHC_LINUX_MIN_NSEG 64
451#else
452#define AHC_NSEG 128 426#define AHC_NSEG 128
453#endif
454 427
455/* 428/*
456 * Per-SCB OSM storage. 429 * Per-SCB OSM storage.
457 */ 430 */
458typedef enum {
459 AHC_UP_EH_SEMAPHORE = 0x1
460} ahc_linux_scb_flags;
461
462struct scb_platform_data { 431struct scb_platform_data {
463 struct ahc_linux_device *dev; 432 struct ahc_linux_device *dev;
464 dma_addr_t buf_busaddr; 433 dma_addr_t buf_busaddr;
465 uint32_t xfer_len; 434 uint32_t xfer_len;
466 uint32_t sense_resid; /* Auto-Sense residual */ 435 uint32_t sense_resid; /* Auto-Sense residual */
467 ahc_linux_scb_flags flags;
468}; 436};
469 437
470/* 438/*
@@ -473,39 +441,24 @@ struct scb_platform_data {
473 * alignment restrictions of the various platforms supported by 441 * alignment restrictions of the various platforms supported by
474 * this driver. 442 * this driver.
475 */ 443 */
476typedef enum {
477 AHC_RUN_CMPLT_Q_TIMER = 0x10
478} ahc_linux_softc_flags;
479
480TAILQ_HEAD(ahc_completeq, ahc_cmd);
481
482struct ahc_platform_data { 444struct ahc_platform_data {
483 /* 445 /*
484 * Fields accessed from interrupt context. 446 * Fields accessed from interrupt context.
485 */ 447 */
486 struct ahc_linux_target *targets[AHC_NUM_TARGETS]; 448 struct ahc_linux_target *targets[AHC_NUM_TARGETS];
487 TAILQ_HEAD(, ahc_linux_device) device_runq;
488 struct ahc_completeq completeq;
489 449
490 spinlock_t spin_lock; 450 spinlock_t spin_lock;
491 struct tasklet_struct runq_tasklet;
492 u_int qfrozen; 451 u_int qfrozen;
493 pid_t dv_pid;
494 struct timer_list completeq_timer;
495 struct timer_list reset_timer; 452 struct timer_list reset_timer;
496 struct semaphore eh_sem; 453 struct semaphore eh_sem;
497 struct semaphore dv_sem;
498 struct semaphore dv_cmd_sem; /* XXX This needs to be in
499 * the target struct
500 */
501 struct scsi_device *dv_scsi_dev;
502 struct Scsi_Host *host; /* pointer to scsi host */ 454 struct Scsi_Host *host; /* pointer to scsi host */
503#define AHC_LINUX_NOIRQ ((uint32_t)~0) 455#define AHC_LINUX_NOIRQ ((uint32_t)~0)
504 uint32_t irq; /* IRQ for this adapter */ 456 uint32_t irq; /* IRQ for this adapter */
505 uint32_t bios_address; 457 uint32_t bios_address;
506 uint32_t mem_busaddr; /* Mem Base Addr */ 458 uint32_t mem_busaddr; /* Mem Base Addr */
507 uint64_t hw_dma_mask; 459
508 ahc_linux_softc_flags flags; 460#define AHC_UP_EH_SEMAPHORE 0x1
461 uint32_t flags;
509}; 462};
510 463
511/************************** OS Utility Wrappers *******************************/ 464/************************** OS Utility Wrappers *******************************/
@@ -594,7 +547,7 @@ ahc_insb(struct ahc_softc * ahc, long port, uint8_t *array, int count)
594 547
595/**************************** Initialization **********************************/ 548/**************************** Initialization **********************************/
596int ahc_linux_register_host(struct ahc_softc *, 549int ahc_linux_register_host(struct ahc_softc *,
597 Scsi_Host_Template *); 550 struct scsi_host_template *);
598 551
599uint64_t ahc_linux_get_memsize(void); 552uint64_t ahc_linux_get_memsize(void);
600 553
@@ -615,17 +568,6 @@ static __inline void ahc_lockinit(struct ahc_softc *);
615static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags); 568static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags);
616static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags); 569static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags);
617 570
618/* Lock acquisition and release of the above lock in midlayer entry points. */
619static __inline void ahc_midlayer_entrypoint_lock(struct ahc_softc *,
620 unsigned long *flags);
621static __inline void ahc_midlayer_entrypoint_unlock(struct ahc_softc *,
622 unsigned long *flags);
623
624/* Lock held during command compeletion to the upper layer */
625static __inline void ahc_done_lockinit(struct ahc_softc *);
626static __inline void ahc_done_lock(struct ahc_softc *, unsigned long *flags);
627static __inline void ahc_done_unlock(struct ahc_softc *, unsigned long *flags);
628
629/* Lock held during ahc_list manipulation and ahc softc frees */ 571/* Lock held during ahc_list manipulation and ahc softc frees */
630extern spinlock_t ahc_list_spinlock; 572extern spinlock_t ahc_list_spinlock;
631static __inline void ahc_list_lockinit(void); 573static __inline void ahc_list_lockinit(void);
@@ -651,57 +593,6 @@ ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
651} 593}
652 594
653static __inline void 595static __inline void
654ahc_midlayer_entrypoint_lock(struct ahc_softc *ahc, unsigned long *flags)
655{
656 /*
657 * In 2.5.X and some 2.4.X versions, the midlayer takes our
658 * lock just before calling us, so we avoid locking again.
659 * For other kernel versions, the io_request_lock is taken
660 * just before our entry point is called. In this case, we
661 * trade the io_request_lock for our per-softc lock.
662 */
663#if AHC_SCSI_HAS_HOST_LOCK == 0
664 spin_unlock(&io_request_lock);
665 spin_lock(&ahc->platform_data->spin_lock);
666#endif
667}
668
669static __inline void
670ahc_midlayer_entrypoint_unlock(struct ahc_softc *ahc, unsigned long *flags)
671{
672#if AHC_SCSI_HAS_HOST_LOCK == 0
673 spin_unlock(&ahc->platform_data->spin_lock);
674 spin_lock(&io_request_lock);
675#endif
676}
677
678static __inline void
679ahc_done_lockinit(struct ahc_softc *ahc)
680{
681 /*
682 * In 2.5.X, our own lock is held during completions.
683 * In previous versions, the io_request_lock is used.
684 * In either case, we can't initialize this lock again.
685 */
686}
687
688static __inline void
689ahc_done_lock(struct ahc_softc *ahc, unsigned long *flags)
690{
691#if AHC_SCSI_HAS_HOST_LOCK == 0
692 spin_lock_irqsave(&io_request_lock, *flags);
693#endif
694}
695
696static __inline void
697ahc_done_unlock(struct ahc_softc *ahc, unsigned long *flags)
698{
699#if AHC_SCSI_HAS_HOST_LOCK == 0
700 spin_unlock_irqrestore(&io_request_lock, *flags);
701#endif
702}
703
704static __inline void
705ahc_list_lockinit(void) 596ahc_list_lockinit(void)
706{ 597{
707 spin_lock_init(&ahc_list_spinlock); 598 spin_lock_init(&ahc_list_spinlock);
@@ -767,12 +658,6 @@ typedef enum
767} ahc_power_state; 658} ahc_power_state;
768 659
769/**************************** VL/EISA Routines ********************************/ 660/**************************** VL/EISA Routines ********************************/
770#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) \
771 && (defined(__i386__) || defined(__alpha__)) \
772 && (!defined(CONFIG_EISA)))
773#define CONFIG_EISA
774#endif
775
776#ifdef CONFIG_EISA 661#ifdef CONFIG_EISA
777extern uint32_t aic7xxx_probe_eisa_vl; 662extern uint32_t aic7xxx_probe_eisa_vl;
778int ahc_linux_eisa_init(void); 663int ahc_linux_eisa_init(void);
@@ -888,22 +773,18 @@ ahc_flush_device_writes(struct ahc_softc *ahc)
888} 773}
889 774
890/**************************** Proc FS Support *********************************/ 775/**************************** Proc FS Support *********************************/
891#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
892int ahc_linux_proc_info(char *, char **, off_t, int, int, int);
893#else
894int ahc_linux_proc_info(struct Scsi_Host *, char *, char **, 776int ahc_linux_proc_info(struct Scsi_Host *, char *, char **,
895 off_t, int, int); 777 off_t, int, int);
896#endif
897 778
898/*************************** Domain Validation ********************************/ 779/*************************** Domain Validation ********************************/
899/*********************** Transaction Access Wrappers *************************/ 780/*********************** Transaction Access Wrappers *************************/
900static __inline void ahc_cmd_set_transaction_status(Scsi_Cmnd *, uint32_t); 781static __inline void ahc_cmd_set_transaction_status(struct scsi_cmnd *, uint32_t);
901static __inline void ahc_set_transaction_status(struct scb *, uint32_t); 782static __inline void ahc_set_transaction_status(struct scb *, uint32_t);
902static __inline void ahc_cmd_set_scsi_status(Scsi_Cmnd *, uint32_t); 783static __inline void ahc_cmd_set_scsi_status(struct scsi_cmnd *, uint32_t);
903static __inline void ahc_set_scsi_status(struct scb *, uint32_t); 784static __inline void ahc_set_scsi_status(struct scb *, uint32_t);
904static __inline uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd); 785static __inline uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd);
905static __inline uint32_t ahc_get_transaction_status(struct scb *); 786static __inline uint32_t ahc_get_transaction_status(struct scb *);
906static __inline uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd); 787static __inline uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd);
907static __inline uint32_t ahc_get_scsi_status(struct scb *); 788static __inline uint32_t ahc_get_scsi_status(struct scb *);
908static __inline void ahc_set_transaction_tag(struct scb *, int, u_int); 789static __inline void ahc_set_transaction_tag(struct scb *, int, u_int);
909static __inline u_long ahc_get_transfer_length(struct scb *); 790static __inline u_long ahc_get_transfer_length(struct scb *);
@@ -922,7 +803,7 @@ static __inline void ahc_platform_scb_free(struct ahc_softc *ahc,
922static __inline void ahc_freeze_scb(struct scb *scb); 803static __inline void ahc_freeze_scb(struct scb *scb);
923 804
924static __inline 805static __inline
925void ahc_cmd_set_transaction_status(Scsi_Cmnd *cmd, uint32_t status) 806void ahc_cmd_set_transaction_status(struct scsi_cmnd *cmd, uint32_t status)
926{ 807{
927 cmd->result &= ~(CAM_STATUS_MASK << 16); 808 cmd->result &= ~(CAM_STATUS_MASK << 16);
928 cmd->result |= status << 16; 809 cmd->result |= status << 16;
@@ -935,7 +816,7 @@ void ahc_set_transaction_status(struct scb *scb, uint32_t status)
935} 816}
936 817
937static __inline 818static __inline
938void ahc_cmd_set_scsi_status(Scsi_Cmnd *cmd, uint32_t status) 819void ahc_cmd_set_scsi_status(struct scsi_cmnd *cmd, uint32_t status)
939{ 820{
940 cmd->result &= ~0xFFFF; 821 cmd->result &= ~0xFFFF;
941 cmd->result |= status; 822 cmd->result |= status;
@@ -948,7 +829,7 @@ void ahc_set_scsi_status(struct scb *scb, uint32_t status)
948} 829}
949 830
950static __inline 831static __inline
951uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd) 832uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd)
952{ 833{
953 return ((cmd->result >> 16) & CAM_STATUS_MASK); 834 return ((cmd->result >> 16) & CAM_STATUS_MASK);
954} 835}
@@ -960,7 +841,7 @@ uint32_t ahc_get_transaction_status(struct scb *scb)
960} 841}
961 842
962static __inline 843static __inline
963uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd) 844uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd)
964{ 845{
965 return (cmd->result & 0xFFFF); 846 return (cmd->result & 0xFFFF);
966} 847}
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
index 6f6674aa31ef..2a0ebce83e7a 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
@@ -221,13 +221,11 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
221 && ahc_linux_get_memsize() > 0x80000000 221 && ahc_linux_get_memsize() > 0x80000000
222 && pci_set_dma_mask(pdev, mask_39bit) == 0) { 222 && pci_set_dma_mask(pdev, mask_39bit) == 0) {
223 ahc->flags |= AHC_39BIT_ADDRESSING; 223 ahc->flags |= AHC_39BIT_ADDRESSING;
224 ahc->platform_data->hw_dma_mask = mask_39bit;
225 } else { 224 } else {
226 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 225 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
227 printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); 226 printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
228 return (-ENODEV); 227 return (-ENODEV);
229 } 228 }
230 ahc->platform_data->hw_dma_mask = DMA_32BIT_MASK;
231 } 229 }
232 ahc->dev_softc = pci; 230 ahc->dev_softc = pci;
233 error = ahc_pci_config(ahc, entry); 231 error = ahc_pci_config(ahc, entry);
@@ -236,15 +234,8 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
236 return (-error); 234 return (-error);
237 } 235 }
238 pci_set_drvdata(pdev, ahc); 236 pci_set_drvdata(pdev, ahc);
239 if (aic7xxx_detect_complete) { 237 if (aic7xxx_detect_complete)
240#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
241 ahc_linux_register_host(ahc, &aic7xxx_driver_template); 238 ahc_linux_register_host(ahc, &aic7xxx_driver_template);
242#else
243 printf("aic7xxx: ignoring PCI device found after "
244 "initialization\n");
245 return (-ENODEV);
246#endif
247 }
248 return (0); 239 return (0);
249} 240}
250 241
diff --git a/drivers/scsi/aic7xxx/aic7xxx_proc.c b/drivers/scsi/aic7xxx/aic7xxx_proc.c
index 85e80eecc9d0..5fece859fbd9 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_proc.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_proc.c
@@ -289,13 +289,8 @@ done:
289 * Return information to handle /proc support for the driver. 289 * Return information to handle /proc support for the driver.
290 */ 290 */
291int 291int
292#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
293ahc_linux_proc_info(char *buffer, char **start, off_t offset,
294 int length, int hostno, int inout)
295#else
296ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, 292ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
297 off_t offset, int length, int inout) 293 off_t offset, int length, int inout)
298#endif
299{ 294{
300 struct ahc_softc *ahc; 295 struct ahc_softc *ahc;
301 struct info_str info; 296 struct info_str info;
@@ -307,15 +302,7 @@ ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
307 302
308 retval = -EINVAL; 303 retval = -EINVAL;
309 ahc_list_lock(&s); 304 ahc_list_lock(&s);
310#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
311 TAILQ_FOREACH(ahc, &ahc_tailq, links) {
312 if (ahc->platform_data->host->host_no == hostno)
313 break;
314 }
315#else
316 ahc = ahc_find_softc(*(struct ahc_softc **)shost->hostdata); 305 ahc = ahc_find_softc(*(struct ahc_softc **)shost->hostdata);
317#endif
318
319 if (ahc == NULL) 306 if (ahc == NULL)
320 goto done; 307 goto done;
321 308
diff --git a/drivers/scsi/aic7xxx/aiclib.c b/drivers/scsi/aic7xxx/aiclib.c
index 79bfd9efd8ed..7c5a6db0e672 100644
--- a/drivers/scsi/aic7xxx/aiclib.c
+++ b/drivers/scsi/aic7xxx/aiclib.c
@@ -35,7 +35,6 @@
35#include <linux/version.h> 35#include <linux/version.h>
36 36
37/* Core SCSI definitions */ 37/* Core SCSI definitions */
38#include "scsi.h"
39#include <scsi/scsi_host.h> 38#include <scsi/scsi_host.h>
40#include "aiclib.h" 39#include "aiclib.h"
41#include "cam.h" 40#include "cam.h"
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 2e2486b035dd..83f062ed9082 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -179,8 +179,18 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
179 return; 179 return;
180 } 180 }
181 count = min(pc->sg->length - pc->b_count, bcount); 181 count = min(pc->sg->length - pc->b_count, bcount);
182 buf = page_address(pc->sg->page) + pc->sg->offset; 182 if (PageHighMem(pc->sg->page)) {
183 drive->hwif->atapi_input_bytes(drive, buf + pc->b_count, count); 183 unsigned long flags;
184
185 local_irq_save(flags);
186 buf = kmap_atomic(pc->sg->page, KM_IRQ0) + pc->sg->offset;
187 drive->hwif->atapi_input_bytes(drive, buf + pc->b_count, count);
188 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
189 local_irq_restore(flags);
190 } else {
191 buf = page_address(pc->sg->page) + pc->sg->offset;
192 drive->hwif->atapi_input_bytes(drive, buf + pc->b_count, count);
193 }
184 bcount -= count; pc->b_count += count; 194 bcount -= count; pc->b_count += count;
185 if (pc->b_count == pc->sg->length) { 195 if (pc->b_count == pc->sg->length) {
186 pc->sg++; 196 pc->sg++;
@@ -201,8 +211,18 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
201 return; 211 return;
202 } 212 }
203 count = min(pc->sg->length - pc->b_count, bcount); 213 count = min(pc->sg->length - pc->b_count, bcount);
204 buf = page_address(pc->sg->page) + pc->sg->offset; 214 if (PageHighMem(pc->sg->page)) {
205 drive->hwif->atapi_output_bytes(drive, buf + pc->b_count, count); 215 unsigned long flags;
216
217 local_irq_save(flags);
218 buf = kmap_atomic(pc->sg->page, KM_IRQ0) + pc->sg->offset;
219 drive->hwif->atapi_output_bytes(drive, buf + pc->b_count, count);
220 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
221 local_irq_restore(flags);
222 } else {
223 buf = page_address(pc->sg->page) + pc->sg->offset;
224 drive->hwif->atapi_output_bytes(drive, buf + pc->b_count, count);
225 }
206 bcount -= count; pc->b_count += count; 226 bcount -= count; pc->b_count += count;
207 if (pc->b_count == pc->sg->length) { 227 if (pc->b_count == pc->sg->length) {
208 pc->sg++; 228 pc->sg++;
@@ -713,7 +733,6 @@ static void idescsi_add_settings(ide_drive_t *drive)
713 */ 733 */
714static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi) 734static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi)
715{ 735{
716 DRIVER(drive)->busy++;
717 if (drive->id && (drive->id->config & 0x0060) == 0x20) 736 if (drive->id && (drive->id->config & 0x0060) == 0x20)
718 set_bit (IDESCSI_DRQ_INTERRUPT, &scsi->flags); 737 set_bit (IDESCSI_DRQ_INTERRUPT, &scsi->flags);
719 set_bit(IDESCSI_TRANSFORM, &scsi->transform); 738 set_bit(IDESCSI_TRANSFORM, &scsi->transform);
@@ -722,17 +741,16 @@ static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi)
722 set_bit(IDESCSI_LOG_CMD, &scsi->log); 741 set_bit(IDESCSI_LOG_CMD, &scsi->log);
723#endif /* IDESCSI_DEBUG_LOG */ 742#endif /* IDESCSI_DEBUG_LOG */
724 idescsi_add_settings(drive); 743 idescsi_add_settings(drive);
725 DRIVER(drive)->busy--;
726} 744}
727 745
728static int idescsi_cleanup (ide_drive_t *drive) 746static int ide_scsi_remove(struct device *dev)
729{ 747{
748 ide_drive_t *drive = to_ide_device(dev);
730 struct Scsi_Host *scsihost = drive->driver_data; 749 struct Scsi_Host *scsihost = drive->driver_data;
731 struct ide_scsi_obj *scsi = scsihost_to_idescsi(scsihost); 750 struct ide_scsi_obj *scsi = scsihost_to_idescsi(scsihost);
732 struct gendisk *g = scsi->disk; 751 struct gendisk *g = scsi->disk;
733 752
734 if (ide_unregister_subdriver(drive)) 753 ide_unregister_subdriver(drive, scsi->driver);
735 return 1;
736 754
737 ide_unregister_region(g); 755 ide_unregister_region(g);
738 756
@@ -746,7 +764,7 @@ static int idescsi_cleanup (ide_drive_t *drive)
746 return 0; 764 return 0;
747} 765}
748 766
749static int idescsi_attach(ide_drive_t *drive); 767static int ide_scsi_probe(struct device *);
750 768
751#ifdef CONFIG_PROC_FS 769#ifdef CONFIG_PROC_FS
752static ide_proc_entry_t idescsi_proc[] = { 770static ide_proc_entry_t idescsi_proc[] = {
@@ -757,24 +775,22 @@ static ide_proc_entry_t idescsi_proc[] = {
757# define idescsi_proc NULL 775# define idescsi_proc NULL
758#endif 776#endif
759 777
760/*
761 * IDE subdriver functions, registered with ide.c
762 */
763static ide_driver_t idescsi_driver = { 778static ide_driver_t idescsi_driver = {
764 .owner = THIS_MODULE, 779 .owner = THIS_MODULE,
765 .name = "ide-scsi", 780 .gen_driver = {
781 .name = "ide-scsi",
782 .bus = &ide_bus_type,
783 .probe = ide_scsi_probe,
784 .remove = ide_scsi_remove,
785 },
766 .version = IDESCSI_VERSION, 786 .version = IDESCSI_VERSION,
767 .media = ide_scsi, 787 .media = ide_scsi,
768 .busy = 0,
769 .supports_dsc_overlap = 0, 788 .supports_dsc_overlap = 0,
770 .proc = idescsi_proc, 789 .proc = idescsi_proc,
771 .attach = idescsi_attach,
772 .cleanup = idescsi_cleanup,
773 .do_request = idescsi_do_request, 790 .do_request = idescsi_do_request,
774 .end_request = idescsi_end_request, 791 .end_request = idescsi_end_request,
775 .error = idescsi_atapi_error, 792 .error = idescsi_atapi_error,
776 .abort = idescsi_atapi_abort, 793 .abort = idescsi_atapi_abort,
777 .drives = LIST_HEAD_INIT(idescsi_driver.drives),
778}; 794};
779 795
780static int idescsi_ide_open(struct inode *inode, struct file *filp) 796static int idescsi_ide_open(struct inode *inode, struct file *filp)
@@ -821,8 +837,6 @@ static struct block_device_operations idescsi_ops = {
821 .ioctl = idescsi_ide_ioctl, 837 .ioctl = idescsi_ide_ioctl,
822}; 838};
823 839
824static int idescsi_attach(ide_drive_t *drive);
825
826static int idescsi_slave_configure(struct scsi_device * sdp) 840static int idescsi_slave_configure(struct scsi_device * sdp)
827{ 841{
828 /* Configure detected device */ 842 /* Configure detected device */
@@ -1095,8 +1109,9 @@ static struct scsi_host_template idescsi_template = {
1095 .proc_name = "ide-scsi", 1109 .proc_name = "ide-scsi",
1096}; 1110};
1097 1111
1098static int idescsi_attach(ide_drive_t *drive) 1112static int ide_scsi_probe(struct device *dev)
1099{ 1113{
1114 ide_drive_t *drive = to_ide_device(dev);
1100 idescsi_scsi_t *idescsi; 1115 idescsi_scsi_t *idescsi;
1101 struct Scsi_Host *host; 1116 struct Scsi_Host *host;
1102 struct gendisk *g; 1117 struct gendisk *g;
@@ -1112,7 +1127,7 @@ static int idescsi_attach(ide_drive_t *drive)
1112 !drive->present || 1127 !drive->present ||
1113 drive->media == ide_disk || 1128 drive->media == ide_disk ||
1114 !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t)))) 1129 !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t))))
1115 return 1; 1130 return -ENODEV;
1116 1131
1117 g = alloc_disk(1 << PARTN_BITS); 1132 g = alloc_disk(1 << PARTN_BITS);
1118 if (!g) 1133 if (!g)
@@ -1138,20 +1153,19 @@ static int idescsi_attach(ide_drive_t *drive)
1138 idescsi->host = host; 1153 idescsi->host = host;
1139 idescsi->disk = g; 1154 idescsi->disk = g;
1140 g->private_data = &idescsi->driver; 1155 g->private_data = &idescsi->driver;
1141 err = ide_register_subdriver(drive, &idescsi_driver); 1156 ide_register_subdriver(drive, &idescsi_driver);
1157 err = 0;
1158 idescsi_setup(drive, idescsi);
1159 g->fops = &idescsi_ops;
1160 ide_register_region(g);
1161 err = scsi_add_host(host, &drive->gendev);
1142 if (!err) { 1162 if (!err) {
1143 idescsi_setup (drive, idescsi); 1163 scsi_scan_host(host);
1144 g->fops = &idescsi_ops; 1164 return 0;
1145 ide_register_region(g);
1146 err = scsi_add_host(host, &drive->gendev);
1147 if (!err) {
1148 scsi_scan_host(host);
1149 return 0;
1150 }
1151 /* fall through on error */
1152 ide_unregister_region(g);
1153 ide_unregister_subdriver(drive);
1154 } 1165 }
1166 /* fall through on error */
1167 ide_unregister_region(g);
1168 ide_unregister_subdriver(drive, &idescsi_driver);
1155 1169
1156 put_disk(g); 1170 put_disk(g);
1157out_host_put: 1171out_host_put:
@@ -1161,12 +1175,12 @@ out_host_put:
1161 1175
1162static int __init init_idescsi_module(void) 1176static int __init init_idescsi_module(void)
1163{ 1177{
1164 return ide_register_driver(&idescsi_driver); 1178 return driver_register(&idescsi_driver.gen_driver);
1165} 1179}
1166 1180
1167static void __exit exit_idescsi_module(void) 1181static void __exit exit_idescsi_module(void)
1168{ 1182{
1169 ide_unregister_driver(&idescsi_driver); 1183 driver_unregister(&idescsi_driver.gen_driver);
1170} 1184}
1171 1185
1172module_init(init_idescsi_module); 1186module_init(init_idescsi_module);
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 0b5d3a5b7eda..63d3f70d06e1 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1253,11 +1253,11 @@ void __sata_phy_reset(struct ata_port *ap)
1253 unsigned long timeout = jiffies + (HZ * 5); 1253 unsigned long timeout = jiffies + (HZ * 5);
1254 1254
1255 if (ap->flags & ATA_FLAG_SATA_RESET) { 1255 if (ap->flags & ATA_FLAG_SATA_RESET) {
1256 scr_write(ap, SCR_CONTROL, 0x301); /* issue phy wake/reset */ 1256 /* issue phy wake/reset */
1257 scr_read(ap, SCR_STATUS); /* dummy read; flush */ 1257 scr_write_flush(ap, SCR_CONTROL, 0x301);
1258 udelay(400); /* FIXME: a guess */ 1258 udelay(400); /* FIXME: a guess */
1259 } 1259 }
1260 scr_write(ap, SCR_CONTROL, 0x300); /* issue phy wake/clear reset */ 1260 scr_write_flush(ap, SCR_CONTROL, 0x300); /* phy wake/clear reset */
1261 1261
1262 /* wait for phy to become ready, if necessary */ 1262 /* wait for phy to become ready, if necessary */
1263 do { 1263 do {
@@ -2071,7 +2071,7 @@ void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
2071 sg = qc->sg; 2071 sg = qc->sg;
2072 sg->page = virt_to_page(buf); 2072 sg->page = virt_to_page(buf);
2073 sg->offset = (unsigned long) buf & ~PAGE_MASK; 2073 sg->offset = (unsigned long) buf & ~PAGE_MASK;
2074 sg_dma_len(sg) = buflen; 2074 sg->length = buflen;
2075} 2075}
2076 2076
2077void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 2077void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
@@ -2101,11 +2101,12 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
2101 dma_addr_t dma_address; 2101 dma_addr_t dma_address;
2102 2102
2103 dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt, 2103 dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt,
2104 sg_dma_len(sg), dir); 2104 sg->length, dir);
2105 if (dma_mapping_error(dma_address)) 2105 if (dma_mapping_error(dma_address))
2106 return -1; 2106 return -1;
2107 2107
2108 sg_dma_address(sg) = dma_address; 2108 sg_dma_address(sg) = dma_address;
2109 sg_dma_len(sg) = sg->length;
2109 2110
2110 DPRINTK("mapped buffer of %d bytes for %s\n", sg_dma_len(sg), 2111 DPRINTK("mapped buffer of %d bytes for %s\n", sg_dma_len(sg),
2111 qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); 2112 qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
@@ -2310,7 +2311,7 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
2310 qc->cursect++; 2311 qc->cursect++;
2311 qc->cursg_ofs++; 2312 qc->cursg_ofs++;
2312 2313
2313 if ((qc->cursg_ofs * ATA_SECT_SIZE) == sg_dma_len(&sg[qc->cursg])) { 2314 if ((qc->cursg_ofs * ATA_SECT_SIZE) == (&sg[qc->cursg])->length) {
2314 qc->cursg++; 2315 qc->cursg++;
2315 qc->cursg_ofs = 0; 2316 qc->cursg_ofs = 0;
2316 } 2317 }
@@ -2347,7 +2348,7 @@ next_page:
2347 page = nth_page(page, (offset >> PAGE_SHIFT)); 2348 page = nth_page(page, (offset >> PAGE_SHIFT));
2348 offset %= PAGE_SIZE; 2349 offset %= PAGE_SIZE;
2349 2350
2350 count = min(sg_dma_len(sg) - qc->cursg_ofs, bytes); 2351 count = min(sg->length - qc->cursg_ofs, bytes);
2351 2352
2352 /* don't cross page boundaries */ 2353 /* don't cross page boundaries */
2353 count = min(count, (unsigned int)PAGE_SIZE - offset); 2354 count = min(count, (unsigned int)PAGE_SIZE - offset);
@@ -2358,7 +2359,7 @@ next_page:
2358 qc->curbytes += count; 2359 qc->curbytes += count;
2359 qc->cursg_ofs += count; 2360 qc->cursg_ofs += count;
2360 2361
2361 if (qc->cursg_ofs == sg_dma_len(sg)) { 2362 if (qc->cursg_ofs == sg->length) {
2362 qc->cursg++; 2363 qc->cursg++;
2363 qc->cursg_ofs = 0; 2364 qc->cursg_ofs = 0;
2364 } 2365 }
@@ -2371,7 +2372,7 @@ next_page:
2371 kunmap(page); 2372 kunmap(page);
2372 2373
2373 if (bytes) { 2374 if (bytes) {
2374 if (qc->cursg_ofs < sg_dma_len(sg)) 2375 if (qc->cursg_ofs < sg->length)
2375 goto next_page; 2376 goto next_page;
2376 goto next_sg; 2377 goto next_sg;
2377 } 2378 }
@@ -2539,7 +2540,7 @@ static void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
2539 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer)); 2540 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer));
2540 qc->dma_dir = DMA_FROM_DEVICE; 2541 qc->dma_dir = DMA_FROM_DEVICE;
2541 2542
2542 memset(&qc->cdb, 0, sizeof(ap->cdb_len)); 2543 memset(&qc->cdb, 0, ap->cdb_len);
2543 qc->cdb[0] = REQUEST_SENSE; 2544 qc->cdb[0] = REQUEST_SENSE;
2544 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE; 2545 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE;
2545 2546
@@ -2811,6 +2812,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
2811 2812
2812 /* call completion callback */ 2813 /* call completion callback */
2813 rc = qc->complete_fn(qc, drv_stat); 2814 rc = qc->complete_fn(qc, drv_stat);
2815 qc->flags &= ~ATA_QCFLAG_ACTIVE;
2814 2816
2815 /* if callback indicates not to complete command (non-zero), 2817 /* if callback indicates not to complete command (non-zero),
2816 * return immediately 2818 * return immediately
@@ -3229,7 +3231,8 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
3229 struct ata_queued_cmd *qc; 3231 struct ata_queued_cmd *qc;
3230 3232
3231 qc = ata_qc_from_tag(ap, ap->active_tag); 3233 qc = ata_qc_from_tag(ap, ap->active_tag);
3232 if (qc && (!(qc->tf.ctl & ATA_NIEN))) 3234 if (qc && (!(qc->tf.ctl & ATA_NIEN)) &&
3235 (qc->flags & ATA_QCFLAG_ACTIVE))
3233 handled |= ata_host_intr(ap, qc); 3236 handled |= ata_host_intr(ap, qc);
3234 } 3237 }
3235 } 3238 }
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 4c96df060c3b..416ba67ba9ee 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -347,7 +347,10 @@ int ata_scsi_slave_config(struct scsi_device *sdev)
347 */ 347 */
348 if ((dev->flags & ATA_DFLAG_LBA48) && 348 if ((dev->flags & ATA_DFLAG_LBA48) &&
349 ((dev->flags & ATA_DFLAG_LOCK_SECTORS) == 0)) { 349 ((dev->flags & ATA_DFLAG_LOCK_SECTORS) == 0)) {
350 sdev->host->max_sectors = 2048; 350 /*
351 * do not overwrite sdev->host->max_sectors, since
352 * other drives on this host may not support LBA48
353 */
351 blk_queue_max_sectors(sdev->request_queue, 2048); 354 blk_queue_max_sectors(sdev->request_queue, 2048);
352 } 355 }
353 } 356 }
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index 19a13e3590f4..c4e9e0298122 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -151,6 +151,8 @@ static struct ata_port_info pdc_port_info[] = {
151static struct pci_device_id pdc_ata_pci_tbl[] = { 151static struct pci_device_id pdc_ata_pci_tbl[] = {
152 { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 152 { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
153 board_2037x }, 153 board_2037x },
154 { PCI_VENDOR_ID_PROMISE, 0x3571, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
155 board_2037x },
154 { PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 156 { PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
155 board_2037x }, 157 board_2037x },
156 { PCI_VENDOR_ID_PROMISE, 0x3375, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 158 { PCI_VENDOR_ID_PROMISE, 0x3375, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index f0489dc302a0..2b2ff48be396 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -82,6 +82,7 @@ static struct pci_device_id sil_pci_tbl[] = {
82 { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 }, 82 { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 },
83 { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 83 { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
84 { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 84 { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
85 { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
85 { } /* terminate list */ 86 { } /* terminate list */
86}; 87};
87 88
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 8d1a5d25c053..05075bd3a893 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -395,7 +395,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
395 395
396 /* Clear a magic bit in SCR1 according to Darwin, those help 396 /* Clear a magic bit in SCR1 according to Darwin, those help
397 * some funky seagate drives (though so far, those were already 397 * some funky seagate drives (though so far, those were already
398 * set by the firmware on the machines I had access to 398 * set by the firmware on the machines I had access to)
399 */ 399 */
400 writel(readl(mmio_base + K2_SATA_SICR1_OFFSET) & ~0x00040000, 400 writel(readl(mmio_base + K2_SATA_SICR1_OFFSET) & ~0x00040000,
401 mmio_base + K2_SATA_SICR1_OFFSET); 401 mmio_base + K2_SATA_SICR1_OFFSET);
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 28966d05435c..67c6cc40ce16 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -35,7 +35,7 @@
35 35
36#define SPI_PRINTK(x, l, f, a...) dev_printk(l, &(x)->dev, f , ##a) 36#define SPI_PRINTK(x, l, f, a...) dev_printk(l, &(x)->dev, f , ##a)
37 37
38#define SPI_NUM_ATTRS 10 /* increase this if you add attributes */ 38#define SPI_NUM_ATTRS 13 /* increase this if you add attributes */
39#define SPI_OTHER_ATTRS 1 /* Increase this if you add "always 39#define SPI_OTHER_ATTRS 1 /* Increase this if you add "always
40 * on" attributes */ 40 * on" attributes */
41#define SPI_HOST_ATTRS 1 41#define SPI_HOST_ATTRS 1
@@ -219,8 +219,11 @@ static int spi_setup_transport_attrs(struct device *dev)
219 struct scsi_target *starget = to_scsi_target(dev); 219 struct scsi_target *starget = to_scsi_target(dev);
220 220
221 spi_period(starget) = -1; /* illegal value */ 221 spi_period(starget) = -1; /* illegal value */
222 spi_min_period(starget) = 0;
222 spi_offset(starget) = 0; /* async */ 223 spi_offset(starget) = 0; /* async */
224 spi_max_offset(starget) = 255;
223 spi_width(starget) = 0; /* narrow */ 225 spi_width(starget) = 0; /* narrow */
226 spi_max_width(starget) = 1;
224 spi_iu(starget) = 0; /* no IU */ 227 spi_iu(starget) = 0; /* no IU */
225 spi_dt(starget) = 0; /* ST */ 228 spi_dt(starget) = 0; /* ST */
226 spi_qas(starget) = 0; 229 spi_qas(starget) = 0;
@@ -235,6 +238,34 @@ static int spi_setup_transport_attrs(struct device *dev)
235 return 0; 238 return 0;
236} 239}
237 240
241#define spi_transport_show_simple(field, format_string) \
242 \
243static ssize_t \
244show_spi_transport_##field(struct class_device *cdev, char *buf) \
245{ \
246 struct scsi_target *starget = transport_class_to_starget(cdev); \
247 struct spi_transport_attrs *tp; \
248 \
249 tp = (struct spi_transport_attrs *)&starget->starget_data; \
250 return snprintf(buf, 20, format_string, tp->field); \
251}
252
253#define spi_transport_store_simple(field, format_string) \
254 \
255static ssize_t \
256store_spi_transport_##field(struct class_device *cdev, const char *buf, \
257 size_t count) \
258{ \
259 int val; \
260 struct scsi_target *starget = transport_class_to_starget(cdev); \
261 struct spi_transport_attrs *tp; \
262 \
263 tp = (struct spi_transport_attrs *)&starget->starget_data; \
264 val = simple_strtoul(buf, NULL, 0); \
265 tp->field = val; \
266 return count; \
267}
268
238#define spi_transport_show_function(field, format_string) \ 269#define spi_transport_show_function(field, format_string) \
239 \ 270 \
240static ssize_t \ 271static ssize_t \
@@ -261,6 +292,25 @@ store_spi_transport_##field(struct class_device *cdev, const char *buf, \
261 struct spi_internal *i = to_spi_internal(shost->transportt); \ 292 struct spi_internal *i = to_spi_internal(shost->transportt); \
262 \ 293 \
263 val = simple_strtoul(buf, NULL, 0); \ 294 val = simple_strtoul(buf, NULL, 0); \
295 i->f->set_##field(starget, val); \
296 return count; \
297}
298
299#define spi_transport_store_max(field, format_string) \
300static ssize_t \
301store_spi_transport_##field(struct class_device *cdev, const char *buf, \
302 size_t count) \
303{ \
304 int val; \
305 struct scsi_target *starget = transport_class_to_starget(cdev); \
306 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
307 struct spi_internal *i = to_spi_internal(shost->transportt); \
308 struct spi_transport_attrs *tp \
309 = (struct spi_transport_attrs *)&starget->starget_data; \
310 \
311 val = simple_strtoul(buf, NULL, 0); \
312 if (val > tp->max_##field) \
313 val = tp->max_##field; \
264 i->f->set_##field(starget, val); \ 314 i->f->set_##field(starget, val); \
265 return count; \ 315 return count; \
266} 316}
@@ -272,9 +322,24 @@ static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \
272 show_spi_transport_##field, \ 322 show_spi_transport_##field, \
273 store_spi_transport_##field); 323 store_spi_transport_##field);
274 324
325#define spi_transport_simple_attr(field, format_string) \
326 spi_transport_show_simple(field, format_string) \
327 spi_transport_store_simple(field, format_string) \
328static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \
329 show_spi_transport_##field, \
330 store_spi_transport_##field);
331
332#define spi_transport_max_attr(field, format_string) \
333 spi_transport_show_function(field, format_string) \
334 spi_transport_store_max(field, format_string) \
335 spi_transport_simple_attr(max_##field, format_string) \
336static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \
337 show_spi_transport_##field, \
338 store_spi_transport_##field);
339
275/* The Parallel SCSI Tranport Attributes: */ 340/* The Parallel SCSI Tranport Attributes: */
276spi_transport_rd_attr(offset, "%d\n"); 341spi_transport_max_attr(offset, "%d\n");
277spi_transport_rd_attr(width, "%d\n"); 342spi_transport_max_attr(width, "%d\n");
278spi_transport_rd_attr(iu, "%d\n"); 343spi_transport_rd_attr(iu, "%d\n");
279spi_transport_rd_attr(dt, "%d\n"); 344spi_transport_rd_attr(dt, "%d\n");
280spi_transport_rd_attr(qas, "%d\n"); 345spi_transport_rd_attr(qas, "%d\n");
@@ -300,26 +365,18 @@ static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);
300 365
301/* Translate the period into ns according to the current spec 366/* Translate the period into ns according to the current spec
302 * for SDTR/PPR messages */ 367 * for SDTR/PPR messages */
303static ssize_t show_spi_transport_period(struct class_device *cdev, char *buf) 368static ssize_t
304 369show_spi_transport_period_helper(struct class_device *cdev, char *buf,
370 int period)
305{ 371{
306 struct scsi_target *starget = transport_class_to_starget(cdev);
307 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
308 struct spi_transport_attrs *tp;
309 int len, picosec; 372 int len, picosec;
310 struct spi_internal *i = to_spi_internal(shost->transportt);
311
312 tp = (struct spi_transport_attrs *)&starget->starget_data;
313
314 if (i->f->get_period)
315 i->f->get_period(starget);
316 373
317 if (tp->period < 0 || tp->period > 0xff) { 374 if (period < 0 || period > 0xff) {
318 picosec = -1; 375 picosec = -1;
319 } else if (tp->period <= SPI_STATIC_PPR) { 376 } else if (period <= SPI_STATIC_PPR) {
320 picosec = ppr_to_ps[tp->period]; 377 picosec = ppr_to_ps[period];
321 } else { 378 } else {
322 picosec = tp->period * 4000; 379 picosec = period * 4000;
323 } 380 }
324 381
325 if (picosec == -1) { 382 if (picosec == -1) {
@@ -334,12 +391,9 @@ static ssize_t show_spi_transport_period(struct class_device *cdev, char *buf)
334} 391}
335 392
336static ssize_t 393static ssize_t
337store_spi_transport_period(struct class_device *cdev, const char *buf, 394store_spi_transport_period_helper(struct class_device *cdev, const char *buf,
338 size_t count) 395 size_t count, int *periodp)
339{ 396{
340 struct scsi_target *starget = transport_class_to_starget(cdev);
341 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
342 struct spi_internal *i = to_spi_internal(shost->transportt);
343 int j, picosec, period = -1; 397 int j, picosec, period = -1;
344 char *endp; 398 char *endp;
345 399
@@ -368,15 +422,79 @@ store_spi_transport_period(struct class_device *cdev, const char *buf,
368 if (period > 0xff) 422 if (period > 0xff)
369 period = 0xff; 423 period = 0xff;
370 424
371 i->f->set_period(starget, period); 425 *periodp = period;
372 426
373 return count; 427 return count;
374} 428}
375 429
430static ssize_t
431show_spi_transport_period(struct class_device *cdev, char *buf)
432{
433 struct scsi_target *starget = transport_class_to_starget(cdev);
434 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
435 struct spi_internal *i = to_spi_internal(shost->transportt);
436 struct spi_transport_attrs *tp =
437 (struct spi_transport_attrs *)&starget->starget_data;
438
439 if (i->f->get_period)
440 i->f->get_period(starget);
441
442 return show_spi_transport_period_helper(cdev, buf, tp->period);
443}
444
445static ssize_t
446store_spi_transport_period(struct class_device *cdev, const char *buf,
447 size_t count)
448{
449 struct scsi_target *starget = transport_class_to_starget(cdev);
450 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
451 struct spi_internal *i = to_spi_internal(shost->transportt);
452 struct spi_transport_attrs *tp =
453 (struct spi_transport_attrs *)&starget->starget_data;
454 int period, retval;
455
456 retval = store_spi_transport_period_helper(cdev, buf, count, &period);
457
458 if (period < tp->min_period)
459 period = tp->min_period;
460
461 i->f->set_period(starget, period);
462
463 return retval;
464}
465
376static CLASS_DEVICE_ATTR(period, S_IRUGO | S_IWUSR, 466static CLASS_DEVICE_ATTR(period, S_IRUGO | S_IWUSR,
377 show_spi_transport_period, 467 show_spi_transport_period,
378 store_spi_transport_period); 468 store_spi_transport_period);
379 469
470static ssize_t
471show_spi_transport_min_period(struct class_device *cdev, char *buf)
472{
473 struct scsi_target *starget = transport_class_to_starget(cdev);
474 struct spi_transport_attrs *tp =
475 (struct spi_transport_attrs *)&starget->starget_data;
476
477 return show_spi_transport_period_helper(cdev, buf, tp->min_period);
478}
479
480static ssize_t
481store_spi_transport_min_period(struct class_device *cdev, const char *buf,
482 size_t count)
483{
484 struct scsi_target *starget = transport_class_to_starget(cdev);
485 struct spi_transport_attrs *tp =
486 (struct spi_transport_attrs *)&starget->starget_data;
487
488 return store_spi_transport_period_helper(cdev, buf, count,
489 &tp->min_period);
490}
491
492
493static CLASS_DEVICE_ATTR(min_period, S_IRUGO | S_IWUSR,
494 show_spi_transport_min_period,
495 store_spi_transport_min_period);
496
497
380static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf) 498static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf)
381{ 499{
382 struct Scsi_Host *shost = transport_class_to_shost(cdev); 500 struct Scsi_Host *shost = transport_class_to_shost(cdev);
@@ -642,6 +760,7 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
642{ 760{
643 struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt); 761 struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt);
644 struct scsi_device *sdev = sreq->sr_device; 762 struct scsi_device *sdev = sreq->sr_device;
763 struct scsi_target *starget = sdev->sdev_target;
645 int len = sdev->inquiry_len; 764 int len = sdev->inquiry_len;
646 /* first set us up for narrow async */ 765 /* first set us up for narrow async */
647 DV_SET(offset, 0); 766 DV_SET(offset, 0);
@@ -655,9 +774,11 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
655 } 774 }
656 775
657 /* test width */ 776 /* test width */
658 if (i->f->set_width && sdev->wdtr) { 777 if (i->f->set_width && spi_max_width(starget) && sdev->wdtr) {
659 i->f->set_width(sdev->sdev_target, 1); 778 i->f->set_width(sdev->sdev_target, 1);
660 779
780 printk("WIDTH IS %d\n", spi_max_width(starget));
781
661 if (spi_dv_device_compare_inquiry(sreq, buffer, 782 if (spi_dv_device_compare_inquiry(sreq, buffer,
662 buffer + len, 783 buffer + len,
663 DV_LOOPS) 784 DV_LOOPS)
@@ -684,8 +805,8 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
684 retry: 805 retry:
685 806
686 /* now set up to the maximum */ 807 /* now set up to the maximum */
687 DV_SET(offset, 255); 808 DV_SET(offset, spi_max_offset(starget));
688 DV_SET(period, 1); 809 DV_SET(period, spi_min_period(starget));
689 810
690 if (len == 0) { 811 if (len == 0) {
691 SPI_PRINTK(sdev->sdev_target, KERN_INFO, "Domain Validation skipping write tests\n"); 812 SPI_PRINTK(sdev->sdev_target, KERN_INFO, "Domain Validation skipping write tests\n");
@@ -892,6 +1013,16 @@ EXPORT_SYMBOL(spi_display_xfer_agreement);
892 if (i->f->show_##field) \ 1013 if (i->f->show_##field) \
893 count++ 1014 count++
894 1015
1016#define SETUP_RELATED_ATTRIBUTE(field, rel_field) \
1017 i->private_attrs[count] = class_device_attr_##field; \
1018 if (!i->f->set_##rel_field) { \
1019 i->private_attrs[count].attr.mode = S_IRUGO; \
1020 i->private_attrs[count].store = NULL; \
1021 } \
1022 i->attrs[count] = &i->private_attrs[count]; \
1023 if (i->f->show_##rel_field) \
1024 count++
1025
895#define SETUP_HOST_ATTRIBUTE(field) \ 1026#define SETUP_HOST_ATTRIBUTE(field) \
896 i->private_host_attrs[count] = class_device_attr_##field; \ 1027 i->private_host_attrs[count] = class_device_attr_##field; \
897 if (!i->f->set_##field) { \ 1028 if (!i->f->set_##field) { \
@@ -975,8 +1106,11 @@ spi_attach_transport(struct spi_function_template *ft)
975 i->f = ft; 1106 i->f = ft;
976 1107
977 SETUP_ATTRIBUTE(period); 1108 SETUP_ATTRIBUTE(period);
1109 SETUP_RELATED_ATTRIBUTE(min_period, period);
978 SETUP_ATTRIBUTE(offset); 1110 SETUP_ATTRIBUTE(offset);
1111 SETUP_RELATED_ATTRIBUTE(max_offset, offset);
979 SETUP_ATTRIBUTE(width); 1112 SETUP_ATTRIBUTE(width);
1113 SETUP_RELATED_ATTRIBUTE(max_width, width);
980 SETUP_ATTRIBUTE(iu); 1114 SETUP_ATTRIBUTE(iu);
981 SETUP_ATTRIBUTE(dt); 1115 SETUP_ATTRIBUTE(dt);
982 SETUP_ATTRIBUTE(qas); 1116 SETUP_ATTRIBUTE(qas);
diff --git a/drivers/serial/21285.c b/drivers/serial/21285.c
index 33fbda79f350..0b10169961eb 100644
--- a/drivers/serial/21285.c
+++ b/drivers/serial/21285.c
@@ -126,18 +126,8 @@ static irqreturn_t serial21285_rx_chars(int irq, void *dev_id, struct pt_regs *r
126 flag = TTY_FRAME; 126 flag = TTY_FRAME;
127 } 127 }
128 128
129 if ((rxs & port->ignore_status_mask) == 0) { 129 uart_insert_char(port, rxs, RXSTAT_OVERRUN, ch, flag);
130 tty_insert_flip_char(tty, ch, flag); 130
131 }
132 if ((rxs & RXSTAT_OVERRUN) &&
133 tty->flip.count < TTY_FLIPBUF_SIZE) {
134 /*
135 * Overrun is special, since it's reported
136 * immediately, and doesn't affect the current
137 * character.
138 */
139 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
140 }
141 status = *CSR_UARTFLG; 131 status = *CSR_UARTFLG;
142 } 132 }
143 tty_flip_buffer_push(tty); 133 tty_flip_buffer_push(tty);
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 0d9358608fdf..30e8beb71430 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -682,8 +682,6 @@ static void autoconfig_16550a(struct uart_8250_port *up)
682 * from EXCR1. Switch back to bank 0, change it in MCR. Then 682 * from EXCR1. Switch back to bank 0, change it in MCR. Then
683 * switch back to bank 2, read it from EXCR1 again and check 683 * switch back to bank 2, read it from EXCR1 again and check
684 * it's changed. If so, set baud_base in EXCR2 to 921600. -- dwmw2 684 * it's changed. If so, set baud_base in EXCR2 to 921600. -- dwmw2
685 * On PowerPC we don't want to change baud_base, as we have
686 * a number of different divisors. -- Tom Rini
687 */ 685 */
688 serial_outp(up, UART_LCR, 0); 686 serial_outp(up, UART_LCR, 0);
689 status1 = serial_in(up, UART_MCR); 687 status1 = serial_in(up, UART_MCR);
@@ -699,16 +697,25 @@ static void autoconfig_16550a(struct uart_8250_port *up)
699 serial_outp(up, UART_MCR, status1); 697 serial_outp(up, UART_MCR, status1);
700 698
701 if ((status2 ^ status1) & UART_MCR_LOOP) { 699 if ((status2 ^ status1) & UART_MCR_LOOP) {
702#ifndef CONFIG_PPC 700 unsigned short quot;
701
703 serial_outp(up, UART_LCR, 0xE0); 702 serial_outp(up, UART_LCR, 0xE0);
703
704 quot = serial_inp(up, UART_DLM) << 8;
705 quot += serial_inp(up, UART_DLL);
706 quot <<= 3;
707
704 status1 = serial_in(up, 0x04); /* EXCR1 */ 708 status1 = serial_in(up, 0x04); /* EXCR1 */
705 status1 &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */ 709 status1 &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */
706 status1 |= 0x10; /* 1.625 divisor for baud_base --> 921600 */ 710 status1 |= 0x10; /* 1.625 divisor for baud_base --> 921600 */
707 serial_outp(up, 0x04, status1); 711 serial_outp(up, 0x04, status1);
712
713 serial_outp(up, UART_DLL, quot & 0xff);
714 serial_outp(up, UART_DLM, quot >> 8);
715
708 serial_outp(up, UART_LCR, 0); 716 serial_outp(up, UART_LCR, 0);
709 up->port.uartclk = 921600*16;
710#endif
711 717
718 up->port.uartclk = 921600*16;
712 up->port.type = PORT_NS16550A; 719 up->port.type = PORT_NS16550A;
713 up->capabilities |= UART_NATSEMI; 720 up->capabilities |= UART_NATSEMI;
714 return; 721 return;
@@ -1122,18 +1129,9 @@ receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs)
1122 } 1129 }
1123 if (uart_handle_sysrq_char(&up->port, ch, regs)) 1130 if (uart_handle_sysrq_char(&up->port, ch, regs))
1124 goto ignore_char; 1131 goto ignore_char;
1125 if ((lsr & up->port.ignore_status_mask) == 0) { 1132
1126 tty_insert_flip_char(tty, ch, flag); 1133 uart_insert_char(&up->port, lsr, UART_LSR_OE, ch, flag);
1127 } 1134
1128 if ((lsr & UART_LSR_OE) &&
1129 tty->flip.count < TTY_FLIPBUF_SIZE) {
1130 /*
1131 * Overrun is special, since it's reported
1132 * immediately, and doesn't affect the current
1133 * character.
1134 */
1135 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
1136 }
1137 ignore_char: 1135 ignore_char:
1138 lsr = serial_inp(up, UART_LSR); 1136 lsr = serial_inp(up, UART_LSR);
1139 } while ((lsr & UART_LSR_DR) && (max_count-- > 0)); 1137 } while ((lsr & UART_LSR_DR) && (max_count-- > 0));
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index f2a5e2933c47..2884b310e54d 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -198,18 +198,8 @@ pl010_rx_chars(struct uart_port *port)
198 if (uart_handle_sysrq_char(port, ch, regs)) 198 if (uart_handle_sysrq_char(port, ch, regs))
199 goto ignore_char; 199 goto ignore_char;
200 200
201 if ((rsr & port->ignore_status_mask) == 0) { 201 uart_insert_char(port, rsr, UART01x_RSR_OE, ch, flag);
202 tty_insert_flip_char(tty, ch, flag); 202
203 }
204 if ((rsr & UART01x_RSR_OE) &&
205 tty->flip.count < TTY_FLIPBUF_SIZE) {
206 /*
207 * Overrun is special, since it's reported
208 * immediately, and doesn't affect the current
209 * character
210 */
211 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
212 }
213 ignore_char: 203 ignore_char:
214 status = UART_GET_FR(port); 204 status = UART_GET_FR(port);
215 } 205 }
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index d5cbef3fe8b6..7db88ee18f75 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -163,18 +163,8 @@ pl011_rx_chars(struct uart_amba_port *uap)
163 if (uart_handle_sysrq_char(&uap->port, ch, regs)) 163 if (uart_handle_sysrq_char(&uap->port, ch, regs))
164 goto ignore_char; 164 goto ignore_char;
165 165
166 if ((rsr & uap->port.ignore_status_mask) == 0) { 166 uart_insert_char(&uap->port, rsr, UART01x_RSR_OE, ch, flag);
167 tty_insert_flip_char(tty, ch, flag); 167
168 }
169 if ((rsr & UART01x_RSR_OE) &&
170 tty->flip.count < TTY_FLIPBUF_SIZE) {
171 /*
172 * Overrun is special, since it's reported
173 * immediately, and doesn't affect the current
174 * character
175 */
176 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
177 }
178 ignore_char: 168 ignore_char:
179 status = readw(uap->port.membase + UART01x_FR); 169 status = readw(uap->port.membase + UART01x_FR);
180 } 170 }
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
index 6242f3090a96..e92522b33c48 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/serial/clps711x.c
@@ -143,10 +143,7 @@ static irqreturn_t clps711xuart_int_rx(int irq, void *dev_id, struct pt_regs *re
143 * CHECK: does overrun affect the current character? 143 * CHECK: does overrun affect the current character?
144 * ASSUMPTION: it does not. 144 * ASSUMPTION: it does not.
145 */ 145 */
146 if ((ch & port->ignore_status_mask & ~RXSTAT_OVERRUN) == 0) 146 uart_insert_char(port, ch, UARTDR_OVERR, ch, flg);
147 tty_insert_flip_char(tty, ch, flg);
148 if ((ch & ~port->ignore_status_mask & RXSTAT_OVERRUN) == 0)
149 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
150 147
151 ignore_char: 148 ignore_char:
152 status = clps_readl(SYSFLG(port)); 149 status = clps_readl(SYSFLG(port));
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index 51d8a49f4477..9dc151d8fa61 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -161,20 +161,12 @@ receive_chars(struct uart_pxa_port *up, int *status, struct pt_regs *regs)
161 else if (*status & UART_LSR_FE) 161 else if (*status & UART_LSR_FE)
162 flag = TTY_FRAME; 162 flag = TTY_FRAME;
163 } 163 }
164
164 if (uart_handle_sysrq_char(&up->port, ch, regs)) 165 if (uart_handle_sysrq_char(&up->port, ch, regs))
165 goto ignore_char; 166 goto ignore_char;
166 if ((*status & up->port.ignore_status_mask) == 0) { 167
167 tty_insert_flip_char(tty, ch, flag); 168 uart_insert_char(&up->port, *status, UART_LSR_OE, ch, flag);
168 } 169
169 if ((*status & UART_LSR_OE) &&
170 tty->flip.count < TTY_FLIPBUF_SIZE) {
171 /*
172 * Overrun is special, since it's reported
173 * immediately, and doesn't affect the current
174 * character.
175 */
176 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
177 }
178 ignore_char: 170 ignore_char:
179 *status = serial_in(up, UART_LSR); 171 *status = serial_in(up, UART_LSR);
180 } while ((*status & UART_LSR_DR) && (max_count-- > 0)); 172 } while ((*status & UART_LSR_DR) && (max_count-- > 0));
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 435750d40a47..2a9f7ade2c9d 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -394,20 +394,7 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id, struct pt_regs *regs)
394 if (uart_handle_sysrq_char(port, ch, regs)) 394 if (uart_handle_sysrq_char(port, ch, regs))
395 goto ignore_char; 395 goto ignore_char;
396 396
397 if ((uerstat & port->ignore_status_mask) == 0) { 397 uart_insert_char(port, uerstat, S3C2410_UERSTAT_OVERRUN, ch, flag);
398 tty_insert_flip_char(tty, ch, flag);
399 }
400
401 if ((uerstat & S3C2410_UERSTAT_OVERRUN) &&
402 tty->flip.count < TTY_FLIPBUF_SIZE) {
403 /*
404 * Overrun is special, since it's reported
405 * immediately, and doesn't affect the current
406 * character.
407 */
408
409 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
410 }
411 398
412 ignore_char: 399 ignore_char:
413 continue; 400 continue;
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index 157218bc6c6f..22565a67a57c 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -237,10 +237,7 @@ sa1100_rx_chars(struct sa1100_port *sport, struct pt_regs *regs)
237 if (uart_handle_sysrq_char(&sport->port, ch, regs)) 237 if (uart_handle_sysrq_char(&sport->port, ch, regs))
238 goto ignore_char; 238 goto ignore_char;
239 239
240 if ((status & port->ignore_status_mask & ~UTSR1_TO_SM(UTSR1_ROR)) == 0) 240 uart_insert_char(&sport->port, status, UTSR1_TO_SM(UTSR1_ROR), ch, flg);
241 tty_insert_flip_char(tty, ch, flg);
242 if (status & ~port->ignore_status_mask & UTSR1_TO_SM(UTSR1_ROR))
243 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
244 241
245 ignore_char: 242 ignore_char:
246 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | 243 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) |
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 6eeb48f6a482..0d7b65f93e8d 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -661,10 +661,10 @@ void serial_config(dev_link_t * link)
661 /* Is this a multiport card? */ 661 /* Is this a multiport card? */
662 tuple->DesiredTuple = CISTPL_MANFID; 662 tuple->DesiredTuple = CISTPL_MANFID;
663 if (first_tuple(handle, tuple, parse) == CS_SUCCESS) { 663 if (first_tuple(handle, tuple, parse) == CS_SUCCESS) {
664 info->manfid = le16_to_cpu(buf[0]); 664 info->manfid = parse->manfid.manf;
665 for (i = 0; i < MULTI_COUNT; i++) 665 for (i = 0; i < MULTI_COUNT; i++)
666 if ((info->manfid == multi_id[i].manfid) && 666 if ((info->manfid == multi_id[i].manfid) &&
667 (le16_to_cpu(buf[1]) == multi_id[i].prodid)) 667 (parse->manfid.card == multi_id[i].prodid))
668 break; 668 break;
669 if (i < MULTI_COUNT) 669 if (i < MULTI_COUNT)
670 info->multi = multi_id[i].multi; 670 info->multi = multi_id[i].multi;
diff --git a/drivers/serial/serial_lh7a40x.c b/drivers/serial/serial_lh7a40x.c
index 85cfa08d3bad..56f269b6bfb1 100644
--- a/drivers/serial/serial_lh7a40x.c
+++ b/drivers/serial/serial_lh7a40x.c
@@ -190,18 +190,7 @@ lh7a40xuart_rx_chars (struct uart_port* port)
190 if (uart_handle_sysrq_char (port, (unsigned char) data, regs)) 190 if (uart_handle_sysrq_char (port, (unsigned char) data, regs))
191 continue; 191 continue;
192 192
193 if ((data & port->ignore_status_mask) == 0) { 193 uart_insert_char(port, data, RxOverrunError, data, flag);
194 tty_insert_flip_char(tty, data, flag);
195 }
196 if ((data & RxOverrunError)
197 && tty->flip.count < TTY_FLIPBUF_SIZE) {
198 /*
199 * Overrun is special, since it's reported
200 * immediately, and doesn't affect the current
201 * character
202 */
203 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
204 }
205 } 194 }
206 tty_flip_buffer_push (tty); 195 tty_flip_buffer_push (tty);
207 return; 196 return;
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index 37b2ef297cbe..3f1051a4a13f 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -350,18 +350,9 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *r
350 } 350 }
351 if (uart_handle_sysrq_char(&up->port, ch, regs)) 351 if (uart_handle_sysrq_char(&up->port, ch, regs))
352 goto ignore_char; 352 goto ignore_char;
353 if ((disr & up->port.ignore_status_mask) == 0) { 353
354 tty_insert_flip_char(tty, ch, flag); 354 uart_insert_char(&up->port, disr, TXX9_SIDISR_UOER, ch, flag);
355 } 355
356 if ((disr & TXX9_SIDISR_UOER) &&
357 tty->flip.count < TTY_FLIPBUF_SIZE) {
358 /*
359 * Overrun is special, since it's reported
360 * immediately, and doesn't affect the current
361 * character.
362 */
363 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
364 }
365 ignore_char: 356 ignore_char:
366 disr = sio_in(up, TXX9_SIDISR); 357 disr = sio_in(up, TXX9_SIDISR);
367 } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0)); 358 } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0));
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
index 39b788d95e39..10e2990a40d4 100644
--- a/drivers/serial/sunsab.c
+++ b/drivers/serial/sunsab.c
@@ -61,6 +61,16 @@ struct uart_sunsab_port {
61 unsigned char pvr_dtr_bit; /* Which PVR bit is DTR */ 61 unsigned char pvr_dtr_bit; /* Which PVR bit is DTR */
62 unsigned char pvr_dsr_bit; /* Which PVR bit is DSR */ 62 unsigned char pvr_dsr_bit; /* Which PVR bit is DSR */
63 int type; /* SAB82532 version */ 63 int type; /* SAB82532 version */
64
65 /* Setting configuration bits while the transmitter is active
66 * can cause garbage characters to get emitted by the chip.
67 * Therefore, we cache such writes here and do the real register
68 * write the next time the transmitter becomes idle.
69 */
70 unsigned int cached_ebrg;
71 unsigned char cached_mode;
72 unsigned char cached_pvr;
73 unsigned char cached_dafo;
64}; 74};
65 75
66/* 76/*
@@ -236,6 +246,7 @@ receive_chars(struct uart_sunsab_port *up,
236} 246}
237 247
238static void sunsab_stop_tx(struct uart_port *, unsigned int); 248static void sunsab_stop_tx(struct uart_port *, unsigned int);
249static void sunsab_tx_idle(struct uart_sunsab_port *);
239 250
240static void transmit_chars(struct uart_sunsab_port *up, 251static void transmit_chars(struct uart_sunsab_port *up,
241 union sab82532_irq_status *stat) 252 union sab82532_irq_status *stat)
@@ -258,6 +269,7 @@ static void transmit_chars(struct uart_sunsab_port *up,
258 return; 269 return;
259 270
260 set_bit(SAB82532_XPR, &up->irqflags); 271 set_bit(SAB82532_XPR, &up->irqflags);
272 sunsab_tx_idle(up);
261 273
262 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) { 274 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
263 up->interrupt_mask1 |= SAB82532_IMR1_XPR; 275 up->interrupt_mask1 |= SAB82532_IMR1_XPR;
@@ -397,21 +409,21 @@ static void sunsab_set_mctrl(struct uart_port *port, unsigned int mctrl)
397 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 409 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
398 410
399 if (mctrl & TIOCM_RTS) { 411 if (mctrl & TIOCM_RTS) {
400 writeb(readb(&up->regs->rw.mode) & ~SAB82532_MODE_FRTS, 412 up->cached_mode &= ~SAB82532_MODE_FRTS;
401 &up->regs->rw.mode); 413 up->cached_mode |= SAB82532_MODE_RTS;
402 writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RTS,
403 &up->regs->rw.mode);
404 } else { 414 } else {
405 writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_FRTS, 415 up->cached_mode |= (SAB82532_MODE_FRTS |
406 &up->regs->rw.mode); 416 SAB82532_MODE_RTS);
407 writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RTS,
408 &up->regs->rw.mode);
409 } 417 }
410 if (mctrl & TIOCM_DTR) { 418 if (mctrl & TIOCM_DTR) {
411 writeb(readb(&up->regs->rw.pvr) & ~(up->pvr_dtr_bit), &up->regs->rw.pvr); 419 up->cached_pvr &= ~(up->pvr_dtr_bit);
412 } else { 420 } else {
413 writeb(readb(&up->regs->rw.pvr) | up->pvr_dtr_bit, &up->regs->rw.pvr); 421 up->cached_pvr |= up->pvr_dtr_bit;
414 } 422 }
423
424 set_bit(SAB82532_REGS_PENDING, &up->irqflags);
425 if (test_bit(SAB82532_XPR, &up->irqflags))
426 sunsab_tx_idle(up);
415} 427}
416 428
417/* port->lock is not held. */ 429/* port->lock is not held. */
@@ -450,6 +462,25 @@ static void sunsab_stop_tx(struct uart_port *port, unsigned int tty_stop)
450} 462}
451 463
452/* port->lock held by caller. */ 464/* port->lock held by caller. */
465static void sunsab_tx_idle(struct uart_sunsab_port *up)
466{
467 if (test_bit(SAB82532_REGS_PENDING, &up->irqflags)) {
468 u8 tmp;
469
470 clear_bit(SAB82532_REGS_PENDING, &up->irqflags);
471 writeb(up->cached_mode, &up->regs->rw.mode);
472 writeb(up->cached_pvr, &up->regs->rw.pvr);
473 writeb(up->cached_dafo, &up->regs->w.dafo);
474
475 writeb(up->cached_ebrg & 0xff, &up->regs->w.bgr);
476 tmp = readb(&up->regs->rw.ccr2);
477 tmp &= ~0xc0;
478 tmp |= (up->cached_ebrg >> 2) & 0xc0;
479 writeb(tmp, &up->regs->rw.ccr2);
480 }
481}
482
483/* port->lock held by caller. */
453static void sunsab_start_tx(struct uart_port *port, unsigned int tty_start) 484static void sunsab_start_tx(struct uart_port *port, unsigned int tty_start)
454{ 485{
455 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 486 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
@@ -517,12 +548,16 @@ static void sunsab_break_ctl(struct uart_port *port, int break_state)
517 548
518 spin_lock_irqsave(&up->port.lock, flags); 549 spin_lock_irqsave(&up->port.lock, flags);
519 550
520 val = readb(&up->regs->rw.dafo); 551 val = up->cached_dafo;
521 if (break_state) 552 if (break_state)
522 val |= SAB82532_DAFO_XBRK; 553 val |= SAB82532_DAFO_XBRK;
523 else 554 else
524 val &= ~SAB82532_DAFO_XBRK; 555 val &= ~SAB82532_DAFO_XBRK;
525 writeb(val, &up->regs->rw.dafo); 556 up->cached_dafo = val;
557
558 set_bit(SAB82532_REGS_PENDING, &up->irqflags);
559 if (test_bit(SAB82532_XPR, &up->irqflags))
560 sunsab_tx_idle(up);
526 561
527 spin_unlock_irqrestore(&up->port.lock, flags); 562 spin_unlock_irqrestore(&up->port.lock, flags);
528} 563}
@@ -566,8 +601,9 @@ static int sunsab_startup(struct uart_port *port)
566 SAB82532_CCR2_TOE, &up->regs->w.ccr2); 601 SAB82532_CCR2_TOE, &up->regs->w.ccr2);
567 writeb(0, &up->regs->w.ccr3); 602 writeb(0, &up->regs->w.ccr3);
568 writeb(SAB82532_CCR4_MCK4 | SAB82532_CCR4_EBRG, &up->regs->w.ccr4); 603 writeb(SAB82532_CCR4_MCK4 | SAB82532_CCR4_EBRG, &up->regs->w.ccr4);
569 writeb(SAB82532_MODE_RTS | SAB82532_MODE_FCTS | 604 up->cached_mode = (SAB82532_MODE_RTS | SAB82532_MODE_FCTS |
570 SAB82532_MODE_RAC, &up->regs->w.mode); 605 SAB82532_MODE_RAC);
606 writeb(up->cached_mode, &up->regs->w.mode);
571 writeb(SAB82532_RFC_DPS|SAB82532_RFC_RFTH_32, &up->regs->w.rfc); 607 writeb(SAB82532_RFC_DPS|SAB82532_RFC_RFTH_32, &up->regs->w.rfc);
572 608
573 tmp = readb(&up->regs->rw.ccr0); 609 tmp = readb(&up->regs->rw.ccr0);
@@ -598,7 +634,6 @@ static void sunsab_shutdown(struct uart_port *port)
598{ 634{
599 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 635 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
600 unsigned long flags; 636 unsigned long flags;
601 unsigned char tmp;
602 637
603 spin_lock_irqsave(&up->port.lock, flags); 638 spin_lock_irqsave(&up->port.lock, flags);
604 639
@@ -609,14 +644,13 @@ static void sunsab_shutdown(struct uart_port *port)
609 writeb(up->interrupt_mask1, &up->regs->w.imr1); 644 writeb(up->interrupt_mask1, &up->regs->w.imr1);
610 645
611 /* Disable break condition */ 646 /* Disable break condition */
612 tmp = readb(&up->regs->rw.dafo); 647 up->cached_dafo = readb(&up->regs->rw.dafo);
613 tmp &= ~SAB82532_DAFO_XBRK; 648 up->cached_dafo &= ~SAB82532_DAFO_XBRK;
614 writeb(tmp, &up->regs->rw.dafo); 649 writeb(up->cached_dafo, &up->regs->rw.dafo);
615 650
616 /* Disable Receiver */ 651 /* Disable Receiver */
617 tmp = readb(&up->regs->rw.mode); 652 up->cached_mode &= ~SAB82532_MODE_RAC;
618 tmp &= ~SAB82532_MODE_RAC; 653 writeb(up->cached_mode, &up->regs->rw.mode);
619 writeb(tmp, &up->regs->rw.mode);
620 654
621 /* 655 /*
622 * XXX FIXME 656 * XXX FIXME
@@ -685,7 +719,6 @@ static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cfla
685 unsigned int iflag, unsigned int baud, 719 unsigned int iflag, unsigned int baud,
686 unsigned int quot) 720 unsigned int quot)
687{ 721{
688 unsigned int ebrg;
689 unsigned char dafo; 722 unsigned char dafo;
690 int bits, n, m; 723 int bits, n, m;
691 724
@@ -714,10 +747,11 @@ static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cfla
714 } else { 747 } else {
715 dafo |= SAB82532_DAFO_PAR_EVEN; 748 dafo |= SAB82532_DAFO_PAR_EVEN;
716 } 749 }
750 up->cached_dafo = dafo;
717 751
718 calc_ebrg(baud, &n, &m); 752 calc_ebrg(baud, &n, &m);
719 753
720 ebrg = n | (m << 6); 754 up->cached_ebrg = n | (m << 6);
721 755
722 up->tec_timeout = (10 * 1000000) / baud; 756 up->tec_timeout = (10 * 1000000) / baud;
723 up->cec_timeout = up->tec_timeout >> 2; 757 up->cec_timeout = up->tec_timeout >> 2;
@@ -770,16 +804,13 @@ static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cfla
770 uart_update_timeout(&up->port, cflag, 804 uart_update_timeout(&up->port, cflag,
771 (up->port.uartclk / (16 * quot))); 805 (up->port.uartclk / (16 * quot)));
772 806
773 /* Now bang the new settings into the chip. */ 807 /* Now schedule a register update when the chip's
774 sunsab_cec_wait(up); 808 * transmitter is idle.
775 sunsab_tec_wait(up); 809 */
776 writeb(dafo, &up->regs->w.dafo); 810 up->cached_mode |= SAB82532_MODE_RAC;
777 writeb(ebrg & 0xff, &up->regs->w.bgr); 811 set_bit(SAB82532_REGS_PENDING, &up->irqflags);
778 writeb((readb(&up->regs->rw.ccr2) & ~0xc0) | ((ebrg >> 2) & 0xc0), 812 if (test_bit(SAB82532_XPR, &up->irqflags))
779 &up->regs->rw.ccr2); 813 sunsab_tx_idle(up);
780
781 writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RAC, &up->regs->rw.mode);
782
783} 814}
784 815
785/* port->lock is not held. */ 816/* port->lock is not held. */
@@ -1084,11 +1115,13 @@ static void __init sunsab_init_hw(void)
1084 up->pvr_dsr_bit = (1 << 3); 1115 up->pvr_dsr_bit = (1 << 3);
1085 up->pvr_dtr_bit = (1 << 2); 1116 up->pvr_dtr_bit = (1 << 2);
1086 } 1117 }
1087 writeb((1 << 1) | (1 << 2) | (1 << 4), &up->regs->w.pvr); 1118 up->cached_pvr = (1 << 1) | (1 << 2) | (1 << 4);
1088 writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_FRTS, 1119 writeb(up->cached_pvr, &up->regs->w.pvr);
1089 &up->regs->rw.mode); 1120 up->cached_mode = readb(&up->regs->rw.mode);
1090 writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RTS, 1121 up->cached_mode |= SAB82532_MODE_FRTS;
1091 &up->regs->rw.mode); 1122 writeb(up->cached_mode, &up->regs->rw.mode);
1123 up->cached_mode |= SAB82532_MODE_RTS;
1124 writeb(up->cached_mode, &up->regs->rw.mode);
1092 1125
1093 up->tec_timeout = SAB82532_MAX_TEC_TIMEOUT; 1126 up->tec_timeout = SAB82532_MAX_TEC_TIMEOUT;
1094 up->cec_timeout = SAB82532_MAX_CEC_TIMEOUT; 1127 up->cec_timeout = SAB82532_MAX_CEC_TIMEOUT;
diff --git a/drivers/serial/sunsab.h b/drivers/serial/sunsab.h
index 686086fcbbf5..b78e1f7b8050 100644
--- a/drivers/serial/sunsab.h
+++ b/drivers/serial/sunsab.h
@@ -126,6 +126,7 @@ union sab82532_irq_status {
126/* irqflags bits */ 126/* irqflags bits */
127#define SAB82532_ALLS 0x00000001 127#define SAB82532_ALLS 0x00000001
128#define SAB82532_XPR 0x00000002 128#define SAB82532_XPR 0x00000002
129#define SAB82532_REGS_PENDING 0x00000004
129 130
130/* RFIFO Status Byte */ 131/* RFIFO Status Byte */
131#define SAB82532_RSTAT_PE 0x80 132#define SAB82532_RSTAT_PE 0x80
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
index 307886199f2f..5d2ceb623e6f 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -412,10 +412,8 @@ static inline void receive_chars(struct uart_port *port, uint8_t *status,
412 412
413 if (uart_handle_sysrq_char(port, ch, regs)) 413 if (uart_handle_sysrq_char(port, ch, regs))
414 goto ignore_char; 414 goto ignore_char;
415 if ((lsr & port->ignore_status_mask) == 0) 415
416 tty_insert_flip_char(tty, ch, flag); 416 uart_insert_char(port, lsr, UART_LSR_OE, ch, flag);
417 if ((lsr & UART_LSR_OE) && (tty->flip.count < TTY_FLIPBUF_SIZE))
418 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
419 417
420 ignore_char: 418 ignore_char:
421 lsr = siu_read(port, UART_LSR); 419 lsr = siu_read(port, UART_LSR);
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 233f9229badb..2a1697bfd695 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -386,6 +386,8 @@ static void speedtch_poll_status(struct speedtch_instance_data *instance)
386 if (instance->u.atm_dev->signal != ATM_PHY_SIG_LOST) { 386 if (instance->u.atm_dev->signal != ATM_PHY_SIG_LOST) {
387 instance->u.atm_dev->signal = ATM_PHY_SIG_LOST; 387 instance->u.atm_dev->signal = ATM_PHY_SIG_LOST;
388 printk(KERN_NOTICE "ADSL line is down\n"); 388 printk(KERN_NOTICE "ADSL line is down\n");
389 /* It'll never resync again unless we ask it to... */
390 speedtch_start_synchro(instance);
389 } 391 }
390 break; 392 break;
391 393
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index ec9b3bde8ae5..4ab50009291d 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -286,6 +286,39 @@ static ssize_t show_interface_string(struct device *dev, char *buf)
286} 286}
287static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); 287static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL);
288 288
289static ssize_t show_modalias(struct device *dev, char *buf)
290{
291 struct usb_interface *intf;
292 struct usb_device *udev;
293
294 intf = to_usb_interface(dev);
295 udev = interface_to_usbdev(intf);
296 if (udev->descriptor.bDeviceClass == 0) {
297 struct usb_host_interface *alt = intf->cur_altsetting;
298
299 return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X\n",
300 le16_to_cpu(udev->descriptor.idVendor),
301 le16_to_cpu(udev->descriptor.idProduct),
302 le16_to_cpu(udev->descriptor.bcdDevice),
303 udev->descriptor.bDeviceClass,
304 udev->descriptor.bDeviceSubClass,
305 udev->descriptor.bDeviceProtocol,
306 alt->desc.bInterfaceClass,
307 alt->desc.bInterfaceSubClass,
308 alt->desc.bInterfaceProtocol);
309 } else {
310 return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\n",
311 le16_to_cpu(udev->descriptor.idVendor),
312 le16_to_cpu(udev->descriptor.idProduct),
313 le16_to_cpu(udev->descriptor.bcdDevice),
314 udev->descriptor.bDeviceClass,
315 udev->descriptor.bDeviceSubClass,
316 udev->descriptor.bDeviceProtocol);
317 }
318
319}
320static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
321
289static struct attribute *intf_attrs[] = { 322static struct attribute *intf_attrs[] = {
290 &dev_attr_bInterfaceNumber.attr, 323 &dev_attr_bInterfaceNumber.attr,
291 &dev_attr_bAlternateSetting.attr, 324 &dev_attr_bAlternateSetting.attr,
@@ -293,6 +326,7 @@ static struct attribute *intf_attrs[] = {
293 &dev_attr_bInterfaceClass.attr, 326 &dev_attr_bInterfaceClass.attr,
294 &dev_attr_bInterfaceSubClass.attr, 327 &dev_attr_bInterfaceSubClass.attr,
295 &dev_attr_bInterfaceProtocol.attr, 328 &dev_attr_bInterfaceProtocol.attr,
329 &dev_attr_modalias.attr,
296 NULL, 330 NULL,
297}; 331};
298static struct attribute_group intf_attr_grp = { 332static struct attribute_group intf_attr_grp = {
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 02fefab3501e..429330bc38de 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -72,6 +72,7 @@ static int ehci_hub_suspend (struct usb_hcd *hcd)
72 } 72 }
73 73
74 /* turn off now-idle HC */ 74 /* turn off now-idle HC */
75 del_timer_sync (&ehci->watchdog);
75 ehci_halt (ehci); 76 ehci_halt (ehci);
76 hcd->state = HC_STATE_SUSPENDED; 77 hcd->state = HC_STATE_SUSPENDED;
77 78
diff --git a/drivers/usb/media/pwc/Makefile b/drivers/usb/media/pwc/Makefile
index e0b41ed4407f..2d93a775011a 100644
--- a/drivers/usb/media/pwc/Makefile
+++ b/drivers/usb/media/pwc/Makefile
@@ -1,6 +1,6 @@
1ifneq ($(KERNELRELEASE),) 1ifneq ($(KERNELRELEASE),)
2 2
3pwc-objs := pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o pwc-dec1.o pwc-dec23.o pwc-kiara.o pwc-timon.o 3pwc-objs := pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o pwc-timon.o pwc-kiara.o
4 4
5obj-$(CONFIG_USB_PWC) += pwc.o 5obj-$(CONFIG_USB_PWC) += pwc.o
6 6
diff --git a/drivers/usb/media/pwc/pwc-ctrl.c b/drivers/usb/media/pwc/pwc-ctrl.c
index 42ec468d52d6..3e1e4fe20d85 100644
--- a/drivers/usb/media/pwc/pwc-ctrl.c
+++ b/drivers/usb/media/pwc/pwc-ctrl.c
@@ -246,7 +246,7 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
246 switch(pdev->type) { 246 switch(pdev->type) {
247 case 645: 247 case 645:
248 case 646: 248 case 646:
249 pwc_dec1_init(pdev->type, pdev->release, buf, pdev->decompress_data); 249/* pwc_dec1_init(pdev->type, pdev->release, buf, pdev->decompress_data); */
250 break; 250 break;
251 251
252 case 675: 252 case 675:
@@ -256,7 +256,7 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
256 case 730: 256 case 730:
257 case 740: 257 case 740:
258 case 750: 258 case 750:
259 pwc_dec23_init(pdev->type, pdev->release, buf, pdev->decompress_data); 259/* pwc_dec23_init(pdev->type, pdev->release, buf, pdev->decompress_data); */
260 break; 260 break;
261 } 261 }
262 } 262 }
@@ -318,8 +318,8 @@ static inline int set_video_mode_Timon(struct pwc_device *pdev, int size, int fr
318 if (ret < 0) 318 if (ret < 0)
319 return ret; 319 return ret;
320 320
321 if (pChoose->bandlength > 0 && pdev->vpalette != VIDEO_PALETTE_RAW) 321/* if (pChoose->bandlength > 0 && pdev->vpalette != VIDEO_PALETTE_RAW)
322 pwc_dec23_init(pdev->type, pdev->release, buf, pdev->decompress_data); 322 pwc_dec23_init(pdev->type, pdev->release, buf, pdev->decompress_data); */
323 323
324 pdev->cmd_len = 13; 324 pdev->cmd_len = 13;
325 memcpy(pdev->cmd_buf, buf, 13); 325 memcpy(pdev->cmd_buf, buf, 13);
@@ -397,8 +397,8 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
397 if (ret < 0) 397 if (ret < 0)
398 return ret; 398 return ret;
399 399
400 if (pChoose->bandlength > 0 && pdev->vpalette != VIDEO_PALETTE_RAW) 400/* if (pChoose->bandlength > 0 && pdev->vpalette != VIDEO_PALETTE_RAW)
401 pwc_dec23_init(pdev->type, pdev->release, buf, pdev->decompress_data); 401 pwc_dec23_init(pdev->type, pdev->release, buf, pdev->decompress_data); */
402 402
403 pdev->cmd_len = 12; 403 pdev->cmd_len = 12;
404 memcpy(pdev->cmd_buf, buf, 12); 404 memcpy(pdev->cmd_buf, buf, 12);
diff --git a/drivers/usb/media/pwc/pwc-dec1.c b/drivers/usb/media/pwc/pwc-dec1.c
deleted file mode 100644
index 57d03d9178f6..000000000000
--- a/drivers/usb/media/pwc/pwc-dec1.c
+++ /dev/null
@@ -1,42 +0,0 @@
1/* Linux driver for Philips webcam
2 Decompression for chipset version 1
3 (C) 2004 Luc Saillard (luc@saillard.org)
4
5 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
6 driver and thus may have bugs that are not present in the original version.
7 Please send bug reports and support requests to <luc@saillard.org>.
8 The decompression routines have been implemented by reverse-engineering the
9 Nemosoft binary pwcx module. Caveat emptor.
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24*/
25
26
27
28#include "pwc-dec1.h"
29
30
31void pwc_dec1_init(int type, int release, void *buffer, void *table)
32{
33
34}
35
36void pwc_dec1_exit(void)
37{
38
39
40
41}
42
diff --git a/drivers/usb/media/pwc/pwc-dec1.h b/drivers/usb/media/pwc/pwc-dec1.h
deleted file mode 100644
index a7ffd9c45a2c..000000000000
--- a/drivers/usb/media/pwc/pwc-dec1.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/* Linux driver for Philips webcam
2 (C) 2004 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
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
26
27#ifndef PWC_DEC1_H
28#define PWC_DEC1_H
29
30void pwc_dec1_init(int type, int release, void *buffer, void *private_data);
31void pwc_dec1_exit(void);
32
33#endif
34
35
36
diff --git a/drivers/usb/media/pwc/pwc-dec23.c b/drivers/usb/media/pwc/pwc-dec23.c
deleted file mode 100644
index 98fa3f7a9eff..000000000000
--- a/drivers/usb/media/pwc/pwc-dec23.c
+++ /dev/null
@@ -1,623 +0,0 @@
1/* Linux driver for Philips webcam
2 Decompression for chipset version 2 et 3
3 (C) 2004 Luc Saillard (luc@saillard.org)
4
5 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
6 driver and thus may have bugs that are not present in the original version.
7 Please send bug reports and support requests to <luc@saillard.org>.
8 The decompression routines have been implemented by reverse-engineering the
9 Nemosoft binary pwcx module. Caveat emptor.
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24*/
25
26#include "pwc-timon.h"
27#include "pwc-kiara.h"
28#include "pwc-dec23.h"
29#include "pwc-ioctl.h"
30
31#include <linux/string.h>
32
33/****
34 *
35 *
36 *
37 */
38
39
40static void fill_table_a000(unsigned int *p)
41{
42 static unsigned int initial_values[12] = {
43 0xFFAD9B00, 0xFFDDEE00, 0x00221200, 0x00526500,
44 0xFFC21E00, 0x003DE200, 0xFF924B80, 0xFFD2A300,
45 0x002D5D00, 0x006DB480, 0xFFED3E00, 0x0012C200
46 };
47 static unsigned int values_derivated[12] = {
48 0x0000A4CA, 0x00004424, 0xFFFFBBDC, 0xFFFF5B36,
49 0x00007BC4, 0xFFFF843C, 0x0000DB69, 0x00005ABA,
50 0xFFFFA546, 0xFFFF2497, 0x00002584, 0xFFFFDA7C
51 };
52 unsigned int temp_values[12];
53 int i,j;
54
55 memcpy(temp_values,initial_values,sizeof(initial_values));
56 for (i=0;i<256;i++)
57 {
58 for (j=0;j<12;j++)
59 {
60 *p++ = temp_values[j];
61 temp_values[j] += values_derivated[j];
62 }
63 }
64}
65
66static void fill_table_d000(unsigned char *p)
67{
68 int bit,byte;
69
70 for (bit=0; bit<8; bit++)
71 {
72 unsigned char bitpower = 1<<bit;
73 unsigned char mask = bitpower-1;
74 for (byte=0; byte<256; byte++)
75 {
76 if (byte & bitpower)
77 *p++ = -(byte & mask);
78 else
79 *p++ = (byte & mask);
80 }
81 }
82}
83
84/*
85 *
86 * Kiara: 0 <= ver <= 7
87 * Timon: 0 <= ver <= 15
88 *
89 */
90static void fill_table_color(unsigned int version, const unsigned int *romtable,
91 unsigned char *p0004,
92 unsigned char *p8004)
93{
94 const unsigned int *table;
95 unsigned char *p0, *p8;
96 int i,j,k;
97 int dl,bit,pw;
98
99 romtable += version*256;
100
101 for (i=0; i<2; i++)
102 {
103 table = romtable + i*128;
104
105 for (dl=0; dl<16; dl++)
106 {
107 p0 = p0004 + (i<<14) + (dl<<10);
108 p8 = p8004 + (i<<12) + (dl<<8);
109
110 for (j=0; j<8; j++ , table++, p0+=128)
111 {
112 for (k=0; k<16; k++)
113 {
114 if (k==0)
115 bit=1;
116 else if (k>=1 && k<3)
117 bit=(table[0]>>15)&7;
118 else if (k>=3 && k<6)
119 bit=(table[0]>>12)&7;
120 else if (k>=6 && k<10)
121 bit=(table[0]>>9)&7;
122 else if (k>=10 && k<13)
123 bit=(table[0]>>6)&7;
124 else if (k>=13 && k<15)
125 bit=(table[0]>>3)&7;
126 else
127 bit=(table[0])&7;
128 if (k == 0)
129 *(unsigned char *)p8++ = 8;
130 else
131 *(unsigned char *)p8++ = j - bit;
132 *(unsigned char *)p8++ = bit;
133
134 pw = 1<<bit;
135 p0[k+0x00] = (1*pw) + 0x80;
136 p0[k+0x10] = (2*pw) + 0x80;
137 p0[k+0x20] = (3*pw) + 0x80;
138 p0[k+0x30] = (4*pw) + 0x80;
139 p0[k+0x40] = (-pw) + 0x80;
140 p0[k+0x50] = (2*-pw) + 0x80;
141 p0[k+0x60] = (3*-pw) + 0x80;
142 p0[k+0x70] = (4*-pw) + 0x80;
143 } /* end of for (k=0; k<16; k++, p8++) */
144 } /* end of for (j=0; j<8; j++ , table++) */
145 } /* end of for (dl=0; dl<16; dl++) */
146 } /* end of for (i=0; i<2; i++) */
147}
148
149/*
150 * precision = (pdev->xx + pdev->yy)
151 *
152 */
153static void fill_table_dc00_d800(unsigned int precision, unsigned int *pdc00, unsigned int *pd800)
154{
155 int i;
156 unsigned int offset1, offset2;
157
158 for(i=0,offset1=0x4000, offset2=0; i<256 ; i++,offset1+=0x7BC4, offset2+=0x7BC4)
159 {
160 unsigned int msb = offset1 >> 15;
161
162 if ( msb > 255)
163 {
164 if (msb)
165 msb=0;
166 else
167 msb=255;
168 }
169
170 *pdc00++ = msb << precision;
171 *pd800++ = offset2;
172 }
173
174}
175
176/*
177 * struct {
178 * unsigned char op; // operation to execute
179 * unsigned char bits; // bits use to perform operation
180 * unsigned char offset1; // offset to add to access in the table_0004 % 16
181 * unsigned char offset2; // offset to add to access in the table_0004
182 * }
183 *
184 */
185static unsigned int table_ops[] = {
1860x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x10, 0x00,0x06,0x01,0x30,
1870x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x01,0x20, 0x01,0x00,0x00,0x00,
1880x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x50, 0x00,0x05,0x02,0x00,
1890x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x03,0x00, 0x01,0x00,0x00,0x00,
1900x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x10, 0x00,0x06,0x02,0x10,
1910x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x01,0x60, 0x01,0x00,0x00,0x00,
1920x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x50, 0x00,0x05,0x02,0x40,
1930x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x03,0x40, 0x01,0x00,0x00,0x00,
1940x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x10, 0x00,0x06,0x01,0x70,
1950x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x01,0x20, 0x01,0x00,0x00,0x00,
1960x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x50, 0x00,0x05,0x02,0x00,
1970x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x03,0x00, 0x01,0x00,0x00,0x00,
1980x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x10, 0x00,0x06,0x02,0x50,
1990x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x01,0x60, 0x01,0x00,0x00,0x00,
2000x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x50, 0x00,0x05,0x02,0x40,
2010x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x03,0x40, 0x01,0x00,0x00,0x00
202};
203
204/*
205 * TODO: multiply by 4 all values
206 *
207 */
208static unsigned int MulIdx[256] = {
209 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
210 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,
211 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
212 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4,
213 6, 7, 8, 9, 7,10,11, 8, 8,11,10, 7, 9, 8, 7, 6,
214 4, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5, 4,
215 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2,
216 0, 3, 3, 0, 1, 2, 2, 1, 2, 1, 1, 2, 3, 0, 0, 3,
217 0, 1, 2, 3, 3, 2, 1, 0, 3, 2, 1, 0, 0, 1, 2, 3,
218 1, 1, 1, 1, 3, 3, 3, 3, 0, 0, 0, 0, 2, 2, 2, 2,
219 7,10,11, 8, 9, 8, 7, 6, 6, 7, 8, 9, 8,11,10, 7,
220 4, 5, 5, 4, 5, 4, 4, 5, 5, 4, 4, 5, 4, 5, 5, 4,
221 7, 9, 6, 8,10, 8, 7,11,11, 7, 8,10, 8, 6, 9, 7,
222 1, 3, 0, 2, 2, 0, 3, 1, 2, 0, 3, 1, 1, 3, 0, 2,
223 1, 2, 2, 1, 3, 0, 0, 3, 0, 3, 3, 0, 2, 1, 1, 2,
22410, 8, 7,11, 8, 6, 9, 7, 7, 9, 6, 8,11, 7, 8,10
225};
226
227
228
229void pwc_dec23_init(int type, int release, unsigned char *mode, void *data)
230{
231 int flags;
232 struct pwc_dec23_private *pdev = data;
233 release = release;
234
235 switch (type)
236 {
237 case 720:
238 case 730:
239 case 740:
240 case 750:
241 flags = mode[2]&0x18; /* our: flags = 8, mode[2]==e8 */
242 if (flags==8)
243 pdev->zz = 7;
244 else if (flags==0x10)
245 pdev->zz = 8;
246 else
247 pdev->zz = 6;
248 flags = mode[2]>>5; /* our: 7 */
249
250 fill_table_color(flags, (unsigned int *)KiaraRomTable, pdev->table_0004, pdev->table_8004);
251 break;
252
253
254 case 675:
255 case 680:
256 case 690:
257 flags = mode[2]&6;
258 if (flags==2)
259 pdev->zz = 7;
260 else if (flags==4)
261 pdev->zz = 8;
262 else
263 pdev->zz = 6;
264 flags = mode[2]>>3;
265
266 fill_table_color(flags, (unsigned int *)TimonRomTable, pdev->table_0004, pdev->table_8004);
267 break;
268
269 default:
270 /* Not supported */
271 return;
272 }
273
274 /* * * * ** */
275 pdev->xx = 8 - pdev->zz;
276 pdev->yy = 15 - pdev->xx;
277 pdev->zzmask = 0xFF>>pdev->xx;
278 //pdev->zzmask = (1U<<pdev->zz)-1;
279
280
281 fill_table_dc00_d800(pdev->xx + pdev->yy, pdev->table_dc00, pdev->table_d800);
282 fill_table_a000(pdev->table_a004);
283 fill_table_d000(pdev->table_d004);
284}
285
286
287/*
288 * To manage the stream, we keep in a 32 bits variables,
289 * the next bits in the stream. fill_reservoir() add to
290 * the reservoir at least wanted nbits.
291 *
292 *
293 */
294#define fill_nbits(reservoir,nbits_in_reservoir,stream,nbits_wanted) do { \
295 while (nbits_in_reservoir<nbits_wanted) \
296 { \
297 reservoir |= (*(stream)++) << nbits_in_reservoir; \
298 nbits_in_reservoir+=8; \
299 } \
300} while(0);
301
302#define get_nbits(reservoir,nbits_in_reservoir,stream,nbits_wanted,result) do { \
303 fill_nbits(reservoir,nbits_in_reservoir,stream,nbits_wanted); \
304 result = (reservoir) & ((1U<<nbits_wanted)-1); \
305 reservoir >>= nbits_wanted; \
306 nbits_in_reservoir -= nbits_wanted; \
307} while(0);
308
309
310
311static void DecompressBand23(const struct pwc_dec23_private *pdev,
312 const unsigned char *rawyuv,
313 unsigned char *planar_y,
314 unsigned char *planar_u,
315 unsigned char *planar_v,
316 unsigned int image_x, /* aka number of pixels wanted ??? */
317 unsigned int pixels_per_line, /* aka number of pixels per line */
318 int flags)
319{
320
321
322 unsigned int reservoir, nbits_in_reservoir;
323 int first_4_bits;
324 unsigned int bytes_per_channel;
325 int line_size; /* size of the line (4Y+U+V) */
326 int passes;
327 const unsigned char *ptable0004, *ptable8004;
328
329 int even_line;
330 unsigned int temp_colors[16];
331 int nblocks;
332
333 const unsigned char *stream;
334 unsigned char *dest_y, *dest_u=NULL, *dest_v=NULL;
335 unsigned int offset_to_plane_u, offset_to_plane_v;
336
337 int i;
338
339
340 reservoir = 0;
341 nbits_in_reservoir = 0;
342 stream = rawyuv+1; /* The first byte of the stream is skipped */
343 even_line = 1;
344
345 get_nbits(reservoir,nbits_in_reservoir,stream,4,first_4_bits);
346
347 line_size = pixels_per_line*3;
348
349 for (passes=0;passes<2;passes++)
350 {
351 if (passes==0)
352 {
353 bytes_per_channel = pixels_per_line;
354 dest_y = planar_y;
355 nblocks = image_x/4;
356 }
357 else
358 {
359 /* Format planar: All Y, then all U, then all V */
360 bytes_per_channel = pixels_per_line/2;
361 dest_u = planar_u;
362 dest_v = planar_v;
363 dest_y = dest_u;
364 nblocks = image_x/8;
365 }
366
367 offset_to_plane_u = bytes_per_channel*2;
368 offset_to_plane_v = bytes_per_channel*3;
369 /*
370 printf("bytes_per_channel = %d\n",bytes_per_channel);
371 printf("offset_to_plane_u = %d\n",offset_to_plane_u);
372 printf("offset_to_plane_v = %d\n",offset_to_plane_v);
373 */
374
375 while (nblocks-->0)
376 {
377 unsigned int gray_index;
378
379 fill_nbits(reservoir,nbits_in_reservoir,stream,16);
380 gray_index = reservoir & pdev->zzmask;
381 reservoir >>= pdev->zz;
382 nbits_in_reservoir -= pdev->zz;
383
384 fill_nbits(reservoir,nbits_in_reservoir,stream,2);
385
386 if ( (reservoir & 3) == 0)
387 {
388 reservoir>>=2;
389 nbits_in_reservoir-=2;
390 for (i=0;i<16;i++)
391 temp_colors[i] = pdev->table_dc00[gray_index];
392
393 }
394 else
395 {
396 unsigned int channel_v, offset1;
397
398 /* swap bit 0 and 2 of offset_OR */
399 channel_v = ((reservoir & 1) << 2) | (reservoir & 2) | ((reservoir & 4)>>2);
400 reservoir>>=3;
401 nbits_in_reservoir-=3;
402
403 for (i=0;i<16;i++)
404 temp_colors[i] = pdev->table_d800[gray_index];
405
406 ptable0004 = pdev->table_0004 + (passes*16384) + (first_4_bits*1024) + (channel_v*128);
407 ptable8004 = pdev->table_8004 + (passes*4096) + (first_4_bits*256) + (channel_v*32);
408
409 offset1 = 0;
410 while(1)
411 {
412 unsigned int index_in_table_ops, op, rows=0;
413 fill_nbits(reservoir,nbits_in_reservoir,stream,16);
414
415 /* mode is 0,1 or 2 */
416 index_in_table_ops = (reservoir&0x3F);
417 op = table_ops[ index_in_table_ops*4 ];
418 if (op == 2)
419 {
420 reservoir >>= 2;
421 nbits_in_reservoir -= 2;
422 break; /* exit the while(1) */
423 }
424 if (op == 0)
425 {
426 unsigned int shift;
427
428 offset1 = (offset1 + table_ops[index_in_table_ops*4+2]) & 0x0F;
429 shift = table_ops[ index_in_table_ops*4+1 ];
430 reservoir >>= shift;
431 nbits_in_reservoir -= shift;
432 rows = ptable0004[ offset1 + table_ops[index_in_table_ops*4+3] ];
433 }
434 if (op == 1)
435 {
436 /* 10bits [ xxxx xxxx yyyy 000 ]
437 * yyy => offset in the table8004
438 * xxx => offset in the tabled004
439 */
440 unsigned int mask, shift;
441 unsigned int col1, row1, total_bits;
442
443 offset1 = (offset1 + ((reservoir>>3)&0x0F)+1) & 0x0F;
444
445 col1 = (reservoir>>7) & 0xFF;
446 row1 = ptable8004 [ offset1*2 ];
447
448 /* Bit mask table */
449 mask = pdev->table_d004[ (row1<<8) + col1 ];
450 shift = ptable8004 [ offset1*2 + 1];
451 rows = ((mask << shift) + 0x80) & 0xFF;
452
453 total_bits = row1 + 8;
454 reservoir >>= total_bits;
455 nbits_in_reservoir -= total_bits;
456 }
457 {
458 const unsigned int *table_a004 = pdev->table_a004 + rows*12;
459 unsigned int *poffset = MulIdx + offset1*16; /* 64/4 (int) */
460 for (i=0;i<16;i++)
461 {
462 temp_colors[i] += table_a004[ *poffset ];
463 poffset++;
464 }
465 }
466 }
467 }
468#define USE_SIGNED_INT_FOR_COLOR
469#ifdef USE_SIGNED_INT_FOR_COLOR
470# define CLAMP(x) ((x)>255?255:((x)<0?0:x))
471#else
472# define CLAMP(x) ((x)>255?255:x)
473#endif
474
475 if (passes == 0)
476 {
477#ifdef USE_SIGNED_INT_FOR_COLOR
478 const int *c = temp_colors;
479#else
480 const unsigned int *c = temp_colors;
481#endif
482 unsigned char *d;
483
484 d = dest_y;
485 for (i=0;i<4;i++,c++)
486 *d++ = CLAMP((*c) >> pdev->yy);
487
488 d = dest_y + bytes_per_channel;
489 for (i=0;i<4;i++,c++)
490 *d++ = CLAMP((*c) >> pdev->yy);
491
492 d = dest_y + offset_to_plane_u;
493 for (i=0;i<4;i++,c++)
494 *d++ = CLAMP((*c) >> pdev->yy);
495
496 d = dest_y + offset_to_plane_v;
497 for (i=0;i<4;i++,c++)
498 *d++ = CLAMP((*c) >> pdev->yy);
499
500 dest_y += 4;
501 }
502 else if (passes == 1)
503 {
504#ifdef USE_SIGNED_INT_FOR_COLOR
505 int *c1 = temp_colors;
506 int *c2 = temp_colors+4;
507#else
508 unsigned int *c1 = temp_colors;
509 unsigned int *c2 = temp_colors+4;
510#endif
511 unsigned char *d;
512
513 d = dest_y;
514 for (i=0;i<4;i++,c1++,c2++)
515 {
516 *d++ = CLAMP((*c1) >> pdev->yy);
517 *d++ = CLAMP((*c2) >> pdev->yy);
518 }
519 c1 = temp_colors+12;
520 //c2 = temp_colors+8;
521 d = dest_y + bytes_per_channel;
522 for (i=0;i<4;i++,c1++,c2++)
523 {
524 *d++ = CLAMP((*c1) >> pdev->yy);
525 *d++ = CLAMP((*c2) >> pdev->yy);
526 }
527
528 if (even_line) /* Each line, swap u/v */
529 {
530 even_line=0;
531 dest_y = dest_v;
532 dest_u += 8;
533 }
534 else
535 {
536 even_line=1;
537 dest_y = dest_u;
538 dest_v += 8;
539 }
540 }
541
542 } /* end of while (nblocks-->0) */
543
544 } /* end of for (passes=0;passes<2;passes++) */
545
546}
547
548
549/**
550 *
551 * image: size of the image wanted
552 * view : size of the image returned by the camera
553 * offset: (x,y) to displayer image in the view
554 *
555 * src: raw data
556 * dst: image output
557 * flags: PWCX_FLAG_PLANAR
558 * pdev: private buffer
559 * bandlength:
560 *
561 */
562void pwc_dec23_decompress(const struct pwc_coord *image,
563 const struct pwc_coord *view,
564 const struct pwc_coord *offset,
565 const void *src,
566 void *dst,
567 int flags,
568 const void *data,
569 int bandlength)
570{
571 const struct pwc_dec23_private *pdev = data;
572 unsigned char *pout, *pout_planar_y=NULL, *pout_planar_u=NULL, *pout_planar_v=NULL;
573 int i,n,stride,pixel_size;
574
575
576 if (flags & PWCX_FLAG_BAYER)
577 {
578 pout = dst + (view->x * offset->y) + offset->x;
579 pixel_size = view->x * 4;
580 }
581 else
582 {
583 n = view->x * view->y;
584
585 /* offset in Y plane */
586 stride = view->x * offset->y;
587 pout_planar_y = dst + stride + offset->x;
588
589 /* offsets in U/V planes */
590 stride = (view->x * offset->y)/4 + offset->x/2;
591 pout_planar_u = dst + n + + stride;
592 pout_planar_v = dst + n + n/4 + stride;
593
594 pixel_size = view->x * 4;
595 }
596
597
598 for (i=0;i<image->y;i+=4)
599 {
600 if (flags & PWCX_FLAG_BAYER)
601 {
602 //TODO:
603 //DecompressBandBayer(pdev,src,pout,image.x,view->x,flags);
604 src += bandlength;
605 pout += pixel_size;
606 }
607 else
608 {
609 DecompressBand23(pdev,src,pout_planar_y,pout_planar_u,pout_planar_v,image->x,view->x,flags);
610 src += bandlength;
611 pout_planar_y += pixel_size;
612 pout_planar_u += view->x;
613 pout_planar_v += view->x;
614 }
615 }
616}
617
618void pwc_dec23_exit(void)
619{
620 /* Do nothing */
621
622}
623
diff --git a/drivers/usb/media/pwc/pwc-dec23.h b/drivers/usb/media/pwc/pwc-dec23.h
deleted file mode 100644
index 5b2aacdefa6c..000000000000
--- a/drivers/usb/media/pwc/pwc-dec23.h
+++ /dev/null
@@ -1,58 +0,0 @@
1/* Linux driver for Philips webcam
2 (C) 2004 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25#ifndef PWC_DEC23_H
26#define PWC_DEC23_H
27
28struct pwc_dec23_private
29{
30 unsigned char xx,yy,zz,zzmask;
31
32 unsigned char table_0004[2*0x4000];
33 unsigned char table_8004[2*0x1000];
34 unsigned int table_a004[256*12];
35
36 unsigned char table_d004[8*256];
37 unsigned int table_d800[256];
38 unsigned int table_dc00[256];
39};
40
41
42void pwc_dec23_init(int type, int release, unsigned char *buffer, void *private_data);
43void pwc_dec23_exit(void);
44void pwc_dec23_decompress(const struct pwc_coord *image,
45 const struct pwc_coord *view,
46 const struct pwc_coord *offset,
47 const void *src,
48 void *dst,
49 int flags,
50 const void *data,
51 int bandlength);
52
53
54
55#endif
56
57
58
diff --git a/drivers/usb/media/pwc/pwc-if.c b/drivers/usb/media/pwc/pwc-if.c
index cca47f480a8b..5429ff3b9753 100644
--- a/drivers/usb/media/pwc/pwc-if.c
+++ b/drivers/usb/media/pwc/pwc-if.c
@@ -68,8 +68,6 @@
68#include "pwc-ioctl.h" 68#include "pwc-ioctl.h"
69#include "pwc-kiara.h" 69#include "pwc-kiara.h"
70#include "pwc-timon.h" 70#include "pwc-timon.h"
71#include "pwc-dec23.h"
72#include "pwc-dec1.h"
73#include "pwc-uncompress.h" 71#include "pwc-uncompress.h"
74 72
75/* Function prototypes and driver templates */ 73/* Function prototypes and driver templates */
@@ -322,6 +320,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
322 case 730: 320 case 730:
323 case 740: 321 case 740:
324 case 750: 322 case 750:
323#if 0
325 Trace(TRACE_MEMORY,"private_data(%zu)\n",sizeof(struct pwc_dec23_private)); 324 Trace(TRACE_MEMORY,"private_data(%zu)\n",sizeof(struct pwc_dec23_private));
326 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */ 325 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */
327 break; 326 break;
@@ -330,6 +329,8 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
330 /* TODO & FIXME */ 329 /* TODO & FIXME */
331 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); 330 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL);
332 break; 331 break;
332#endif
333 ;
333 } 334 }
334 if (kbuf == NULL) { 335 if (kbuf == NULL) {
335 Err("Failed to allocate decompress table.\n"); 336 Err("Failed to allocate decompress table.\n");
@@ -1131,11 +1132,11 @@ static int pwc_video_close(struct inode *inode, struct file *file)
1131 case 730: 1132 case 730:
1132 case 740: 1133 case 740:
1133 case 750: 1134 case 750:
1134 pwc_dec23_exit(); /* Timon & Kiara */ 1135/* pwc_dec23_exit(); *//* Timon & Kiara */
1135 break; 1136 break;
1136 case 645: 1137 case 645:
1137 case 646: 1138 case 646:
1138 pwc_dec1_exit(); 1139/* pwc_dec1_exit(); */
1139 break; 1140 break;
1140 } 1141 }
1141 1142
diff --git a/drivers/usb/media/pwc/pwc-kiara.c b/drivers/usb/media/pwc/pwc-kiara.c
index 5485800efd83..c498c68bace1 100644
--- a/drivers/usb/media/pwc/pwc-kiara.c
+++ b/drivers/usb/media/pwc/pwc-kiara.c
@@ -316,576 +316,3 @@ const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4] =
316 }, 316 },
317}; 317};
318 318
319
320/*
321 * Rom table for kiara chips
322 *
323 * 32 roms tables (one for each resolution ?)
324 * 2 tables per roms (one for each passes) (Y, and U&V)
325 * 128 bytes per passes
326 */
327
328const unsigned int KiaraRomTable [8][2][16][8] =
329{
330 { /* version 0 */
331 { /* version 0, passes 0 */
332 {0x00000000,0x00000000,0x00000000,0x00000000,
333 0x00000000,0x00000000,0x00000001,0x00000001},
334 {0x00000000,0x00000000,0x00000009,0x00000009,
335 0x00000009,0x00000009,0x00000009,0x00000009},
336 {0x00000000,0x00000000,0x00000009,0x00000049,
337 0x00000049,0x00000049,0x00000049,0x00000049},
338 {0x00000000,0x00000000,0x00000049,0x00000049,
339 0x00000049,0x00000249,0x0000024a,0x00000049},
340 {0x00000000,0x00000000,0x00000049,0x00000049,
341 0x00000249,0x00000249,0x0000024a,0x0000024a},
342 {0x00000000,0x00000000,0x00000049,0x00000249,
343 0x00000249,0x0000124a,0x0000024a,0x0000024a},
344 {0x00000000,0x00000000,0x00000049,0x00000249,
345 0x0000124a,0x00009252,0x00001252,0x00001252},
346 {0x00000000,0x00000000,0x00000249,0x00000249,
347 0x00009252,0x00009292,0x00009292,0x00009292},
348 {0x00000000,0x00000000,0x00000249,0x00001249,
349 0x00009292,0x00009292,0x00009493,0x000124db},
350 {0x00000000,0x00000000,0x00000249,0x0000924a,
351 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
352 {0x00000000,0x00000000,0x00001249,0x00009252,
353 0x0000a493,0x000124db,0x000124db,0x000126dc},
354 {0x00000000,0x00000000,0x00001249,0x00009493,
355 0x000124db,0x000126dc,0x000136e4,0x000126dc},
356 {0x00000000,0x00000000,0x00009292,0x0000a49b,
357 0x000124db,0x000136e4,0x000136e4,0x000136e4},
358 {0x00000000,0x00000000,0x00009292,0x0000a49b,
359 0x000126dc,0x0001b724,0x0001b92d,0x0001b925},
360 {0x00000000,0x00000000,0x00009492,0x000124db,
361 0x000136e4,0x0001b925,0x0001c96e,0x0001c92d},
362 {0x00000000,0x00000000,0x00000000,0x00000000,
363 0x00000000,0x00000000,0x00000000,0x00000000}
364 },
365 { /* version 0, passes 1 */
366 {0x00000000,0x00000000,0x00000000,0x00000000,
367 0x00000000,0x00000000,0x00000000,0x00000000},
368 {0x00000000,0x00000000,0x00000000,0x00000000,
369 0x00000000,0x00000000,0x00000000,0x00000000},
370 {0x00000000,0x00000000,0x00000001,0x00000009,
371 0x00000009,0x00000009,0x00000009,0x00000001},
372 {0x00000000,0x00000000,0x00000009,0x00000009,
373 0x00000049,0x00000049,0x00000049,0x00000049},
374 {0x00000000,0x00000000,0x00000049,0x00000049,
375 0x00000049,0x00000049,0x0000024a,0x0000024a},
376 {0x00000000,0x00000000,0x00000049,0x00000049,
377 0x00000249,0x00000249,0x0000024a,0x0000024a},
378 {0x00000000,0x00000000,0x00000049,0x00000249,
379 0x00000249,0x00000249,0x0000024a,0x00001252},
380 {0x00000000,0x00000000,0x00000049,0x00001249,
381 0x0000124a,0x0000124a,0x00001252,0x00009292},
382 {0x00000000,0x00000000,0x00000249,0x00001249,
383 0x00009252,0x00009252,0x00009292,0x00009493},
384 {0x00000000,0x00000000,0x00000249,0x0000924a,
385 0x00009292,0x00009292,0x00009292,0x00009493},
386 {0x00000000,0x00000000,0x00000249,0x00009292,
387 0x00009492,0x00009493,0x0000a49b,0x00009493},
388 {0x00000000,0x00000000,0x00001249,0x00009292,
389 0x0000a493,0x000124db,0x000126dc,0x000126dc},
390 {0x00000000,0x00000000,0x0000924a,0x00009493,
391 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
392 {0x00000000,0x00000000,0x00009252,0x00009493,
393 0x000126dc,0x000126dc,0x000136e4,0x000136e4},
394 {0x00000000,0x00000000,0x00009292,0x0000a49b,
395 0x000136e4,0x000136e4,0x0001b725,0x0001b724},
396 {0x00000000,0x00000000,0x00000000,0x00000000,
397 0x00000000,0x00000000,0x00000000,0x00000000}
398 }
399 },
400 { /* version 1 */
401 { /* version 1, passes 0 */
402 {0x00000000,0x00000000,0x00000000,0x00000000,
403 0x00000000,0x00000000,0x00000000,0x00000001},
404 {0x00000000,0x00000000,0x00000009,0x00000009,
405 0x00000009,0x00000009,0x00000009,0x00000009},
406 {0x00000000,0x00000000,0x00000049,0x00000049,
407 0x00000049,0x00000049,0x00000049,0x00000049},
408 {0x00000000,0x00000000,0x00000049,0x00000049,
409 0x00000049,0x00000249,0x0000024a,0x0000024a},
410 {0x00000000,0x00000000,0x00000049,0x00000249,
411 0x00000249,0x00000249,0x0000024a,0x00001252},
412 {0x00000000,0x00000000,0x00000249,0x00000249,
413 0x00000249,0x0000124a,0x00001252,0x00001252},
414 {0x00000000,0x00000000,0x00000249,0x00000249,
415 0x0000124a,0x0000124a,0x00009292,0x00009292},
416 {0x00000000,0x00000000,0x00000249,0x00001249,
417 0x0000124a,0x00009252,0x00009292,0x00009292},
418 {0x00000000,0x00000000,0x00000249,0x00001249,
419 0x00009252,0x00009292,0x00009292,0x00009292},
420 {0x00000000,0x00000000,0x00000249,0x00001249,
421 0x00009252,0x00009292,0x00009493,0x00009493},
422 {0x00000000,0x00000000,0x00000249,0x0000924a,
423 0x00009252,0x00009493,0x00009493,0x00009493},
424 {0x00000000,0x00000000,0x00000249,0x0000924a,
425 0x00009292,0x00009493,0x00009493,0x00009493},
426 {0x00000000,0x00000000,0x00000249,0x00009252,
427 0x00009492,0x00009493,0x0000a49b,0x0000a49b},
428 {0x00000000,0x00000000,0x00001249,0x00009292,
429 0x00009492,0x000124db,0x000124db,0x000124db},
430 {0x00000000,0x00000000,0x0000924a,0x00009493,
431 0x0000a493,0x000126dc,0x000126dc,0x000126dc},
432 {0x00000000,0x00000000,0x00000000,0x00000000,
433 0x00000000,0x00000000,0x00000000,0x00000000}
434 },
435 { /* version 1, passes 1 */
436 {0x00000000,0x00000000,0x00000000,0x00000000,
437 0x00000000,0x00000000,0x00000000,0x00000000},
438 {0x00000000,0x00000000,0x00000049,0x00000009,
439 0x00000049,0x00000009,0x00000001,0x00000000},
440 {0x00000000,0x00000000,0x00000049,0x00000049,
441 0x00000049,0x00000049,0x00000049,0x00000000},
442 {0x00000000,0x00000000,0x00000249,0x00000049,
443 0x00000249,0x00000049,0x0000024a,0x00000001},
444 {0x00000000,0x00000000,0x00000249,0x00000249,
445 0x00000249,0x00000249,0x0000024a,0x00000001},
446 {0x00000000,0x00000000,0x00000249,0x00000249,
447 0x00000249,0x00000249,0x0000024a,0x00000001},
448 {0x00000000,0x00000000,0x00000249,0x00000249,
449 0x00000249,0x00000249,0x0000024a,0x00000009},
450 {0x00000000,0x00000000,0x00000249,0x00000249,
451 0x0000124a,0x0000124a,0x0000024a,0x00000009},
452 {0x00000000,0x00000000,0x00000249,0x00000249,
453 0x0000124a,0x0000124a,0x0000024a,0x00000009},
454 {0x00000000,0x00000000,0x00001249,0x00001249,
455 0x0000124a,0x00009252,0x00001252,0x00000049},
456 {0x00000000,0x00000000,0x00001249,0x00001249,
457 0x0000124a,0x00009292,0x00001252,0x00000049},
458 {0x00000000,0x00000000,0x00001249,0x00001249,
459 0x0000124a,0x00009292,0x00001252,0x00000049},
460 {0x00000000,0x00000000,0x00001249,0x00001249,
461 0x00009252,0x00009292,0x00001252,0x0000024a},
462 {0x00000000,0x00000000,0x00001249,0x00001249,
463 0x00009292,0x00009292,0x00001252,0x0000024a},
464 {0x00000000,0x00000000,0x0000924a,0x0000924a,
465 0x00009492,0x00009493,0x00009292,0x00001252},
466 {0x00000000,0x00000000,0x00000000,0x00000000,
467 0x00000000,0x00000000,0x00000000,0x00000000}
468 }
469 },
470 { /* version 2 */
471 { /* version 2, passes 0 */
472 {0x00000000,0x00000000,0x00000049,0x00000049,
473 0x00000049,0x00000049,0x0000024a,0x0000024a},
474 {0x00000000,0x00000000,0x00000249,0x00000249,
475 0x00000249,0x0000124a,0x00001252,0x00009292},
476 {0x00000000,0x00000000,0x00000249,0x00000249,
477 0x0000124a,0x00009252,0x00009292,0x00009292},
478 {0x00000000,0x00000000,0x00000249,0x00001249,
479 0x0000124a,0x00009292,0x00009493,0x00009493},
480 {0x00000000,0x00000000,0x00000249,0x00001249,
481 0x00009252,0x00009493,0x00009493,0x0000a49b},
482 {0x00000000,0x00000000,0x00000249,0x0000924a,
483 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
484 {0x00000000,0x00000000,0x00001249,0x0000924a,
485 0x00009292,0x00009493,0x0000a49b,0x000124db},
486 {0x00000000,0x00000000,0x00001249,0x00009252,
487 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
488 {0x00000000,0x00000000,0x00001249,0x00009292,
489 0x00009492,0x000124db,0x000124db,0x000126dc},
490 {0x00000000,0x00000000,0x00001249,0x00009292,
491 0x0000a493,0x000124db,0x000126dc,0x000126dc},
492 {0x00000000,0x00000000,0x00001249,0x00009493,
493 0x0000a493,0x000124db,0x000126dc,0x000136e4},
494 {0x00000000,0x00000000,0x00001249,0x00009493,
495 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
496 {0x00000000,0x00000000,0x0000924a,0x00009493,
497 0x0001249b,0x000126dc,0x000136e4,0x000136e4},
498 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
499 0x000124db,0x000136e4,0x000136e4,0x0001b724},
500 {0x00000000,0x00000000,0x00009252,0x000124db,
501 0x000126dc,0x0001b724,0x0001b725,0x0001b925},
502 {0x00000000,0x00000000,0x00000000,0x00000000,
503 0x00000000,0x00000000,0x00000000,0x00000000}
504 },
505 { /* version 2, passes 1 */
506 {0x00000000,0x00000000,0x00000049,0x00000049,
507 0x00000049,0x00000049,0x00000049,0x00000049},
508 {0x00000000,0x00000000,0x00000249,0x00000249,
509 0x00000249,0x00000249,0x0000024a,0x00000049},
510 {0x00000000,0x00000000,0x00001249,0x00000249,
511 0x0000124a,0x0000124a,0x00001252,0x00000049},
512 {0x00000000,0x00000000,0x00001249,0x00001249,
513 0x0000124a,0x0000124a,0x00009292,0x0000024a},
514 {0x00000000,0x00000000,0x00001249,0x00001249,
515 0x00009252,0x00009292,0x00009292,0x0000024a},
516 {0x00000000,0x00000000,0x00001249,0x00001249,
517 0x00009252,0x00009292,0x0000a49b,0x0000024a},
518 {0x00000000,0x00000000,0x00001249,0x00001249,
519 0x00009292,0x00009493,0x0000a49b,0x00001252},
520 {0x00000000,0x00000000,0x00001249,0x00001249,
521 0x00009292,0x00009493,0x0000a49b,0x00001252},
522 {0x00000000,0x00000000,0x00001249,0x0000924a,
523 0x00009492,0x0000a49b,0x0000a49b,0x00001252},
524 {0x00000000,0x00000000,0x00001249,0x00009252,
525 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
526 {0x00000000,0x00000000,0x00001249,0x00009292,
527 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
528 {0x00000000,0x00000000,0x00001249,0x00009493,
529 0x0000a493,0x0000a49b,0x0000a49b,0x00009292},
530 {0x00000000,0x00000000,0x00001249,0x00009493,
531 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
532 {0x00000000,0x00000000,0x0000924a,0x00009493,
533 0x0000a493,0x000124db,0x0000a49b,0x00009493},
534 {0x00000000,0x00000000,0x00009252,0x0000a49b,
535 0x0001249b,0x000126dc,0x000124db,0x0000a49b},
536 {0x00000000,0x00000000,0x00000000,0x00000000,
537 0x00000000,0x00000000,0x00000000,0x00000000}
538 }
539 },
540 { /* version 3 */
541 { /* version 3, passes 0 */
542 {0x00000000,0x00000000,0x00000249,0x00000249,
543 0x0000124a,0x0000124a,0x00009292,0x00009292},
544 {0x00000000,0x00000000,0x00001249,0x00001249,
545 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
546 {0x00000000,0x00000000,0x00001249,0x0000924a,
547 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
548 {0x00000000,0x00000000,0x00001249,0x00009292,
549 0x00009492,0x000124db,0x000126dc,0x000126dc},
550 {0x00000000,0x00000000,0x00001249,0x00009493,
551 0x0000a493,0x000124db,0x000126dc,0x000126dc},
552 {0x00000000,0x00000000,0x00001249,0x00009493,
553 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
554 {0x00000000,0x00000000,0x00001249,0x00009493,
555 0x0000a493,0x000126dc,0x000136e4,0x0001b724},
556 {0x00000000,0x00000000,0x00001249,0x00009493,
557 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
558 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
559 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
560 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
561 0x0001249b,0x000136e4,0x0001b725,0x0001b724},
562 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
563 0x000124db,0x000136e4,0x0001b725,0x0001b925},
564 {0x00000000,0x00000000,0x00009292,0x0000a49b,
565 0x000126dc,0x000136e4,0x0001b92d,0x0001b925},
566 {0x00000000,0x00000000,0x00009292,0x0000a49b,
567 0x000126dc,0x0001b724,0x0001b92d,0x0001c92d},
568 {0x00000000,0x00000000,0x00009492,0x000124db,
569 0x000126dc,0x0001b724,0x0001c96e,0x0001c92d},
570 {0x00000000,0x00000000,0x0000a492,0x000126db,
571 0x000136e4,0x0001b925,0x00025bb6,0x00024b77},
572 {0x00000000,0x00000000,0x00000000,0x00000000,
573 0x00000000,0x00000000,0x00000000,0x00000000}
574 },
575 { /* version 3, passes 1 */
576 {0x00000000,0x00000000,0x00001249,0x00000249,
577 0x0000124a,0x0000124a,0x00001252,0x00001252},
578 {0x00000000,0x00000000,0x00001249,0x00001249,
579 0x00009252,0x00009292,0x00009292,0x00001252},
580 {0x00000000,0x00000000,0x00001249,0x0000924a,
581 0x00009492,0x00009493,0x0000a49b,0x00001252},
582 {0x00000000,0x00000000,0x00001249,0x00009252,
583 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
584 {0x00000000,0x00000000,0x00001249,0x00009292,
585 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
586 {0x00000000,0x00000000,0x00001249,0x00009493,
587 0x0000a493,0x0000a49b,0x000126dc,0x00009292},
588 {0x00000000,0x00000000,0x0000924a,0x00009493,
589 0x0000a493,0x0000a49b,0x000126dc,0x00009493},
590 {0x00000000,0x00000000,0x0000924a,0x00009493,
591 0x0000a493,0x0000a49b,0x000126dc,0x00009493},
592 {0x00000000,0x00000000,0x0000924a,0x00009493,
593 0x0000a493,0x000124db,0x000126dc,0x00009493},
594 {0x00000000,0x00000000,0x0000924a,0x00009493,
595 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
596 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
597 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
598 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
599 0x0001249b,0x000126dc,0x000126dc,0x0000a49b},
600 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
601 0x000124db,0x000136e4,0x000126dc,0x000124db},
602 {0x00000000,0x00000000,0x00009492,0x0000a49b,
603 0x000136e4,0x000136e4,0x000126dc,0x000124db},
604 {0x00000000,0x00000000,0x0000a492,0x000124db,
605 0x0001b724,0x0001b724,0x000136e4,0x000126dc},
606 {0x00000000,0x00000000,0x00000000,0x00000000,
607 0x00000000,0x00000000,0x00000000,0x00000000}
608 }
609 },
610 { /* version 4 */
611 { /* version 4, passes 0 */
612 {0x00000000,0x00000000,0x00000049,0x00000049,
613 0x00000049,0x00000049,0x00000049,0x00000049},
614 {0x00000000,0x00000000,0x00000249,0x00000049,
615 0x00000249,0x00000249,0x0000024a,0x00000049},
616 {0x00000000,0x00000000,0x00000249,0x00000249,
617 0x0000124a,0x00009252,0x00001252,0x0000024a},
618 {0x00000000,0x00000000,0x00001249,0x00001249,
619 0x00009252,0x00009292,0x00009493,0x00001252},
620 {0x00000000,0x00000000,0x00001249,0x0000924a,
621 0x00009292,0x00009493,0x00009493,0x00001252},
622 {0x00000000,0x00000000,0x00001249,0x00009292,
623 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
624 {0x00000000,0x00000000,0x00001249,0x00009493,
625 0x0000a493,0x000124db,0x000124db,0x00009493},
626 {0x00000000,0x00000000,0x0000924a,0x00009493,
627 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
628 {0x00000000,0x00000000,0x0000924a,0x00009493,
629 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
630 {0x00000000,0x00000000,0x0000924a,0x00009493,
631 0x0001249b,0x000126dc,0x000126dc,0x000124db},
632 {0x00000000,0x00000000,0x00009252,0x00009493,
633 0x000124db,0x000136e4,0x000136e4,0x000126dc},
634 {0x00000000,0x00000000,0x00009252,0x0000a49b,
635 0x000124db,0x000136e4,0x000136e4,0x000126dc},
636 {0x00000000,0x00000000,0x00009292,0x0000a49b,
637 0x000126dc,0x000136e4,0x000136e4,0x000136e4},
638 {0x00000000,0x00000000,0x00009492,0x0000a49b,
639 0x000126dc,0x0001b724,0x0001b725,0x0001b724},
640 {0x00000000,0x00000000,0x0000a492,0x000124db,
641 0x000136e4,0x0001b925,0x0001b92d,0x0001b925},
642 {0x00000000,0x00000000,0x00000000,0x00000000,
643 0x00000000,0x00000000,0x00000000,0x00000000}
644 },
645 { /* version 4, passes 1 */
646 {0x00000000,0x00000000,0x00000249,0x00000049,
647 0x00000009,0x00000009,0x00000009,0x00000009},
648 {0x00000000,0x00000000,0x00000249,0x00000249,
649 0x00000049,0x00000049,0x00000009,0x00000009},
650 {0x00000000,0x00000000,0x00001249,0x00001249,
651 0x0000124a,0x00000249,0x00000049,0x00000049},
652 {0x00000000,0x00000000,0x00001249,0x00001249,
653 0x0000124a,0x0000124a,0x00000049,0x00000049},
654 {0x00000000,0x00000000,0x00001249,0x00001249,
655 0x00009252,0x0000124a,0x0000024a,0x0000024a},
656 {0x00000000,0x00000000,0x00001249,0x0000924a,
657 0x00009252,0x0000124a,0x0000024a,0x0000024a},
658 {0x00000000,0x00000000,0x00001249,0x00009292,
659 0x00009492,0x00009252,0x00001252,0x00001252},
660 {0x00000000,0x00000000,0x00001249,0x00009493,
661 0x0000a493,0x00009292,0x00009292,0x00001252},
662 {0x00000000,0x00000000,0x0000924a,0x00009493,
663 0x0000a493,0x00009292,0x00009292,0x00009292},
664 {0x00000000,0x00000000,0x0000924a,0x00009493,
665 0x0000a493,0x00009493,0x00009493,0x00009292},
666 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
667 0x0000a493,0x0000a49b,0x00009493,0x00009493},
668 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
669 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
670 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
671 0x0001249b,0x000124db,0x0000a49b,0x0000a49b},
672 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
673 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
674 {0x00000000,0x00000000,0x00009252,0x000124db,
675 0x0001b724,0x000136e4,0x000126dc,0x000124db},
676 {0x00000000,0x00000000,0x00000000,0x00000000,
677 0x00000000,0x00000000,0x00000000,0x00000000}
678 }
679 },
680 { /* version 5 */
681 { /* version 5, passes 0 */
682 {0x00000000,0x00000000,0x00000249,0x00000249,
683 0x00000249,0x00000249,0x00001252,0x00001252},
684 {0x00000000,0x00000000,0x00001249,0x00001249,
685 0x00009252,0x00009292,0x00009292,0x00001252},
686 {0x00000000,0x00000000,0x00001249,0x0000924a,
687 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
688 {0x00000000,0x00000000,0x00001249,0x00009493,
689 0x0000a493,0x0000a49b,0x000124db,0x00009493},
690 {0x00000000,0x00000000,0x00001249,0x00009493,
691 0x0000a493,0x000124db,0x000126dc,0x00009493},
692 {0x00000000,0x00000000,0x0000924a,0x00009493,
693 0x0000a493,0x000126dc,0x000126dc,0x0000a49b},
694 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
695 0x0001249b,0x000126dc,0x000136e4,0x000124db},
696 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
697 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
698 {0x00000000,0x00000000,0x00009292,0x0000a49b,
699 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
700 {0x00000000,0x00000000,0x00009292,0x0000a49b,
701 0x000126dc,0x0001b724,0x0001b725,0x000136e4},
702 {0x00000000,0x00000000,0x00009292,0x0000a49b,
703 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
704 {0x00000000,0x00000000,0x00009492,0x0000a49b,
705 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
706 {0x00000000,0x00000000,0x00009492,0x000124db,
707 0x000136e4,0x0001b925,0x0001c96e,0x0001b925},
708 {0x00000000,0x00000000,0x00009492,0x000124db,
709 0x0001b724,0x0001b925,0x0001c96e,0x0001c92d},
710 {0x00000000,0x00000000,0x0000a492,0x000126db,
711 0x0001c924,0x0002496d,0x00025bb6,0x00024b77},
712 {0x00000000,0x00000000,0x00000000,0x00000000,
713 0x00000000,0x00000000,0x00000000,0x00000000}
714 },
715 { /* version 5, passes 1 */
716 {0x00000000,0x00000000,0x00001249,0x00000249,
717 0x00000249,0x00000249,0x0000024a,0x0000024a},
718 {0x00000000,0x00000000,0x00001249,0x00001249,
719 0x0000124a,0x0000124a,0x0000024a,0x0000024a},
720 {0x00000000,0x00000000,0x00001249,0x0000924a,
721 0x00009252,0x00009252,0x0000024a,0x0000024a},
722 {0x00000000,0x00000000,0x00001249,0x00009292,
723 0x00009492,0x0000a49b,0x00001252,0x00001252},
724 {0x00000000,0x00000000,0x0000924a,0x00009493,
725 0x0000a493,0x0000a49b,0x00001252,0x00001252},
726 {0x00000000,0x00000000,0x0000924a,0x00009493,
727 0x0000a493,0x0000a49b,0x00009292,0x00001252},
728 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
729 0x0000a493,0x0000a49b,0x00009292,0x00009292},
730 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
731 0x0000a493,0x0000a49b,0x00009493,0x00009292},
732 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
733 0x0001249b,0x000124db,0x00009493,0x00009292},
734 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
735 0x0001249b,0x000124db,0x00009493,0x00009493},
736 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
737 0x000124db,0x000124db,0x0000a49b,0x00009493},
738 {0x00000000,0x00000000,0x0000924a,0x000124db,
739 0x000126dc,0x000126dc,0x0000a49b,0x00009493},
740 {0x00000000,0x00000000,0x0000924a,0x000124db,
741 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
742 {0x00000000,0x00000000,0x00009292,0x000124db,
743 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
744 {0x00000000,0x00000000,0x00009492,0x000126db,
745 0x0001b724,0x000136e4,0x000126dc,0x000124db},
746 {0x00000000,0x00000000,0x00000000,0x00000000,
747 0x00000000,0x00000000,0x00000000,0x00000000}
748 }
749 },
750 { /* version 6 */
751 { /* version 6, passes 0 */
752 {0x00000000,0x00000000,0x00001249,0x00001249,
753 0x00009252,0x00009292,0x00009493,0x00009493},
754 {0x00000000,0x00000000,0x00001249,0x00009292,
755 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
756 {0x00000000,0x00000000,0x00001249,0x00009493,
757 0x0000a493,0x000124db,0x000124db,0x0000a49b},
758 {0x00000000,0x00000000,0x0000924a,0x00009493,
759 0x0000a493,0x000126dc,0x000126dc,0x0000a49b},
760 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
761 0x0001249b,0x000126dc,0x000136e4,0x000124db},
762 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
763 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
764 {0x00000000,0x00000000,0x00009292,0x0000a49b,
765 0x000126dc,0x0001b724,0x0001b725,0x000126dc},
766 {0x00000000,0x00000000,0x00009292,0x0000a49b,
767 0x000136e4,0x0001b724,0x0001b92d,0x000136e4},
768 {0x00000000,0x00000000,0x00009492,0x0000a49b,
769 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
770 {0x00000000,0x00000000,0x00009492,0x000124db,
771 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
772 {0x00000000,0x00000000,0x00009492,0x000124db,
773 0x000136e4,0x0001b925,0x0001b92d,0x0001b925},
774 {0x00000000,0x00000000,0x00009492,0x000124db,
775 0x0001b724,0x0001b925,0x0001c96e,0x0001c92d},
776 {0x00000000,0x00000000,0x0000a492,0x000124db,
777 0x0001b724,0x0001c92d,0x0001c96e,0x0001c92d},
778 {0x00000000,0x00000000,0x0000a492,0x000124db,
779 0x0001b724,0x0001c92d,0x00024b76,0x0002496e},
780 {0x00000000,0x00000000,0x00012492,0x000126db,
781 0x0001c924,0x00024b6d,0x0002ddb6,0x00025bbf},
782 {0x00000000,0x00000000,0x00000000,0x00000000,
783 0x00000000,0x00000000,0x00000000,0x00000000}
784 },
785 { /* version 6, passes 1 */
786 {0x00000000,0x00000000,0x00001249,0x00001249,
787 0x0000124a,0x0000124a,0x00001252,0x00001252},
788 {0x00000000,0x00000000,0x00001249,0x00009292,
789 0x00009492,0x00009252,0x00001252,0x00001252},
790 {0x00000000,0x00000000,0x0000924a,0x00009493,
791 0x0000a493,0x00009292,0x00001252,0x00001252},
792 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
793 0x0000a493,0x0000a49b,0x00009292,0x00009292},
794 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
795 0x0000a493,0x0000a49b,0x00009292,0x00009292},
796 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
797 0x0001249b,0x0000a49b,0x00009493,0x00009292},
798 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
799 0x000124db,0x000124db,0x00009493,0x00009493},
800 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
801 0x000124db,0x000124db,0x0000a49b,0x00009493},
802 {0x00000000,0x00000000,0x0000924a,0x000124db,
803 0x000126dc,0x000124db,0x0000a49b,0x00009493},
804 {0x00000000,0x00000000,0x0000924a,0x000124db,
805 0x000126dc,0x000126dc,0x0000a49b,0x0000a49b},
806 {0x00000000,0x00000000,0x0000924a,0x000124db,
807 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
808 {0x00000000,0x00000000,0x00009492,0x000126db,
809 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
810 {0x00000000,0x00000000,0x00009492,0x000126db,
811 0x0001b724,0x000136e4,0x000126dc,0x000124db},
812 {0x00000000,0x00000000,0x00009492,0x000126db,
813 0x0001b724,0x000136e4,0x000126dc,0x000124db},
814 {0x00000000,0x00000000,0x0000a492,0x000136db,
815 0x0001c924,0x0001b724,0x000136e4,0x000126dc},
816 {0x00000000,0x00000000,0x00000000,0x00000000,
817 0x00000000,0x00000000,0x00000000,0x00000000}
818 }
819 },
820 { /* version 7 */
821 { /* version 7, passes 0 */
822 {0x00000000,0x00000000,0x00001249,0x00001249,
823 0x00009252,0x00009292,0x00009493,0x00009493},
824 {0x00000000,0x00000000,0x00001249,0x00009493,
825 0x0000a493,0x000124db,0x000126dc,0x00009493},
826 {0x00000000,0x00000000,0x00001249,0x0000a49b,
827 0x0001249b,0x000126dc,0x000126dc,0x0000a49b},
828 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
829 0x0001249b,0x000126dc,0x000136e4,0x0000a49b},
830 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
831 0x000126dc,0x000136e4,0x0001b725,0x000124db},
832 {0x00000000,0x00000000,0x00009292,0x0000a49b,
833 0x000136e4,0x0001b724,0x0001b725,0x000126dc},
834 {0x00000000,0x00000000,0x00009292,0x000124db,
835 0x000136e4,0x0001b724,0x0001b725,0x000126dc},
836 {0x00000000,0x00000000,0x00009492,0x000124db,
837 0x000136e4,0x0001b724,0x0001c96e,0x000136e4},
838 {0x00000000,0x00000000,0x00009492,0x000124db,
839 0x000136e4,0x0001c92d,0x0001c96e,0x0001b724},
840 {0x00000000,0x00000000,0x0000a492,0x000124db,
841 0x000136e4,0x0001c92d,0x0001c96e,0x0001b724},
842 {0x00000000,0x00000000,0x0000a492,0x000124db,
843 0x0001b724,0x0001c92d,0x0001c96e,0x0001b925},
844 {0x00000000,0x00000000,0x0000a492,0x000126db,
845 0x0001b724,0x0001c92d,0x00024b76,0x0001c92d},
846 {0x00000000,0x00000000,0x0000a492,0x000126db,
847 0x0001b924,0x0001c92d,0x00024b76,0x0001c92d},
848 {0x00000000,0x00000000,0x0000a492,0x000126db,
849 0x0001b924,0x0001c92d,0x00024b76,0x0002496e},
850 {0x00000000,0x00000000,0x00012492,0x000136db,
851 0x00024924,0x00024b6d,0x0002ddb6,0x00025bbf},
852 {0x00000000,0x00000000,0x00000000,0x00000000,
853 0x00000000,0x00000000,0x00000000,0x00000000}
854 },
855 { /* version 7, passes 1 */
856 {0x00000000,0x00000000,0x00001249,0x00001249,
857 0x0000124a,0x0000124a,0x00001252,0x00001252},
858 {0x00000000,0x00000000,0x0000924a,0x00009493,
859 0x00009492,0x00009292,0x00001252,0x00001252},
860 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
861 0x0000a493,0x0000a49b,0x00001252,0x00001252},
862 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
863 0x0000a493,0x0000a49b,0x00009292,0x00009292},
864 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
865 0x0000a493,0x0000a49b,0x00009292,0x00009292},
866 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
867 0x000126dc,0x0000a49b,0x00009493,0x00009292},
868 {0x00000000,0x00000000,0x0000924a,0x000124db,
869 0x000126dc,0x000124db,0x00009493,0x00009493},
870 {0x00000000,0x00000000,0x0000924a,0x000124db,
871 0x000136e4,0x000124db,0x0000a49b,0x00009493},
872 {0x00000000,0x00000000,0x0000924a,0x000136db,
873 0x0001b724,0x000124db,0x0000a49b,0x00009493},
874 {0x00000000,0x00000000,0x0000924a,0x000136db,
875 0x0001b724,0x000126dc,0x0000a49b,0x0000a49b},
876 {0x00000000,0x00000000,0x00009292,0x000136db,
877 0x0001b724,0x000126dc,0x000124db,0x0000a49b},
878 {0x00000000,0x00000000,0x00009492,0x000136db,
879 0x0001b724,0x000126dc,0x000124db,0x0000a49b},
880 {0x00000000,0x00000000,0x0000a492,0x000136db,
881 0x0001b724,0x000136e4,0x000126dc,0x000124db},
882 {0x00000000,0x00000000,0x0000a492,0x000136db,
883 0x0001b724,0x000136e4,0x000126dc,0x000124db},
884 {0x00000000,0x00000000,0x00012492,0x0001b6db,
885 0x0001c924,0x0001b724,0x000136e4,0x000126dc},
886 {0x00000000,0x00000000,0x00000000,0x00000000,
887 0x00000000,0x00000000,0x00000000,0x00000000}
888 }
889 }
890};
891
diff --git a/drivers/usb/media/pwc/pwc-timon.c b/drivers/usb/media/pwc/pwc-timon.c
index f950a4e5ed96..dee967173d6c 100644
--- a/drivers/usb/media/pwc/pwc-timon.c
+++ b/drivers/usb/media/pwc/pwc-timon.c
@@ -314,1133 +314,3 @@ const struct Timon_table_entry Timon_table[PSZ_MAX][6][4] =
314 }, 314 },
315}; 315};
316 316
317/*
318 * 16 versions:
319 * 2 tables (one for Y, and one for U&V)
320 * 16 levels of details per tables
321 * 8 blocs
322 */
323
324const unsigned int TimonRomTable [16][2][16][8] =
325{
326 { /* version 0 */
327 { /* version 0, passes 0 */
328 {0x00000000,0x00000000,0x00000000,0x00000000,
329 0x00000000,0x00000000,0x00000000,0x00000001},
330 {0x00000000,0x00000000,0x00000001,0x00000001,
331 0x00000001,0x00000001,0x00000001,0x00000001},
332 {0x00000000,0x00000000,0x00000001,0x00000001,
333 0x00000001,0x00000009,0x00000009,0x00000009},
334 {0x00000000,0x00000000,0x00000009,0x00000001,
335 0x00000009,0x00000009,0x00000009,0x00000009},
336 {0x00000000,0x00000000,0x00000009,0x00000009,
337 0x00000009,0x00000009,0x00000049,0x00000009},
338 {0x00000000,0x00000000,0x00000009,0x00000009,
339 0x00000009,0x00000049,0x00000049,0x00000049},
340 {0x00000000,0x00000000,0x00000009,0x00000009,
341 0x00000049,0x00000049,0x00000049,0x00000049},
342 {0x00000000,0x00000000,0x00000009,0x00000049,
343 0x00000049,0x00000049,0x00000049,0x00000049},
344 {0x00000000,0x00000000,0x00000049,0x00000049,
345 0x00000049,0x00000049,0x0000024a,0x0000024a},
346 {0x00000000,0x00000000,0x00000049,0x00000049,
347 0x00000049,0x00000249,0x0000024a,0x0000024a},
348 {0x00000000,0x00000000,0x00000049,0x00000049,
349 0x00000249,0x00000249,0x0000024a,0x0000024a},
350 {0x00000000,0x00000000,0x00000049,0x00000049,
351 0x00000249,0x00000249,0x00001252,0x0000024a},
352 {0x00000000,0x00000000,0x00000049,0x00000049,
353 0x00000249,0x0000124a,0x00001252,0x0000024a},
354 {0x00000000,0x00000000,0x00000049,0x00000249,
355 0x00000249,0x0000124a,0x00001252,0x0000024a},
356 {0x00000000,0x00000000,0x00000249,0x00001249,
357 0x0000124a,0x00009252,0x00009292,0x00001252},
358 {0x00000000,0x00000000,0x00000000,0x00000000,
359 0x00000000,0x00000000,0x00000000,0x00000000}
360 },
361 { /* version 0, passes 1 */
362 {0x00000000,0x00000000,0x00000000,0x00000000,
363 0x00000000,0x00000000,0x00000000,0x00000000},
364 {0x00000000,0x00000000,0x00000001,0x00000001,
365 0x00000001,0x00000001,0x00000000,0x00000000},
366 {0x00000000,0x00000000,0x00000009,0x00000001,
367 0x00000001,0x00000009,0x00000000,0x00000000},
368 {0x00000000,0x00000000,0x00000009,0x00000009,
369 0x00000009,0x00000009,0x00000000,0x00000000},
370 {0x00000000,0x00000000,0x00000009,0x00000009,
371 0x00000009,0x00000009,0x00000001,0x00000000},
372 {0x00000000,0x00000000,0x00000049,0x00000009,
373 0x00000009,0x00000049,0x00000001,0x00000001},
374 {0x00000000,0x00000000,0x00000049,0x00000009,
375 0x00000009,0x00000049,0x00000001,0x00000001},
376 {0x00000000,0x00000000,0x00000049,0x00000049,
377 0x00000049,0x00000049,0x00000009,0x00000001},
378 {0x00000000,0x00000000,0x00000049,0x00000049,
379 0x00000049,0x00000049,0x00000009,0x00000001},
380 {0x00000000,0x00000000,0x00000049,0x00000049,
381 0x00000049,0x00000049,0x00000009,0x00000001},
382 {0x00000000,0x00000000,0x00000049,0x00000049,
383 0x00000049,0x00000049,0x00000009,0x00000009},
384 {0x00000000,0x00000000,0x00000049,0x00000049,
385 0x00000049,0x00000249,0x00000049,0x00000009},
386 {0x00000000,0x00000000,0x00000049,0x00000049,
387 0x00000049,0x00000249,0x00000049,0x00000009},
388 {0x00000000,0x00000000,0x00000249,0x00000049,
389 0x00000249,0x00000249,0x00000049,0x00000009},
390 {0x00000000,0x00000000,0x00001249,0x00000249,
391 0x0000124a,0x0000124a,0x0000024a,0x00000049},
392 {0x00000000,0x00000000,0x00000000,0x00000000,
393 0x00000000,0x00000000,0x00000000,0x00000000}
394 }
395 },
396 { /* version 1 */
397 { /* version 1, passes 0 */
398 {0x00000000,0x00000000,0x00000000,0x00000000,
399 0x00000000,0x00000000,0x00000000,0x00000001},
400 {0x00000000,0x00000000,0x00000001,0x00000001,
401 0x00000001,0x00000009,0x00000009,0x00000009},
402 {0x00000000,0x00000000,0x00000009,0x00000009,
403 0x00000009,0x00000009,0x00000009,0x00000009},
404 {0x00000000,0x00000000,0x00000009,0x00000009,
405 0x00000009,0x00000049,0x00000049,0x00000049},
406 {0x00000000,0x00000000,0x00000009,0x00000049,
407 0x00000049,0x00000049,0x00000049,0x00000049},
408 {0x00000000,0x00000000,0x00000049,0x00000049,
409 0x00000049,0x00000249,0x0000024a,0x0000024a},
410 {0x00000000,0x00000000,0x00000049,0x00000049,
411 0x00000249,0x00000249,0x0000024a,0x0000024a},
412 {0x00000000,0x00000000,0x00000049,0x00000249,
413 0x00000249,0x00000249,0x0000024a,0x00001252},
414 {0x00000000,0x00000000,0x00000049,0x00000249,
415 0x00000249,0x0000124a,0x00001252,0x00001252},
416 {0x00000000,0x00000000,0x00000049,0x00000249,
417 0x0000124a,0x0000124a,0x00001252,0x00001252},
418 {0x00000000,0x00000000,0x00000249,0x00000249,
419 0x0000124a,0x0000124a,0x00009292,0x00009292},
420 {0x00000000,0x00000000,0x00000249,0x00001249,
421 0x0000124a,0x00009252,0x00009292,0x00009292},
422 {0x00000000,0x00000000,0x00000249,0x00001249,
423 0x00009252,0x00009252,0x00009292,0x00009292},
424 {0x00000000,0x00000000,0x00000249,0x0000924a,
425 0x00009292,0x00009493,0x00009493,0x00009493},
426 {0x00000000,0x00000000,0x00001249,0x00009252,
427 0x00009492,0x0000a49b,0x0000a49b,0x0000a49b},
428 {0x00000000,0x00000000,0x00000000,0x00000000,
429 0x00000000,0x00000000,0x00000000,0x00000000}
430 },
431 { /* version 1, passes 1 */
432 {0x00000000,0x00000000,0x00000000,0x00000000,
433 0x00000000,0x00000000,0x00000000,0x00000000},
434 {0x00000000,0x00000000,0x00000009,0x00000009,
435 0x00000009,0x00000001,0x00000001,0x00000000},
436 {0x00000000,0x00000000,0x00000009,0x00000009,
437 0x00000009,0x00000009,0x00000001,0x00000000},
438 {0x00000000,0x00000000,0x00000049,0x00000049,
439 0x00000049,0x00000009,0x00000001,0x00000000},
440 {0x00000000,0x00000000,0x00000049,0x00000049,
441 0x00000049,0x00000049,0x00000001,0x00000001},
442 {0x00000000,0x00000000,0x00000049,0x00000049,
443 0x00000049,0x00000049,0x00000009,0x00000001},
444 {0x00000000,0x00000000,0x00000249,0x00000049,
445 0x00000049,0x00000249,0x00000009,0x00000001},
446 {0x00000000,0x00000000,0x00000249,0x00000049,
447 0x00000249,0x00000249,0x00000009,0x00000009},
448 {0x00000000,0x00000000,0x00000249,0x00000249,
449 0x00000249,0x00000249,0x00000049,0x00000009},
450 {0x00000000,0x00000000,0x00000249,0x00000249,
451 0x00000249,0x0000124a,0x00000049,0x00000009},
452 {0x00000000,0x00000000,0x00000249,0x00000249,
453 0x00000249,0x0000124a,0x00000049,0x00000009},
454 {0x00000000,0x00000000,0x00000249,0x00000249,
455 0x00000249,0x0000124a,0x0000024a,0x00000049},
456 {0x00000000,0x00000000,0x00000249,0x00000249,
457 0x0000124a,0x0000124a,0x0000024a,0x00000049},
458 {0x00000000,0x00000000,0x00000249,0x00000249,
459 0x0000124a,0x0000124a,0x0000024a,0x00000049},
460 {0x00000000,0x00000000,0x00001249,0x00001249,
461 0x00009252,0x00009252,0x00001252,0x0000024a},
462 {0x00000000,0x00000000,0x00000000,0x00000000,
463 0x00000000,0x00000000,0x00000000,0x00000000}
464 }
465 },
466 { /* version 2 */
467 { /* version 2, passes 0 */
468 {0x00000000,0x00000000,0x00000000,0x00000000,
469 0x00000000,0x00000000,0x00000000,0x00000001},
470 {0x00000000,0x00000000,0x00000009,0x00000009,
471 0x00000009,0x00000009,0x00000009,0x00000009},
472 {0x00000000,0x00000000,0x00000049,0x00000049,
473 0x00000049,0x00000049,0x00000049,0x00000049},
474 {0x00000000,0x00000000,0x00000049,0x00000049,
475 0x00000049,0x00000249,0x0000024a,0x0000024a},
476 {0x00000000,0x00000000,0x00000049,0x00000249,
477 0x00000249,0x00000249,0x0000024a,0x00001252},
478 {0x00000000,0x00000000,0x00000249,0x00000249,
479 0x00000249,0x0000124a,0x00001252,0x00001252},
480 {0x00000000,0x00000000,0x00000249,0x00000249,
481 0x0000124a,0x0000124a,0x00009292,0x00009292},
482 {0x00000000,0x00000000,0x00000249,0x00001249,
483 0x0000124a,0x00009252,0x00009292,0x00009292},
484 {0x00000000,0x00000000,0x00000249,0x00001249,
485 0x00009252,0x00009292,0x00009292,0x00009292},
486 {0x00000000,0x00000000,0x00000249,0x00001249,
487 0x00009252,0x00009292,0x00009493,0x00009493},
488 {0x00000000,0x00000000,0x00000249,0x0000924a,
489 0x00009252,0x00009493,0x00009493,0x00009493},
490 {0x00000000,0x00000000,0x00000249,0x0000924a,
491 0x00009292,0x00009493,0x00009493,0x00009493},
492 {0x00000000,0x00000000,0x00000249,0x00009252,
493 0x00009492,0x00009493,0x0000a49b,0x0000a49b},
494 {0x00000000,0x00000000,0x00001249,0x00009292,
495 0x00009492,0x000124db,0x000124db,0x000124db},
496 {0x00000000,0x00000000,0x0000924a,0x00009493,
497 0x0000a493,0x000126dc,0x000126dc,0x000126dc},
498 {0x00000000,0x00000000,0x00000000,0x00000000,
499 0x00000000,0x00000000,0x00000000,0x00000000}
500 },
501 { /* version 2, passes 1 */
502 {0x00000000,0x00000000,0x00000000,0x00000000,
503 0x00000000,0x00000000,0x00000000,0x00000000},
504 {0x00000000,0x00000000,0x00000049,0x00000009,
505 0x00000049,0x00000009,0x00000001,0x00000000},
506 {0x00000000,0x00000000,0x00000049,0x00000049,
507 0x00000049,0x00000049,0x00000049,0x00000000},
508 {0x00000000,0x00000000,0x00000249,0x00000049,
509 0x00000249,0x00000049,0x0000024a,0x00000001},
510 {0x00000000,0x00000000,0x00000249,0x00000249,
511 0x00000249,0x00000249,0x0000024a,0x00000001},
512 {0x00000000,0x00000000,0x00000249,0x00000249,
513 0x00000249,0x00000249,0x0000024a,0x00000001},
514 {0x00000000,0x00000000,0x00000249,0x00000249,
515 0x00000249,0x00000249,0x0000024a,0x00000009},
516 {0x00000000,0x00000000,0x00000249,0x00000249,
517 0x0000124a,0x0000124a,0x0000024a,0x00000009},
518 {0x00000000,0x00000000,0x00000249,0x00000249,
519 0x0000124a,0x0000124a,0x0000024a,0x00000009},
520 {0x00000000,0x00000000,0x00001249,0x00001249,
521 0x0000124a,0x00009252,0x00001252,0x00000049},
522 {0x00000000,0x00000000,0x00001249,0x00001249,
523 0x0000124a,0x00009292,0x00001252,0x00000049},
524 {0x00000000,0x00000000,0x00001249,0x00001249,
525 0x0000124a,0x00009292,0x00001252,0x00000049},
526 {0x00000000,0x00000000,0x00001249,0x00001249,
527 0x00009252,0x00009292,0x00001252,0x0000024a},
528 {0x00000000,0x00000000,0x00001249,0x00001249,
529 0x00009292,0x00009292,0x00001252,0x0000024a},
530 {0x00000000,0x00000000,0x0000924a,0x0000924a,
531 0x00009492,0x00009493,0x00009292,0x00001252},
532 {0x00000000,0x00000000,0x00000000,0x00000000,
533 0x00000000,0x00000000,0x00000000,0x00000000}
534 }
535 },
536 { /* version 3 */
537 { /* version 3, passes 0 */
538 {0x00000000,0x00000000,0x00000000,0x00000000,
539 0x00000000,0x00000000,0x00000000,0x00000001},
540 {0x00000000,0x00000000,0x00000049,0x00000049,
541 0x00000049,0x00000049,0x00000049,0x00000049},
542 {0x00000000,0x00000000,0x00000049,0x00000249,
543 0x00000249,0x00000249,0x00001252,0x0000024a},
544 {0x00000000,0x00000000,0x00000249,0x00000249,
545 0x00000249,0x0000124a,0x00001252,0x00001252},
546 {0x00000000,0x00000000,0x00000249,0x00000249,
547 0x0000124a,0x00009252,0x00009292,0x00009292},
548 {0x00000000,0x00000000,0x00000249,0x00001249,
549 0x0000124a,0x00009292,0x00009292,0x00009493},
550 {0x00000000,0x00000000,0x00000249,0x00001249,
551 0x00009252,0x00009292,0x00009493,0x00009493},
552 {0x00000000,0x00000000,0x00000249,0x00001249,
553 0x00009292,0x00009493,0x00009493,0x00009493},
554 {0x00000000,0x00000000,0x00000249,0x00009252,
555 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
556 {0x00000000,0x00000000,0x00001249,0x00009252,
557 0x00009292,0x0000a49b,0x0000a49b,0x0000a49b},
558 {0x00000000,0x00000000,0x00001249,0x00009252,
559 0x00009492,0x0000a49b,0x0000a49b,0x0000a49b},
560 {0x00000000,0x00000000,0x00001249,0x00009292,
561 0x00009492,0x0000a49b,0x000124db,0x000124db},
562 {0x00000000,0x00000000,0x00001249,0x00009292,
563 0x0000a493,0x0000a49b,0x000124db,0x000124db},
564 {0x00000000,0x00000000,0x00001249,0x00009493,
565 0x0001249b,0x000126dc,0x000136e4,0x000126dc},
566 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
567 0x000124db,0x000136e4,0x0001b725,0x000136e4},
568 {0x00000000,0x00000000,0x00000000,0x00000000,
569 0x00000000,0x00000000,0x00000000,0x00000000}
570 },
571 { /* version 3, passes 1 */
572 {0x00000000,0x00000000,0x00000000,0x00000000,
573 0x00000000,0x00000000,0x00000000,0x00000000},
574 {0x00000000,0x00000000,0x00000049,0x00000049,
575 0x00000049,0x00000049,0x00000001,0x00000000},
576 {0x00000000,0x00000000,0x00000249,0x00000249,
577 0x00000249,0x00000249,0x00000049,0x00000001},
578 {0x00000000,0x00000000,0x00000249,0x00000249,
579 0x00000249,0x0000124a,0x00001252,0x00000001},
580 {0x00000000,0x00000000,0x00000249,0x00000249,
581 0x0000124a,0x0000124a,0x00001252,0x00000009},
582 {0x00000000,0x00000000,0x00000249,0x00001249,
583 0x0000124a,0x00009252,0x00009292,0x00000009},
584 {0x00000000,0x00000000,0x00001249,0x00001249,
585 0x0000124a,0x00009252,0x00009292,0x00000049},
586 {0x00000000,0x00000000,0x00001249,0x00001249,
587 0x00009252,0x00009252,0x00009292,0x00000049},
588 {0x00000000,0x00000000,0x00001249,0x00001249,
589 0x00009252,0x00009493,0x00009292,0x0000024a},
590 {0x00000000,0x00000000,0x00001249,0x00001249,
591 0x00009252,0x00009493,0x00009292,0x0000024a},
592 {0x00000000,0x00000000,0x00001249,0x00001249,
593 0x00009252,0x00009493,0x00009493,0x00001252},
594 {0x00000000,0x00000000,0x00001249,0x0000924a,
595 0x00009292,0x00009493,0x00009493,0x00001252},
596 {0x00000000,0x00000000,0x00001249,0x0000924a,
597 0x00009492,0x00009493,0x00009493,0x00009292},
598 {0x00000000,0x00000000,0x00001249,0x00009252,
599 0x00009492,0x0000a49b,0x00009493,0x00009292},
600 {0x00000000,0x00000000,0x0000924a,0x00009292,
601 0x0000a493,0x000124db,0x0000a49b,0x00009493},
602 {0x00000000,0x00000000,0x00000000,0x00000000,
603 0x00000000,0x00000000,0x00000000,0x00000000}
604 }
605 },
606 { /* version 4 */
607 { /* version 4, passes 0 */
608 {0x00000000,0x00000000,0x00000049,0x00000049,
609 0x00000049,0x00000049,0x0000024a,0x0000024a},
610 {0x00000000,0x00000000,0x00000249,0x00000249,
611 0x00000249,0x0000124a,0x00001252,0x00009292},
612 {0x00000000,0x00000000,0x00000249,0x00000249,
613 0x0000124a,0x00009252,0x00009292,0x00009292},
614 {0x00000000,0x00000000,0x00000249,0x00001249,
615 0x0000124a,0x00009292,0x00009493,0x00009493},
616 {0x00000000,0x00000000,0x00000249,0x00001249,
617 0x00009252,0x00009493,0x00009493,0x0000a49b},
618 {0x00000000,0x00000000,0x00000249,0x0000924a,
619 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
620 {0x00000000,0x00000000,0x00001249,0x0000924a,
621 0x00009292,0x00009493,0x0000a49b,0x000124db},
622 {0x00000000,0x00000000,0x00001249,0x00009252,
623 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
624 {0x00000000,0x00000000,0x00001249,0x00009292,
625 0x00009492,0x000124db,0x000124db,0x000126dc},
626 {0x00000000,0x00000000,0x00001249,0x00009292,
627 0x0000a493,0x000124db,0x000126dc,0x000126dc},
628 {0x00000000,0x00000000,0x00001249,0x00009493,
629 0x0000a493,0x000124db,0x000126dc,0x000136e4},
630 {0x00000000,0x00000000,0x00001249,0x00009493,
631 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
632 {0x00000000,0x00000000,0x0000924a,0x00009493,
633 0x0001249b,0x000126dc,0x000136e4,0x000136e4},
634 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
635 0x000124db,0x000136e4,0x000136e4,0x0001b724},
636 {0x00000000,0x00000000,0x00009252,0x000124db,
637 0x000126dc,0x0001b724,0x0001b725,0x0001b925},
638 {0x00000000,0x00000000,0x00000000,0x00000000,
639 0x00000000,0x00000000,0x00000000,0x00000000}
640 },
641 { /* version 4, passes 1 */
642 {0x00000000,0x00000000,0x00000049,0x00000049,
643 0x00000049,0x00000049,0x00000049,0x00000049},
644 {0x00000000,0x00000000,0x00000249,0x00000249,
645 0x00000249,0x00000249,0x0000024a,0x00000049},
646 {0x00000000,0x00000000,0x00001249,0x00000249,
647 0x0000124a,0x0000124a,0x00001252,0x00000049},
648 {0x00000000,0x00000000,0x00001249,0x00001249,
649 0x0000124a,0x0000124a,0x00009292,0x0000024a},
650 {0x00000000,0x00000000,0x00001249,0x00001249,
651 0x00009252,0x00009292,0x00009292,0x0000024a},
652 {0x00000000,0x00000000,0x00001249,0x00001249,
653 0x00009252,0x00009292,0x0000a49b,0x0000024a},
654 {0x00000000,0x00000000,0x00001249,0x00001249,
655 0x00009292,0x00009493,0x0000a49b,0x00001252},
656 {0x00000000,0x00000000,0x00001249,0x00001249,
657 0x00009292,0x00009493,0x0000a49b,0x00001252},
658 {0x00000000,0x00000000,0x00001249,0x0000924a,
659 0x00009492,0x0000a49b,0x0000a49b,0x00001252},
660 {0x00000000,0x00000000,0x00001249,0x00009252,
661 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
662 {0x00000000,0x00000000,0x00001249,0x00009292,
663 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
664 {0x00000000,0x00000000,0x00001249,0x00009493,
665 0x0000a493,0x0000a49b,0x0000a49b,0x00009292},
666 {0x00000000,0x00000000,0x00001249,0x00009493,
667 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
668 {0x00000000,0x00000000,0x0000924a,0x00009493,
669 0x0000a493,0x000124db,0x0000a49b,0x00009493},
670 {0x00000000,0x00000000,0x00009252,0x0000a49b,
671 0x0001249b,0x000126dc,0x000124db,0x0000a49b},
672 {0x00000000,0x00000000,0x00000000,0x00000000,
673 0x00000000,0x00000000,0x00000000,0x00000000}
674 }
675 },
676 { /* version 5 */
677 { /* version 5, passes 0 */
678 {0x00000000,0x00000000,0x00000249,0x00000249,
679 0x00000249,0x0000124a,0x00001252,0x00009292},
680 {0x00000000,0x00000000,0x00000249,0x00001249,
681 0x0000124a,0x00009292,0x00009292,0x00009493},
682 {0x00000000,0x00000000,0x00000249,0x0000924a,
683 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
684 {0x00000000,0x00000000,0x00001249,0x0000924a,
685 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
686 {0x00000000,0x00000000,0x00001249,0x0000924a,
687 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
688 {0x00000000,0x00000000,0x00001249,0x00009292,
689 0x00009492,0x0000a49b,0x000124db,0x000124db},
690 {0x00000000,0x00000000,0x00001249,0x00009292,
691 0x0000a493,0x000124db,0x000124db,0x000126dc},
692 {0x00000000,0x00000000,0x00001249,0x00009493,
693 0x0000a493,0x000124db,0x000126dc,0x000126dc},
694 {0x00000000,0x00000000,0x00001249,0x00009493,
695 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
696 {0x00000000,0x00000000,0x00001249,0x00009493,
697 0x0001249b,0x000126dc,0x000136e4,0x000136e4},
698 {0x00000000,0x00000000,0x00001249,0x00009493,
699 0x0001249b,0x000126dc,0x000136e4,0x000136e4},
700 {0x00000000,0x00000000,0x0000924a,0x00009493,
701 0x0001249b,0x000126dc,0x0001b725,0x0001b724},
702 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
703 0x000124db,0x000126dc,0x0001b725,0x0001b724},
704 {0x00000000,0x00000000,0x00009292,0x0000a49b,
705 0x000126dc,0x000136e4,0x0001b92d,0x0001b925},
706 {0x00000000,0x00000000,0x00009492,0x000124db,
707 0x000136e4,0x0001b724,0x0001c96e,0x0001c92d},
708 {0x00000000,0x00000000,0x00000000,0x00000000,
709 0x00000000,0x00000000,0x00000000,0x00000000}
710 },
711 { /* version 5, passes 1 */
712 {0x00000000,0x00000000,0x00000249,0x00000249,
713 0x0000124a,0x00000249,0x0000024a,0x0000024a},
714 {0x00000000,0x00000000,0x00001249,0x00001249,
715 0x0000124a,0x0000124a,0x00001252,0x0000024a},
716 {0x00000000,0x00000000,0x00001249,0x00001249,
717 0x00009292,0x00009493,0x00009493,0x0000024a},
718 {0x00000000,0x00000000,0x00001249,0x00001249,
719 0x00009292,0x00009493,0x00009493,0x00001252},
720 {0x00000000,0x00000000,0x00001249,0x00001249,
721 0x00009292,0x00009493,0x0000a49b,0x00001252},
722 {0x00000000,0x00000000,0x00001249,0x0000924a,
723 0x00009492,0x00009493,0x000124db,0x00001252},
724 {0x00000000,0x00000000,0x00001249,0x00009292,
725 0x00009492,0x00009493,0x000124db,0x00009292},
726 {0x00000000,0x00000000,0x00001249,0x00009292,
727 0x00009492,0x0000a49b,0x000124db,0x00009292},
728 {0x00000000,0x00000000,0x00001249,0x00009493,
729 0x0000a493,0x0000a49b,0x000124db,0x00009292},
730 {0x00000000,0x00000000,0x00001249,0x00009493,
731 0x0000a493,0x000124db,0x000124db,0x00009493},
732 {0x00000000,0x00000000,0x0000924a,0x00009493,
733 0x0000a493,0x000124db,0x000124db,0x00009493},
734 {0x00000000,0x00000000,0x0000924a,0x00009493,
735 0x0000a493,0x000124db,0x000124db,0x00009493},
736 {0x00000000,0x00000000,0x0000924a,0x00009493,
737 0x0000a493,0x000124db,0x000124db,0x0000a49b},
738 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
739 0x000124db,0x000126dc,0x000124db,0x0000a49b},
740 {0x00000000,0x00000000,0x00009252,0x000124db,
741 0x000126dc,0x000136e4,0x000126dc,0x000124db},
742 {0x00000000,0x00000000,0x00000000,0x00000000,
743 0x00000000,0x00000000,0x00000000,0x00000000}
744 }
745 },
746 { /* version 6 */
747 { /* version 6, passes 0 */
748 {0x00000000,0x00000000,0x00000249,0x00000249,
749 0x0000124a,0x0000124a,0x00009292,0x00009292},
750 {0x00000000,0x00000000,0x00001249,0x00001249,
751 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
752 {0x00000000,0x00000000,0x00001249,0x0000924a,
753 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
754 {0x00000000,0x00000000,0x00001249,0x00009292,
755 0x00009492,0x000124db,0x000126dc,0x000126dc},
756 {0x00000000,0x00000000,0x00001249,0x00009493,
757 0x0000a493,0x000124db,0x000126dc,0x000126dc},
758 {0x00000000,0x00000000,0x00001249,0x00009493,
759 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
760 {0x00000000,0x00000000,0x00001249,0x00009493,
761 0x0000a493,0x000126dc,0x000136e4,0x0001b724},
762 {0x00000000,0x00000000,0x00001249,0x00009493,
763 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
764 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
765 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
766 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
767 0x0001249b,0x000136e4,0x0001b725,0x0001b724},
768 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
769 0x000124db,0x000136e4,0x0001b725,0x0001b925},
770 {0x00000000,0x00000000,0x00009292,0x0000a49b,
771 0x000126dc,0x000136e4,0x0001b92d,0x0001b925},
772 {0x00000000,0x00000000,0x00009292,0x0000a49b,
773 0x000126dc,0x0001b724,0x0001b92d,0x0001c92d},
774 {0x00000000,0x00000000,0x00009492,0x000124db,
775 0x000126dc,0x0001b724,0x0001c96e,0x0001c92d},
776 {0x00000000,0x00000000,0x0000a492,0x000126db,
777 0x000136e4,0x0001b925,0x00025bb6,0x00024b77},
778 {0x00000000,0x00000000,0x00000000,0x00000000,
779 0x00000000,0x00000000,0x00000000,0x00000000}
780 },
781 { /* version 6, passes 1 */
782 {0x00000000,0x00000000,0x00001249,0x00000249,
783 0x0000124a,0x0000124a,0x00001252,0x00001252},
784 {0x00000000,0x00000000,0x00001249,0x00001249,
785 0x00009252,0x00009292,0x00009292,0x00001252},
786 {0x00000000,0x00000000,0x00001249,0x0000924a,
787 0x00009492,0x00009493,0x0000a49b,0x00001252},
788 {0x00000000,0x00000000,0x00001249,0x00009252,
789 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
790 {0x00000000,0x00000000,0x00001249,0x00009292,
791 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
792 {0x00000000,0x00000000,0x00001249,0x00009493,
793 0x0000a493,0x0000a49b,0x000126dc,0x00009292},
794 {0x00000000,0x00000000,0x0000924a,0x00009493,
795 0x0000a493,0x0000a49b,0x000126dc,0x00009493},
796 {0x00000000,0x00000000,0x0000924a,0x00009493,
797 0x0000a493,0x0000a49b,0x000126dc,0x00009493},
798 {0x00000000,0x00000000,0x0000924a,0x00009493,
799 0x0000a493,0x000124db,0x000126dc,0x00009493},
800 {0x00000000,0x00000000,0x0000924a,0x00009493,
801 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
802 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
803 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
804 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
805 0x0001249b,0x000126dc,0x000126dc,0x0000a49b},
806 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
807 0x000124db,0x000136e4,0x000126dc,0x000124db},
808 {0x00000000,0x00000000,0x00009492,0x0000a49b,
809 0x000136e4,0x000136e4,0x000126dc,0x000124db},
810 {0x00000000,0x00000000,0x0000a492,0x000124db,
811 0x0001b724,0x0001b724,0x000136e4,0x000126dc},
812 {0x00000000,0x00000000,0x00000000,0x00000000,
813 0x00000000,0x00000000,0x00000000,0x00000000}
814 }
815 },
816 { /* version 7 */
817 { /* version 7, passes 0 */
818 {0x00000000,0x00000000,0x00001249,0x00001249,
819 0x00009292,0x00009493,0x0000a49b,0x000124db},
820 {0x00000000,0x00000000,0x00001249,0x00009292,
821 0x0000a493,0x0000a49b,0x000124db,0x000126dc},
822 {0x00000000,0x00000000,0x00001249,0x00009493,
823 0x0000a493,0x000124db,0x000126dc,0x000136e4},
824 {0x00000000,0x00000000,0x00001249,0x00009493,
825 0x0000a493,0x000124db,0x000136e4,0x000136e4},
826 {0x00000000,0x00000000,0x00001249,0x00009493,
827 0x0001249b,0x000126dc,0x000136e4,0x000136e4},
828 {0x00000000,0x00000000,0x00001249,0x0000a49b,
829 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
830 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
831 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
832 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
833 0x000124db,0x000136e4,0x0001b725,0x0001b724},
834 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
835 0x000126dc,0x000136e4,0x0001b725,0x0001b925},
836 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
837 0x000126dc,0x0001b724,0x0001b92d,0x0001b925},
838 {0x00000000,0x00000000,0x00009292,0x0000a49b,
839 0x000126dc,0x0001b724,0x0001c96e,0x0001c92d},
840 {0x00000000,0x00000000,0x00009292,0x000124db,
841 0x000126dc,0x0001b724,0x0001c96e,0x0001c92d},
842 {0x00000000,0x00000000,0x00009492,0x000124db,
843 0x000136e4,0x0001b724,0x0001c96e,0x0002496e},
844 {0x00000000,0x00000000,0x00009492,0x000126db,
845 0x000136e4,0x0001b925,0x0001c96e,0x0002496e},
846 {0x00000000,0x00000000,0x0000a492,0x000136db,
847 0x0001b724,0x0002496d,0x00025bb6,0x00025bbf},
848 {0x00000000,0x00000000,0x00000000,0x00000000,
849 0x00000000,0x00000000,0x00000000,0x00000000}
850 },
851 { /* version 7, passes 1 */
852 {0x00000000,0x00000000,0x00001249,0x00001249,
853 0x00009252,0x00009292,0x00009292,0x00009292},
854 {0x00000000,0x00000000,0x00001249,0x0000924a,
855 0x00009492,0x00009493,0x00009493,0x00009292},
856 {0x00000000,0x00000000,0x00001249,0x00009493,
857 0x0000a493,0x0000a49b,0x0000a49b,0x00009292},
858 {0x00000000,0x00000000,0x0000924a,0x00009493,
859 0x0000a493,0x0000a49b,0x000124db,0x00009493},
860 {0x00000000,0x00000000,0x0000924a,0x00009493,
861 0x0000a493,0x000124db,0x000124db,0x00009493},
862 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
863 0x0000a493,0x000124db,0x000136e4,0x00009493},
864 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
865 0x0000a493,0x000124db,0x000136e4,0x0000a49b},
866 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
867 0x0001249b,0x000124db,0x000136e4,0x0000a49b},
868 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
869 0x0001249b,0x000126dc,0x000136e4,0x0000a49b},
870 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
871 0x0001249b,0x000126dc,0x000136e4,0x000124db},
872 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
873 0x000126dc,0x000136e4,0x000136e4,0x000124db},
874 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
875 0x000126dc,0x000136e4,0x000136e4,0x000124db},
876 {0x00000000,0x00000000,0x0000924a,0x000124db,
877 0x000136e4,0x000136e4,0x000136e4,0x000126dc},
878 {0x00000000,0x00000000,0x0000a492,0x000124db,
879 0x000136e4,0x0001b724,0x000136e4,0x000126dc},
880 {0x00000000,0x00000000,0x00012492,0x000126db,
881 0x0001b724,0x0001b925,0x0001b725,0x000136e4},
882 {0x00000000,0x00000000,0x00000000,0x00000000,
883 0x00000000,0x00000000,0x00000000,0x00000000}
884 }
885 },
886 { /* version 8 */
887 { /* version 8, passes 0 */
888 {0x00000000,0x00000000,0x00001249,0x00001249,
889 0x00009292,0x00009493,0x0000a49b,0x000124db},
890 {0x00000000,0x00000000,0x00001249,0x00009292,
891 0x0000a493,0x000124db,0x000126dc,0x000126dc},
892 {0x00000000,0x00000000,0x00001249,0x00009493,
893 0x0000a493,0x000124db,0x000126dc,0x000136e4},
894 {0x00000000,0x00000000,0x00001249,0x0000a49b,
895 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
896 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
897 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
898 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
899 0x000124db,0x000136e4,0x0001b725,0x0001b724},
900 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
901 0x000126dc,0x000136e4,0x0001b725,0x0001b925},
902 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
903 0x000126dc,0x0001b724,0x0001b92d,0x0001c92d},
904 {0x00000000,0x00000000,0x00009252,0x000124db,
905 0x000126dc,0x0001b724,0x0001b92d,0x0001c92d},
906 {0x00000000,0x00000000,0x00009292,0x000124db,
907 0x000126dc,0x0001b925,0x0001c96e,0x0001c92d},
908 {0x00000000,0x00000000,0x00009492,0x000124db,
909 0x000136e4,0x0001b925,0x0001c96e,0x0001c92d},
910 {0x00000000,0x00000000,0x00009492,0x000124db,
911 0x000136e4,0x0001b925,0x00024b76,0x00024b77},
912 {0x00000000,0x00000000,0x00009492,0x000126db,
913 0x000136e4,0x0001b925,0x00024b76,0x00025bbf},
914 {0x00000000,0x00000000,0x0000a492,0x000126db,
915 0x000136e4,0x0001c92d,0x00024b76,0x00025bbf},
916 {0x00000000,0x00000000,0x00012492,0x000136db,
917 0x0001b724,0x00024b6d,0x0002ddb6,0x0002efff},
918 {0x00000000,0x00000000,0x00000000,0x00000000,
919 0x00000000,0x00000000,0x00000000,0x00000000}
920 },
921 { /* version 8, passes 1 */
922 {0x00000000,0x00000000,0x00001249,0x00001249,
923 0x00009252,0x00009493,0x00009493,0x00009493},
924 {0x00000000,0x00000000,0x00001249,0x00009292,
925 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
926 {0x00000000,0x00000000,0x0000924a,0x00009493,
927 0x0000a493,0x0000a49b,0x000124db,0x00009493},
928 {0x00000000,0x00000000,0x0000924a,0x00009493,
929 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
930 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
931 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
932 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
933 0x0000a493,0x000124db,0x000136e4,0x000124db},
934 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
935 0x0001249b,0x000126dc,0x000136e4,0x000124db},
936 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
937 0x000126dc,0x000126dc,0x000136e4,0x000126dc},
938 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
939 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
940 {0x00000000,0x00000000,0x0000924a,0x000124db,
941 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
942 {0x00000000,0x00000000,0x0000924a,0x000124db,
943 0x000126dc,0x000136e4,0x000136e4,0x000136e4},
944 {0x00000000,0x00000000,0x00009292,0x000124db,
945 0x000136e4,0x0001b724,0x0001b725,0x000136e4},
946 {0x00000000,0x00000000,0x00009492,0x000126db,
947 0x000136e4,0x0001b925,0x0001b725,0x0001b724},
948 {0x00000000,0x00000000,0x00009492,0x000126db,
949 0x000136e4,0x0001b925,0x0001b725,0x0001b724},
950 {0x00000000,0x00000000,0x0000a492,0x000136db,
951 0x0001b724,0x0002496d,0x0001b92d,0x0001b925},
952 {0x00000000,0x00000000,0x00000000,0x00000000,
953 0x00000000,0x00000000,0x00000000,0x00000000}
954 }
955 },
956 { /* version 9 */
957 { /* version 9, passes 0 */
958 {0x00000000,0x00000000,0x00000049,0x00000049,
959 0x00000049,0x00000049,0x00000049,0x00000049},
960 {0x00000000,0x00000000,0x00000249,0x00000049,
961 0x00000249,0x00000249,0x0000024a,0x00000049},
962 {0x00000000,0x00000000,0x00000249,0x00000249,
963 0x0000124a,0x00009252,0x00001252,0x0000024a},
964 {0x00000000,0x00000000,0x00001249,0x00001249,
965 0x00009252,0x00009292,0x00009493,0x00001252},
966 {0x00000000,0x00000000,0x00001249,0x0000924a,
967 0x00009292,0x00009493,0x00009493,0x00001252},
968 {0x00000000,0x00000000,0x00001249,0x00009292,
969 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
970 {0x00000000,0x00000000,0x00001249,0x00009493,
971 0x0000a493,0x000124db,0x000124db,0x00009493},
972 {0x00000000,0x00000000,0x0000924a,0x00009493,
973 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
974 {0x00000000,0x00000000,0x0000924a,0x00009493,
975 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
976 {0x00000000,0x00000000,0x0000924a,0x00009493,
977 0x0001249b,0x000126dc,0x000126dc,0x000124db},
978 {0x00000000,0x00000000,0x00009252,0x00009493,
979 0x000124db,0x000136e4,0x000136e4,0x000126dc},
980 {0x00000000,0x00000000,0x00009252,0x0000a49b,
981 0x000124db,0x000136e4,0x000136e4,0x000126dc},
982 {0x00000000,0x00000000,0x00009292,0x0000a49b,
983 0x000126dc,0x000136e4,0x000136e4,0x000136e4},
984 {0x00000000,0x00000000,0x00009492,0x0000a49b,
985 0x000126dc,0x0001b724,0x0001b725,0x0001b724},
986 {0x00000000,0x00000000,0x0000a492,0x000124db,
987 0x000136e4,0x0001b925,0x0001b92d,0x0001b925},
988 {0x00000000,0x00000000,0x00000000,0x00000000,
989 0x00000000,0x00000000,0x00000000,0x00000000}
990 },
991 { /* version 9, passes 1 */
992 {0x00000000,0x00000000,0x00000249,0x00000049,
993 0x00000009,0x00000009,0x00000009,0x00000009},
994 {0x00000000,0x00000000,0x00000249,0x00000249,
995 0x00000049,0x00000049,0x00000009,0x00000009},
996 {0x00000000,0x00000000,0x00001249,0x00001249,
997 0x0000124a,0x00000249,0x00000049,0x00000049},
998 {0x00000000,0x00000000,0x00001249,0x00001249,
999 0x0000124a,0x0000124a,0x00000049,0x00000049},
1000 {0x00000000,0x00000000,0x00001249,0x00001249,
1001 0x00009252,0x0000124a,0x0000024a,0x0000024a},
1002 {0x00000000,0x00000000,0x00001249,0x0000924a,
1003 0x00009252,0x0000124a,0x0000024a,0x0000024a},
1004 {0x00000000,0x00000000,0x00001249,0x00009292,
1005 0x00009492,0x00009252,0x00001252,0x00001252},
1006 {0x00000000,0x00000000,0x00001249,0x00009493,
1007 0x0000a493,0x00009292,0x00009292,0x00001252},
1008 {0x00000000,0x00000000,0x0000924a,0x00009493,
1009 0x0000a493,0x00009292,0x00009292,0x00009292},
1010 {0x00000000,0x00000000,0x0000924a,0x00009493,
1011 0x0000a493,0x00009493,0x00009493,0x00009292},
1012 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1013 0x0000a493,0x0000a49b,0x00009493,0x00009493},
1014 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1015 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
1016 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1017 0x0001249b,0x000124db,0x0000a49b,0x0000a49b},
1018 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1019 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1020 {0x00000000,0x00000000,0x00009252,0x000124db,
1021 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1022 {0x00000000,0x00000000,0x00000000,0x00000000,
1023 0x00000000,0x00000000,0x00000000,0x00000000}
1024 }
1025 },
1026 { /* version 10 */
1027 { /* version 10, passes 0 */
1028 {0x00000000,0x00000000,0x00000249,0x00000249,
1029 0x00000249,0x00000249,0x0000024a,0x0000024a},
1030 {0x00000000,0x00000000,0x00000249,0x00001249,
1031 0x00009252,0x00009292,0x00009292,0x0000024a},
1032 {0x00000000,0x00000000,0x00001249,0x00001249,
1033 0x00009252,0x00009292,0x00009292,0x00001252},
1034 {0x00000000,0x00000000,0x00001249,0x0000924a,
1035 0x00009492,0x00009493,0x0000a49b,0x00009292},
1036 {0x00000000,0x00000000,0x00001249,0x00009292,
1037 0x00009492,0x000124db,0x000124db,0x00009292},
1038 {0x00000000,0x00000000,0x00001249,0x00009493,
1039 0x0000a493,0x000124db,0x000124db,0x00009493},
1040 {0x00000000,0x00000000,0x00001249,0x00009493,
1041 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
1042 {0x00000000,0x00000000,0x0000924a,0x00009493,
1043 0x0000a493,0x000124db,0x000126dc,0x000124db},
1044 {0x00000000,0x00000000,0x0000924a,0x00009493,
1045 0x0001249b,0x000126dc,0x000126dc,0x000124db},
1046 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1047 0x000124db,0x000126dc,0x000136e4,0x000126dc},
1048 {0x00000000,0x00000000,0x00009252,0x0000a49b,
1049 0x000124db,0x000136e4,0x000136e4,0x000136e4},
1050 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1051 0x000126dc,0x000136e4,0x000136e4,0x000136e4},
1052 {0x00000000,0x00000000,0x00009492,0x0000a49b,
1053 0x000126dc,0x0001b724,0x0001b92d,0x0001b724},
1054 {0x00000000,0x00000000,0x00009492,0x000124db,
1055 0x000126dc,0x0001b925,0x0001b92d,0x0001b925},
1056 {0x00000000,0x00000000,0x0000a492,0x000126db,
1057 0x000136e4,0x0002496d,0x0001c96e,0x0001c92d},
1058 {0x00000000,0x00000000,0x00000000,0x00000000,
1059 0x00000000,0x00000000,0x00000000,0x00000000}
1060 },
1061 { /* version 10, passes 1 */
1062 {0x00000000,0x00000000,0x00000249,0x00000249,
1063 0x00000049,0x00000049,0x00000049,0x00000049},
1064 {0x00000000,0x00000000,0x00001249,0x00001249,
1065 0x0000124a,0x00000249,0x00000049,0x00000049},
1066 {0x00000000,0x00000000,0x00001249,0x00001249,
1067 0x0000124a,0x00009252,0x0000024a,0x00000049},
1068 {0x00000000,0x00000000,0x00001249,0x00001249,
1069 0x00009252,0x00009493,0x0000024a,0x0000024a},
1070 {0x00000000,0x00000000,0x00001249,0x00009252,
1071 0x00009492,0x00009493,0x00001252,0x0000024a},
1072 {0x00000000,0x00000000,0x00001249,0x00009292,
1073 0x00009492,0x00009493,0x00001252,0x00001252},
1074 {0x00000000,0x00000000,0x0000924a,0x00009493,
1075 0x00009492,0x00009493,0x00009292,0x00001252},
1076 {0x00000000,0x00000000,0x0000924a,0x00009493,
1077 0x0000a493,0x00009493,0x00009292,0x00009292},
1078 {0x00000000,0x00000000,0x0000924a,0x00009493,
1079 0x0000a493,0x0000a49b,0x00009493,0x00009292},
1080 {0x00000000,0x00000000,0x0000924a,0x00009493,
1081 0x0000a493,0x0000a49b,0x00009493,0x00009292},
1082 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1083 0x0000a493,0x000124db,0x0000a49b,0x00009493},
1084 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1085 0x0000a493,0x000124db,0x0000a49b,0x00009493},
1086 {0x00000000,0x00000000,0x0000924a,0x000124db,
1087 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1088 {0x00000000,0x00000000,0x0000924a,0x000124db,
1089 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1090 {0x00000000,0x00000000,0x00009252,0x000126db,
1091 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1092 {0x00000000,0x00000000,0x00000000,0x00000000,
1093 0x00000000,0x00000000,0x00000000,0x00000000}
1094 }
1095 },
1096 { /* version 11 */
1097 { /* version 11, passes 0 */
1098 {0x00000000,0x00000000,0x00000249,0x00000249,
1099 0x00000249,0x00000249,0x00001252,0x00001252},
1100 {0x00000000,0x00000000,0x00001249,0x00001249,
1101 0x00009252,0x00009292,0x00009292,0x00001252},
1102 {0x00000000,0x00000000,0x00001249,0x0000924a,
1103 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
1104 {0x00000000,0x00000000,0x00001249,0x00009493,
1105 0x0000a493,0x0000a49b,0x000124db,0x00009493},
1106 {0x00000000,0x00000000,0x00001249,0x00009493,
1107 0x0000a493,0x000124db,0x000126dc,0x00009493},
1108 {0x00000000,0x00000000,0x0000924a,0x00009493,
1109 0x0000a493,0x000126dc,0x000126dc,0x0000a49b},
1110 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1111 0x0001249b,0x000126dc,0x000136e4,0x000124db},
1112 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1113 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
1114 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1115 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
1116 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1117 0x000126dc,0x0001b724,0x0001b725,0x000136e4},
1118 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1119 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
1120 {0x00000000,0x00000000,0x00009492,0x0000a49b,
1121 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
1122 {0x00000000,0x00000000,0x00009492,0x000124db,
1123 0x000136e4,0x0001b925,0x0001c96e,0x0001b925},
1124 {0x00000000,0x00000000,0x00009492,0x000124db,
1125 0x0001b724,0x0001b925,0x0001c96e,0x0001c92d},
1126 {0x00000000,0x00000000,0x0000a492,0x000126db,
1127 0x0001c924,0x0002496d,0x00025bb6,0x00024b77},
1128 {0x00000000,0x00000000,0x00000000,0x00000000,
1129 0x00000000,0x00000000,0x00000000,0x00000000}
1130 },
1131 { /* version 11, passes 1 */
1132 {0x00000000,0x00000000,0x00001249,0x00000249,
1133 0x00000249,0x00000249,0x0000024a,0x0000024a},
1134 {0x00000000,0x00000000,0x00001249,0x00001249,
1135 0x0000124a,0x0000124a,0x0000024a,0x0000024a},
1136 {0x00000000,0x00000000,0x00001249,0x0000924a,
1137 0x00009252,0x00009252,0x0000024a,0x0000024a},
1138 {0x00000000,0x00000000,0x00001249,0x00009292,
1139 0x00009492,0x0000a49b,0x00001252,0x00001252},
1140 {0x00000000,0x00000000,0x0000924a,0x00009493,
1141 0x0000a493,0x0000a49b,0x00001252,0x00001252},
1142 {0x00000000,0x00000000,0x0000924a,0x00009493,
1143 0x0000a493,0x0000a49b,0x00009292,0x00001252},
1144 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1145 0x0000a493,0x0000a49b,0x00009292,0x00009292},
1146 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1147 0x0000a493,0x0000a49b,0x00009493,0x00009292},
1148 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1149 0x0001249b,0x000124db,0x00009493,0x00009292},
1150 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1151 0x0001249b,0x000124db,0x00009493,0x00009493},
1152 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1153 0x000124db,0x000124db,0x0000a49b,0x00009493},
1154 {0x00000000,0x00000000,0x0000924a,0x000124db,
1155 0x000126dc,0x000126dc,0x0000a49b,0x00009493},
1156 {0x00000000,0x00000000,0x0000924a,0x000124db,
1157 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1158 {0x00000000,0x00000000,0x00009292,0x000124db,
1159 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1160 {0x00000000,0x00000000,0x00009492,0x000126db,
1161 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1162 {0x00000000,0x00000000,0x00000000,0x00000000,
1163 0x00000000,0x00000000,0x00000000,0x00000000}
1164 }
1165 },
1166 { /* version 12 */
1167 { /* version 12, passes 0 */
1168 {0x00000000,0x00000000,0x00001249,0x00001249,
1169 0x00009252,0x00009292,0x00009493,0x00009493},
1170 {0x00000000,0x00000000,0x00001249,0x00009292,
1171 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
1172 {0x00000000,0x00000000,0x00001249,0x00009493,
1173 0x0000a493,0x000124db,0x000124db,0x0000a49b},
1174 {0x00000000,0x00000000,0x0000924a,0x00009493,
1175 0x0000a493,0x000126dc,0x000126dc,0x0000a49b},
1176 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1177 0x0001249b,0x000126dc,0x000136e4,0x000124db},
1178 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1179 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
1180 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1181 0x000126dc,0x0001b724,0x0001b725,0x000126dc},
1182 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1183 0x000136e4,0x0001b724,0x0001b92d,0x000136e4},
1184 {0x00000000,0x00000000,0x00009492,0x0000a49b,
1185 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
1186 {0x00000000,0x00000000,0x00009492,0x000124db,
1187 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
1188 {0x00000000,0x00000000,0x00009492,0x000124db,
1189 0x000136e4,0x0001b925,0x0001b92d,0x0001b925},
1190 {0x00000000,0x00000000,0x00009492,0x000124db,
1191 0x0001b724,0x0001b925,0x0001c96e,0x0001c92d},
1192 {0x00000000,0x00000000,0x0000a492,0x000124db,
1193 0x0001b724,0x0001c92d,0x0001c96e,0x0001c92d},
1194 {0x00000000,0x00000000,0x0000a492,0x000124db,
1195 0x0001b724,0x0001c92d,0x00024b76,0x0002496e},
1196 {0x00000000,0x00000000,0x00012492,0x000126db,
1197 0x0001c924,0x00024b6d,0x0002ddb6,0x00025bbf},
1198 {0x00000000,0x00000000,0x00000000,0x00000000,
1199 0x00000000,0x00000000,0x00000000,0x00000000}
1200 },
1201 { /* version 12, passes 1 */
1202 {0x00000000,0x00000000,0x00001249,0x00001249,
1203 0x0000124a,0x0000124a,0x00001252,0x00001252},
1204 {0x00000000,0x00000000,0x00001249,0x00009292,
1205 0x00009492,0x00009252,0x00001252,0x00001252},
1206 {0x00000000,0x00000000,0x0000924a,0x00009493,
1207 0x0000a493,0x00009292,0x00001252,0x00001252},
1208 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1209 0x0000a493,0x0000a49b,0x00009292,0x00009292},
1210 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1211 0x0000a493,0x0000a49b,0x00009292,0x00009292},
1212 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1213 0x0001249b,0x0000a49b,0x00009493,0x00009292},
1214 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1215 0x000124db,0x000124db,0x00009493,0x00009493},
1216 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1217 0x000124db,0x000124db,0x0000a49b,0x00009493},
1218 {0x00000000,0x00000000,0x0000924a,0x000124db,
1219 0x000126dc,0x000124db,0x0000a49b,0x00009493},
1220 {0x00000000,0x00000000,0x0000924a,0x000124db,
1221 0x000126dc,0x000126dc,0x0000a49b,0x0000a49b},
1222 {0x00000000,0x00000000,0x0000924a,0x000124db,
1223 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1224 {0x00000000,0x00000000,0x00009492,0x000126db,
1225 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1226 {0x00000000,0x00000000,0x00009492,0x000126db,
1227 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1228 {0x00000000,0x00000000,0x00009492,0x000126db,
1229 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1230 {0x00000000,0x00000000,0x0000a492,0x000136db,
1231 0x0001c924,0x0001b724,0x000136e4,0x000126dc},
1232 {0x00000000,0x00000000,0x00000000,0x00000000,
1233 0x00000000,0x00000000,0x00000000,0x00000000}
1234 }
1235 },
1236 { /* version 13 */
1237 { /* version 13, passes 0 */
1238 {0x00000000,0x00000000,0x00001249,0x00001249,
1239 0x00009252,0x00009292,0x00009493,0x00009493},
1240 {0x00000000,0x00000000,0x00001249,0x00009493,
1241 0x0000a493,0x000124db,0x000126dc,0x00009493},
1242 {0x00000000,0x00000000,0x00001249,0x0000a49b,
1243 0x0001249b,0x000126dc,0x000126dc,0x0000a49b},
1244 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1245 0x0001249b,0x000126dc,0x000136e4,0x0000a49b},
1246 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1247 0x000126dc,0x000136e4,0x0001b725,0x000124db},
1248 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1249 0x000136e4,0x0001b724,0x0001b725,0x000126dc},
1250 {0x00000000,0x00000000,0x00009292,0x000124db,
1251 0x000136e4,0x0001b724,0x0001b725,0x000126dc},
1252 {0x00000000,0x00000000,0x00009492,0x000124db,
1253 0x000136e4,0x0001b724,0x0001c96e,0x000136e4},
1254 {0x00000000,0x00000000,0x00009492,0x000124db,
1255 0x000136e4,0x0001c92d,0x0001c96e,0x0001b724},
1256 {0x00000000,0x00000000,0x0000a492,0x000124db,
1257 0x000136e4,0x0001c92d,0x0001c96e,0x0001b724},
1258 {0x00000000,0x00000000,0x0000a492,0x000124db,
1259 0x0001b724,0x0001c92d,0x0001c96e,0x0001b925},
1260 {0x00000000,0x00000000,0x0000a492,0x000126db,
1261 0x0001b724,0x0001c92d,0x00024b76,0x0001c92d},
1262 {0x00000000,0x00000000,0x0000a492,0x000126db,
1263 0x0001b924,0x0001c92d,0x00024b76,0x0001c92d},
1264 {0x00000000,0x00000000,0x0000a492,0x000126db,
1265 0x0001b924,0x0001c92d,0x00024b76,0x0002496e},
1266 {0x00000000,0x00000000,0x00012492,0x000136db,
1267 0x00024924,0x00024b6d,0x0002ddb6,0x00025bbf},
1268 {0x00000000,0x00000000,0x00000000,0x00000000,
1269 0x00000000,0x00000000,0x00000000,0x00000000}
1270 },
1271 { /* version 13, passes 1 */
1272 {0x00000000,0x00000000,0x00001249,0x00001249,
1273 0x0000124a,0x0000124a,0x00001252,0x00001252},
1274 {0x00000000,0x00000000,0x0000924a,0x00009493,
1275 0x00009492,0x00009292,0x00001252,0x00001252},
1276 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1277 0x0000a493,0x0000a49b,0x00001252,0x00001252},
1278 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1279 0x0000a493,0x0000a49b,0x00009292,0x00009292},
1280 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1281 0x0000a493,0x0000a49b,0x00009292,0x00009292},
1282 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1283 0x000126dc,0x0000a49b,0x00009493,0x00009292},
1284 {0x00000000,0x00000000,0x0000924a,0x000124db,
1285 0x000126dc,0x000124db,0x00009493,0x00009493},
1286 {0x00000000,0x00000000,0x0000924a,0x000124db,
1287 0x000136e4,0x000124db,0x0000a49b,0x00009493},
1288 {0x00000000,0x00000000,0x0000924a,0x000136db,
1289 0x0001b724,0x000124db,0x0000a49b,0x00009493},
1290 {0x00000000,0x00000000,0x0000924a,0x000136db,
1291 0x0001b724,0x000126dc,0x0000a49b,0x0000a49b},
1292 {0x00000000,0x00000000,0x00009292,0x000136db,
1293 0x0001b724,0x000126dc,0x000124db,0x0000a49b},
1294 {0x00000000,0x00000000,0x00009492,0x000136db,
1295 0x0001b724,0x000126dc,0x000124db,0x0000a49b},
1296 {0x00000000,0x00000000,0x0000a492,0x000136db,
1297 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1298 {0x00000000,0x00000000,0x0000a492,0x000136db,
1299 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1300 {0x00000000,0x00000000,0x00012492,0x0001b6db,
1301 0x0001c924,0x0001b724,0x000136e4,0x000126dc},
1302 {0x00000000,0x00000000,0x00000000,0x00000000,
1303 0x00000000,0x00000000,0x00000000,0x00000000}
1304 }
1305 },
1306 { /* version 14 */
1307 { /* version 14, passes 0 */
1308 {0x00000000,0x00000000,0x00001249,0x0000924a,
1309 0x00009292,0x00009493,0x00009493,0x00009493},
1310 {0x00000000,0x00000000,0x00001249,0x0000a49b,
1311 0x0000a493,0x000124db,0x000126dc,0x00009493},
1312 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1313 0x0001249b,0x000126dc,0x000136e4,0x0000a49b},
1314 {0x00000000,0x00000000,0x0000924a,0x000124db,
1315 0x000126dc,0x000136e4,0x0001b725,0x000124db},
1316 {0x00000000,0x00000000,0x00009292,0x000124db,
1317 0x000126dc,0x0001b724,0x0001b92d,0x000126dc},
1318 {0x00000000,0x00000000,0x00009492,0x000124db,
1319 0x000136e4,0x0001b724,0x0001b92d,0x000126dc},
1320 {0x00000000,0x00000000,0x00009492,0x000124db,
1321 0x000136e4,0x0001c92d,0x0001c96e,0x000136e4},
1322 {0x00000000,0x00000000,0x00009492,0x000124db,
1323 0x0001b724,0x0001c92d,0x0001c96e,0x0001b724},
1324 {0x00000000,0x00000000,0x0000a492,0x000124db,
1325 0x0001b724,0x0001c92d,0x00024b76,0x0001b925},
1326 {0x00000000,0x00000000,0x0000a492,0x000126db,
1327 0x0001b724,0x0001c92d,0x00024b76,0x0001c92d},
1328 {0x00000000,0x00000000,0x0000a492,0x000126db,
1329 0x0001b724,0x0001c92d,0x00024b76,0x0001c92d},
1330 {0x00000000,0x00000000,0x0000a492,0x000136db,
1331 0x0001b724,0x0001c92d,0x00024b76,0x0002496e},
1332 {0x00000000,0x00000000,0x0000a492,0x000136db,
1333 0x0001b924,0x0002496d,0x00024b76,0x00024b77},
1334 {0x00000000,0x00000000,0x0000a492,0x000136db,
1335 0x0001b924,0x00024b6d,0x0002ddb6,0x00025bbf},
1336 {0x00000000,0x00000000,0x00012492,0x0001b6db,
1337 0x00024924,0x0002db6d,0x00036db6,0x0002efff},
1338 {0x00000000,0x00000000,0x00000000,0x00000000,
1339 0x00000000,0x00000000,0x00000000,0x00000000}
1340 },
1341 { /* version 14, passes 1 */
1342 {0x00000000,0x00000000,0x00001249,0x00001249,
1343 0x0000124a,0x0000124a,0x00001252,0x00001252},
1344 {0x00000000,0x00000000,0x0000924a,0x00009493,
1345 0x0000a493,0x00009292,0x00001252,0x00001252},
1346 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1347 0x0000a493,0x0000a49b,0x00001252,0x00001252},
1348 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1349 0x0001249b,0x000136e4,0x00009292,0x00009292},
1350 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1351 0x0001249b,0x000136e4,0x00009292,0x00009292},
1352 {0x00000000,0x00000000,0x0000924a,0x000124db,
1353 0x000136e4,0x000136e4,0x00009493,0x00009292},
1354 {0x00000000,0x00000000,0x00009492,0x000136db,
1355 0x0001b724,0x000136e4,0x00009493,0x00009493},
1356 {0x00000000,0x00000000,0x00009492,0x000136db,
1357 0x0001b724,0x000136e4,0x0000a49b,0x00009493},
1358 {0x00000000,0x00000000,0x00009492,0x000136db,
1359 0x0001b724,0x000136e4,0x0000a49b,0x00009493},
1360 {0x00000000,0x00000000,0x00009492,0x000136db,
1361 0x0001b724,0x000136e4,0x0000a49b,0x0000a49b},
1362 {0x00000000,0x00000000,0x0000a492,0x000136db,
1363 0x0001b724,0x000136e4,0x000124db,0x0000a49b},
1364 {0x00000000,0x00000000,0x0000a492,0x000136db,
1365 0x0001b724,0x000136e4,0x000124db,0x0000a49b},
1366 {0x00000000,0x00000000,0x0000a492,0x000136db,
1367 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1368 {0x00000000,0x00000000,0x0000a492,0x000136db,
1369 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1370 {0x00000000,0x00000000,0x00012492,0x0001b6db,
1371 0x0001c924,0x0001b724,0x000136e4,0x000126dc},
1372 {0x00000000,0x00000000,0x00000000,0x00000000,
1373 0x00000000,0x00000000,0x00000000,0x00000000}
1374 }
1375 },
1376 { /* version 15 */
1377 { /* version 15, passes 0 */
1378 {0x00000000,0x00000000,0x00001249,0x00009493,
1379 0x0000a493,0x0000a49b,0x000124db,0x000124db},
1380 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1381 0x0001249b,0x000126dc,0x000136e4,0x000124db},
1382 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1383 0x000126dc,0x0001b724,0x0001b725,0x000126dc},
1384 {0x00000000,0x00000000,0x0000924a,0x000124db,
1385 0x000136e4,0x0001b724,0x0001b92d,0x000126dc},
1386 {0x00000000,0x00000000,0x00009492,0x000124db,
1387 0x000136e4,0x0001b925,0x0001c96e,0x000136e4},
1388 {0x00000000,0x00000000,0x00009492,0x000124db,
1389 0x0001b724,0x0001c92d,0x0001c96e,0x0001b724},
1390 {0x00000000,0x00000000,0x0000a492,0x000124db,
1391 0x0001b724,0x0001c92d,0x0001c96e,0x0001b724},
1392 {0x00000000,0x00000000,0x0000a492,0x000126db,
1393 0x0001b724,0x0001c92d,0x0001c96e,0x0001b925},
1394 {0x00000000,0x00000000,0x0000a492,0x000126db,
1395 0x0001b924,0x0001c92d,0x00024b76,0x0001c92d},
1396 {0x00000000,0x00000000,0x0000a492,0x000136db,
1397 0x0001b924,0x0001c92d,0x00024b76,0x0001c92d},
1398 {0x00000000,0x00000000,0x0000a492,0x000136db,
1399 0x0001b924,0x0002496d,0x00024b76,0x0002496e},
1400 {0x00000000,0x00000000,0x0000a492,0x000136db,
1401 0x0001c924,0x0002496d,0x00025bb6,0x00024b77},
1402 {0x00000000,0x00000000,0x0000a492,0x000136db,
1403 0x0001c924,0x00024b6d,0x00025bb6,0x00024b77},
1404 {0x00000000,0x00000000,0x00012492,0x000136db,
1405 0x0001c924,0x00024b6d,0x0002ddb6,0x00025bbf},
1406 {0x00000000,0x00000000,0x00012492,0x0001b6db,
1407 0x00024924,0x0002db6d,0x00036db6,0x0002efff},
1408 {0x00000000,0x00000000,0x00000000,0x00000000,
1409 0x00000000,0x00000000,0x00000000,0x00000000}
1410 },
1411 { /* version 15, passes 1 */
1412 {0x00000000,0x00000000,0x0000924a,0x0000924a,
1413 0x00009292,0x00009292,0x00009292,0x00009292},
1414 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1415 0x0000a493,0x000124db,0x00009292,0x00009292},
1416 {0x00000000,0x00000000,0x0000924a,0x000124db,
1417 0x000124db,0x0001b724,0x00009493,0x00009493},
1418 {0x00000000,0x00000000,0x0000924a,0x000124db,
1419 0x000126dc,0x0001b724,0x00009493,0x00009493},
1420 {0x00000000,0x00000000,0x0000924a,0x000124db,
1421 0x000136e4,0x0001b724,0x0000a49b,0x0000a49b},
1422 {0x00000000,0x00000000,0x00009292,0x000136db,
1423 0x0001b724,0x0001b724,0x0000a49b,0x0000a49b},
1424 {0x00000000,0x00000000,0x00009492,0x000136db,
1425 0x0001c924,0x0001b724,0x000124db,0x000124db},
1426 {0x00000000,0x00000000,0x00009492,0x000136db,
1427 0x0001c924,0x0001b724,0x000124db,0x000124db},
1428 {0x00000000,0x00000000,0x0000a492,0x000136db,
1429 0x0001c924,0x0001b724,0x000126dc,0x000126dc},
1430 {0x00000000,0x00000000,0x0000a492,0x000136db,
1431 0x0001c924,0x0001b925,0x000126dc,0x000126dc},
1432 {0x00000000,0x00000000,0x0000a492,0x000136db,
1433 0x0001c924,0x0001b925,0x000136e4,0x000136e4},
1434 {0x00000000,0x00000000,0x0000a492,0x000136db,
1435 0x0001c924,0x0001b925,0x000136e4,0x000136e4},
1436 {0x00000000,0x00000000,0x0000a492,0x000136db,
1437 0x0001c924,0x0001b925,0x0001b725,0x0001b724},
1438 {0x00000000,0x00000000,0x00012492,0x000136db,
1439 0x0001c924,0x0001b925,0x0001b725,0x0001b724},
1440 {0x00000000,0x00000000,0x00012492,0x0001b6db,
1441 0x00024924,0x0002496d,0x0001b92d,0x0001b925},
1442 {0x00000000,0x00000000,0x00000000,0x00000000,
1443 0x00000000,0x00000000,0x00000000,0x00000000}
1444 }
1445 }
1446};
diff --git a/drivers/usb/media/pwc/pwc-uncompress.c b/drivers/usb/media/pwc/pwc-uncompress.c
index c062e43b3ac5..c596083f06ba 100644
--- a/drivers/usb/media/pwc/pwc-uncompress.c
+++ b/drivers/usb/media/pwc/pwc-uncompress.c
@@ -122,6 +122,7 @@ int pwc_decompress(struct pwc_device *pdev)
122 122
123 switch (pdev->type) 123 switch (pdev->type)
124 { 124 {
125#if 0
125 case 675: 126 case 675:
126 case 680: 127 case 680:
127 case 690: 128 case 690:
@@ -137,6 +138,7 @@ int pwc_decompress(struct pwc_device *pdev)
137 case 645: 138 case 645:
138 case 646: 139 case 646:
139 /* TODO & FIXME */ 140 /* TODO & FIXME */
141#endif
140 return -ENXIO; /* No such device or address: missing decompressor */ 142 return -ENXIO; /* No such device or address: missing decompressor */
141 break; 143 break;
142 } 144 }
diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
index db64c908d4a7..b104430e2c6a 100644
--- a/drivers/usb/net/Kconfig
+++ b/drivers/usb/net/Kconfig
@@ -219,17 +219,21 @@ config USB_EPSON2888
219 by some sample firmware from Epson. 219 by some sample firmware from Epson.
220 220
221config USB_ZAURUS 221config USB_ZAURUS
222 boolean "Sharp Zaurus (stock ROMs)" 222 boolean "Sharp Zaurus (stock ROMs) and compatible"
223 depends on USB_USBNET 223 depends on USB_USBNET
224 select CRC32 224 select CRC32
225 default y 225 default y
226 help 226 help
227 Choose this option to support the usb networking links used by 227 Choose this option to support the usb networking links used by
228 Zaurus models like the SL-5000D, SL-5500, SL-5600, A-300, B-500. 228 Zaurus models like the SL-5000D, SL-5500, SL-5600, A-300, B-500.
229 229 This also supports some related device firmware, as used in some
230 If you install an alternate ROM image, you may no longer need 230 PDAs from Olympus and some cell phones from Motorola.
231 to support this protocol. Only the "eth-fd" driver really needs 231
232 this non-conformant variant of CDC Ethernet protocol. 232 If you install an alternate ROM image, such as the Linux 2.6 based
233 versions of OpenZaurus, you should no longer need to support this
234 protocol. Only the "eth-fd" or "net_fd" drivers in these devices
235 really need this non-conformant variant of CDC Ethernet (or in
236 some cases CDC MDLM) protocol, not "g_ether".
233 237
234config USB_CDCETHER 238config USB_CDCETHER
235 boolean "CDC Ethernet support (smart devices such as cable modems)" 239 boolean "CDC Ethernet support (smart devices such as cable modems)"
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index f6bc6b3b333c..85476e76b244 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -1517,6 +1517,26 @@ static void cdc_unbind (struct usbnet *dev, struct usb_interface *intf)
1517 } 1517 }
1518} 1518}
1519 1519
1520#endif /* NEED_GENERIC_CDC */
1521
1522
1523#ifdef CONFIG_USB_CDCETHER
1524#define HAVE_HARDWARE
1525
1526/*-------------------------------------------------------------------------
1527 *
1528 * Communications Device Class, Ethernet Control model
1529 *
1530 * Takes two interfaces. The DATA interface is inactive till an altsetting
1531 * is selected. Configuration data includes class descriptors.
1532 *
1533 * This should interop with whatever the 2.4 "CDCEther.c" driver
1534 * (by Brad Hards) talked with.
1535 *
1536 *-------------------------------------------------------------------------*/
1537
1538#include <linux/ctype.h>
1539
1520 1540
1521static void dumpspeed (struct usbnet *dev, __le32 *speeds) 1541static void dumpspeed (struct usbnet *dev, __le32 *speeds)
1522{ 1542{
@@ -1567,26 +1587,6 @@ static void cdc_status (struct usbnet *dev, struct urb *urb)
1567 } 1587 }
1568} 1588}
1569 1589
1570#endif /* NEED_GENERIC_CDC */
1571
1572
1573#ifdef CONFIG_USB_CDCETHER
1574#define HAVE_HARDWARE
1575
1576/*-------------------------------------------------------------------------
1577 *
1578 * Communications Device Class, Ethernet Control model
1579 *
1580 * Takes two interfaces. The DATA interface is inactive till an altsetting
1581 * is selected. Configuration data includes class descriptors.
1582 *
1583 * This should interop with whatever the 2.4 "CDCEther.c" driver
1584 * (by Brad Hards) talked with.
1585 *
1586 *-------------------------------------------------------------------------*/
1587
1588#include <linux/ctype.h>
1589
1590static u8 nibble (unsigned char c) 1590static u8 nibble (unsigned char c)
1591{ 1591{
1592 if (likely (isdigit (c))) 1592 if (likely (isdigit (c)))
@@ -2765,7 +2765,7 @@ static int blan_mdlm_bind (struct usbnet *dev, struct usb_interface *intf)
2765 } 2765 }
2766 /* expect bcdVersion 1.0, ignore */ 2766 /* expect bcdVersion 1.0, ignore */
2767 if (memcmp(&desc->bGUID, blan_guid, 16) 2767 if (memcmp(&desc->bGUID, blan_guid, 16)
2768 || memcmp(&desc->bGUID, blan_guid, 16) ) { 2768 && memcmp(&desc->bGUID, blan_guid, 16) ) {
2769 /* hey, this one might _really_ be MDLM! */ 2769 /* hey, this one might _really_ be MDLM! */
2770 dev_dbg (&intf->dev, "MDLM guid\n"); 2770 dev_dbg (&intf->dev, "MDLM guid\n");
2771 goto bad_desc; 2771 goto bad_desc;
@@ -2797,11 +2797,13 @@ static int blan_mdlm_bind (struct usbnet *dev, struct usb_interface *intf)
2797 * - bPad (ignored, for PADAFTER -- BLAN-only) 2797 * - bPad (ignored, for PADAFTER -- BLAN-only)
2798 * bits are: 2798 * bits are:
2799 * - 0x01 -- Zaurus framing (add CRC) 2799 * - 0x01 -- Zaurus framing (add CRC)
2800 * - 0x02 -- PADBEFORE 2800 * - 0x02 -- PADBEFORE (CRC includes some padding)
2801 * - 0x04 -- PADAFTER 2801 * - 0x04 -- PADAFTER (some padding after CRC)
2802 * - 0x08 -- "fermat" packet mangling (for hw bugs) 2802 * - 0x08 -- "fermat" packet mangling (for hw bugs)
2803 * the PADBEFORE appears not to matter; we interop
2804 * with devices that use it and those that don't.
2803 */ 2805 */
2804 if (detail->bDetailData[1] != 0x01) { 2806 if ((detail->bDetailData[1] & ~02) != 0x01) {
2805 /* bmDataCapabilites == 0 would be fine too, 2807 /* bmDataCapabilites == 0 would be fine too,
2806 * but framing is minidriver-coupled for now. 2808 * but framing is minidriver-coupled for now.
2807 */ 2809 */
@@ -4071,9 +4073,6 @@ static const struct usb_device_id products [] = {
4071 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader 4073 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader
4072 .driver_info = (unsigned long) &blob_info, 4074 .driver_info = (unsigned long) &blob_info,
4073}, { 4075}, {
4074 USB_DEVICE (0x22b8, 0x600c), // USBNET Motorola E680
4075 .driver_info = (unsigned long) &linuxdev_info,
4076}, {
4077 // Linux Ethernet/RNDIS gadget on pxa210/25x/26x 4076 // Linux Ethernet/RNDIS gadget on pxa210/25x/26x
4078 // e.g. Gumstix, current OpenZaurus, ... 4077 // e.g. Gumstix, current OpenZaurus, ...
4079 USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203), 4078 USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index f34a9bb6a219..012e63e05806 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -89,6 +89,7 @@ static int interval;
89 89
90static struct usb_device_id id_table_earthmate [] = { 90static struct usb_device_id id_table_earthmate [] = {
91 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) }, 91 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
92 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
92 { } /* Terminating entry */ 93 { } /* Terminating entry */
93}; 94};
94 95
@@ -99,6 +100,7 @@ static struct usb_device_id id_table_cyphidcomrs232 [] = {
99 100
100static struct usb_device_id id_table_combined [] = { 101static struct usb_device_id id_table_combined [] = {
101 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) }, 102 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
103 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
102 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) }, 104 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
103 { } /* Terminating entry */ 105 { } /* Terminating entry */
104}; 106};
diff --git a/drivers/usb/serial/cypress_m8.h b/drivers/usb/serial/cypress_m8.h
index 1012ee6b19ce..1fa119efe41a 100644
--- a/drivers/usb/serial/cypress_m8.h
+++ b/drivers/usb/serial/cypress_m8.h
@@ -13,6 +13,7 @@
13/* DeLorme Earthmate USB - a GPS device */ 13/* DeLorme Earthmate USB - a GPS device */
14#define VENDOR_ID_DELORME 0x1163 14#define VENDOR_ID_DELORME 0x1163
15#define PRODUCT_ID_EARTHMATEUSB 0x0100 15#define PRODUCT_ID_EARTHMATEUSB 0x0100
16#define PRODUCT_ID_EARTHMATEUSB_LT20 0x0200
16 17
17/* Cypress HID->COM RS232 Adapter */ 18/* Cypress HID->COM RS232 Adapter */
18#define VENDOR_ID_CYPRESS 0x04b4 19#define VENDOR_ID_CYPRESS 0x04b4
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index ce9423bb2de3..c374be51b041 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -251,7 +251,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr * exec,
251 } 251 }
252 252
253 /* Populate argv and envp */ 253 /* Populate argv and envp */
254 p = current->mm->arg_start; 254 p = current->mm->arg_end = current->mm->arg_start;
255 while (argc-- > 0) { 255 while (argc-- > 0) {
256 size_t len; 256 size_t len;
257 __put_user((elf_addr_t)p, argv++); 257 __put_user((elf_addr_t)p, argv++);
@@ -1301,7 +1301,7 @@ static void fill_prstatus(struct elf_prstatus *prstatus,
1301static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p, 1301static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
1302 struct mm_struct *mm) 1302 struct mm_struct *mm)
1303{ 1303{
1304 int i, len; 1304 unsigned int i, len;
1305 1305
1306 /* first copy the parameters from user space */ 1306 /* first copy the parameters from user space */
1307 memset(psinfo, 0, sizeof(struct elf_prpsinfo)); 1307 memset(psinfo, 0, sizeof(struct elf_prpsinfo));
diff --git a/fs/buffer.c b/fs/buffer.c
index 6f88dcc6d002..7e9e409feaa7 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2094,9 +2094,12 @@ int block_read_full_page(struct page *page, get_block_t *get_block)
2094 continue; 2094 continue;
2095 2095
2096 if (!buffer_mapped(bh)) { 2096 if (!buffer_mapped(bh)) {
2097 int err = 0;
2098
2097 fully_mapped = 0; 2099 fully_mapped = 0;
2098 if (iblock < lblock) { 2100 if (iblock < lblock) {
2099 if (get_block(inode, iblock, bh, 0)) 2101 err = get_block(inode, iblock, bh, 0);
2102 if (err)
2100 SetPageError(page); 2103 SetPageError(page);
2101 } 2104 }
2102 if (!buffer_mapped(bh)) { 2105 if (!buffer_mapped(bh)) {
@@ -2104,7 +2107,8 @@ int block_read_full_page(struct page *page, get_block_t *get_block)
2104 memset(kaddr + i * blocksize, 0, blocksize); 2107 memset(kaddr + i * blocksize, 0, blocksize);
2105 flush_dcache_page(page); 2108 flush_dcache_page(page);
2106 kunmap_atomic(kaddr, KM_USER0); 2109 kunmap_atomic(kaddr, KM_USER0);
2107 set_buffer_uptodate(bh); 2110 if (!err)
2111 set_buffer_uptodate(bh);
2108 continue; 2112 continue;
2109 } 2113 }
2110 /* 2114 /*
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 545b440a2d2f..981ccb233ef5 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -225,8 +225,16 @@ void __ext3_std_error (struct super_block * sb, const char * function,
225 int errno) 225 int errno)
226{ 226{
227 char nbuf[16]; 227 char nbuf[16];
228 const char *errstr = ext3_decode_error(sb, errno, nbuf); 228 const char *errstr;
229
230 /* Special case: if the error is EROFS, and we're not already
231 * inside a transaction, then there's really no point in logging
232 * an error. */
233 if (errno == -EROFS && journal_current_handle() == NULL &&
234 (sb->s_flags & MS_RDONLY))
235 return;
229 236
237 errstr = ext3_decode_error(sb, errno, nbuf);
230 printk (KERN_CRIT "EXT3-fs error (device %s) in %s: %s\n", 238 printk (KERN_CRIT "EXT3-fs error (device %s) in %s: %s\n",
231 sb->s_id, function, errstr); 239 sb->s_id, function, errstr);
232 240
diff --git a/fs/namei.c b/fs/namei.c
index defe6781e003..dd78f01b6de8 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1580,6 +1580,7 @@ enoent:
1580fail: 1580fail:
1581 return dentry; 1581 return dentry;
1582} 1582}
1583EXPORT_SYMBOL_GPL(lookup_create);
1583 1584
1584int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) 1585int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
1585{ 1586{
diff --git a/fs/proc/mmu.c b/fs/proc/mmu.c
index a7041038ad56..25d2d9c6e329 100644
--- a/fs/proc/mmu.c
+++ b/fs/proc/mmu.c
@@ -50,13 +50,23 @@ void get_vmalloc_info(struct vmalloc_info *vmi)
50 read_lock(&vmlist_lock); 50 read_lock(&vmlist_lock);
51 51
52 for (vma = vmlist; vma; vma = vma->next) { 52 for (vma = vmlist; vma; vma = vma->next) {
53 unsigned long addr = (unsigned long) vma->addr;
54
55 /*
56 * Some archs keep another range for modules in vmlist
57 */
58 if (addr < VMALLOC_START)
59 continue;
60 if (addr >= VMALLOC_END)
61 break;
62
53 vmi->used += vma->size; 63 vmi->used += vma->size;
54 64
55 free_area_size = (unsigned long) vma->addr - prev_end; 65 free_area_size = addr - prev_end;
56 if (vmi->largest_chunk < free_area_size) 66 if (vmi->largest_chunk < free_area_size)
57 vmi->largest_chunk = free_area_size; 67 vmi->largest_chunk = free_area_size;
58 68
59 prev_end = vma->size + (unsigned long) vma->addr; 69 prev_end = vma->size + addr;
60 } 70 }
61 71
62 if (VMALLOC_END - prev_end > vmi->largest_chunk) 72 if (VMALLOC_END - prev_end > vmi->largest_chunk)
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index da23ba75f3d5..c47f8fd31a2d 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -230,7 +230,6 @@ const struct reiserfs_key MAX_KEY = {
230 __constant_cpu_to_le32(0xffffffff)},} 230 __constant_cpu_to_le32(0xffffffff)},}
231}; 231};
232 232
233const struct in_core_key MAX_IN_CORE_KEY = {~0U, ~0U, ~0ULL>>4, 15};
234 233
235/* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom 234/* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom
236 of the path, and going upwards. We must check the path's validity at each step. If the key is not in 235 of the path, and going upwards. We must check the path's validity at each step. If the key is not in
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 31e75125f48b..b35b87744983 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -164,7 +164,9 @@ static int finish_unfinished (struct super_block * s)
164 164
165 /* compose key to look for "save" links */ 165 /* compose key to look for "save" links */
166 max_cpu_key.version = KEY_FORMAT_3_5; 166 max_cpu_key.version = KEY_FORMAT_3_5;
167 max_cpu_key.on_disk_key = MAX_IN_CORE_KEY; 167 max_cpu_key.on_disk_key.k_dir_id = ~0U;
168 max_cpu_key.on_disk_key.k_objectid = ~0U;
169 set_cpu_key_k_offset (&max_cpu_key, ~0U);
168 max_cpu_key.key_length = 3; 170 max_cpu_key.key_length = 3;
169 171
170#ifdef CONFIG_QUOTA 172#ifdef CONFIG_QUOTA
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 9278e9aba9ba..93ce257cd149 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -886,7 +886,6 @@ xfs_page_state_convert(
886 SetPageUptodate(page); 886 SetPageUptodate(page);
887 887
888 if (startio) { 888 if (startio) {
889 WARN_ON(page_dirty);
890 xfs_submit_page(page, wbc, bh_arr, cnt, 0, !page_dirty); 889 xfs_submit_page(page, wbc, bh_arr, cnt, 0, !page_dirty);
891 } 890 }
892 891
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index d0d412afd261..24fa3b101b93 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -565,7 +565,7 @@ struct file_operations linvfs_file_operations = {
565 .sendfile = linvfs_sendfile, 565 .sendfile = linvfs_sendfile,
566 .unlocked_ioctl = linvfs_ioctl, 566 .unlocked_ioctl = linvfs_ioctl,
567#ifdef CONFIG_COMPAT 567#ifdef CONFIG_COMPAT
568 .compat_ioctl = xfs_compat_ioctl, 568 .compat_ioctl = linvfs_compat_ioctl,
569#endif 569#endif
570 .mmap = linvfs_file_mmap, 570 .mmap = linvfs_file_mmap,
571 .open = linvfs_open, 571 .open = linvfs_open,
@@ -587,7 +587,7 @@ struct file_operations linvfs_invis_file_operations = {
587 .sendfile = linvfs_sendfile, 587 .sendfile = linvfs_sendfile,
588 .unlocked_ioctl = linvfs_ioctl_invis, 588 .unlocked_ioctl = linvfs_ioctl_invis,
589#ifdef CONFIG_COMPAT 589#ifdef CONFIG_COMPAT
590 .compat_ioctl = xfs_compat_invis_ioctl, 590 .compat_ioctl = linvfs_compat_invis_ioctl,
591#endif 591#endif
592 .mmap = linvfs_file_mmap, 592 .mmap = linvfs_file_mmap,
593 .open = linvfs_open, 593 .open = linvfs_open,
@@ -600,6 +600,9 @@ struct file_operations linvfs_dir_operations = {
600 .read = generic_read_dir, 600 .read = generic_read_dir,
601 .readdir = linvfs_readdir, 601 .readdir = linvfs_readdir,
602 .unlocked_ioctl = linvfs_ioctl, 602 .unlocked_ioctl = linvfs_ioctl,
603#ifdef CONFIG_COMPAT
604 .compat_ioctl = linvfs_compat_ioctl,
605#endif
603 .fsync = linvfs_fsync, 606 .fsync = linvfs_fsync,
604}; 607};
605 608
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c
index 7a12c83184f5..0f8f1384eb36 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2004-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
@@ -58,8 +58,9 @@ typedef struct xfs_fsop_bulkreq32 {
58 __s32 ocount; /* output count pointer */ 58 __s32 ocount; /* output count pointer */
59} xfs_fsop_bulkreq32_t; 59} xfs_fsop_bulkreq32_t;
60 60
61static unsigned long 61STATIC unsigned long
62xfs_ioctl32_bulkstat(unsigned long arg) 62xfs_ioctl32_bulkstat(
63 unsigned long arg)
63{ 64{
64 xfs_fsop_bulkreq32_t __user *p32 = (void __user *)arg; 65 xfs_fsop_bulkreq32_t __user *p32 = (void __user *)arg;
65 xfs_fsop_bulkreq_t __user *p = compat_alloc_user_space(sizeof(*p)); 66 xfs_fsop_bulkreq_t __user *p = compat_alloc_user_space(sizeof(*p));
@@ -78,11 +79,11 @@ xfs_ioctl32_bulkstat(unsigned long arg)
78} 79}
79#endif 80#endif
80 81
81static long 82STATIC long
82__xfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg) 83__linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
83{ 84{
84 int error; 85 int error;
85 struct inode *inode = f->f_dentry->d_inode; 86 struct inode *inode = f->f_dentry->d_inode;
86 vnode_t *vp = LINVFS_GET_VP(inode); 87 vnode_t *vp = LINVFS_GET_VP(inode);
87 88
88 switch (cmd) { 89 switch (cmd) {
@@ -152,12 +153,20 @@ __xfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
152 return error; 153 return error;
153} 154}
154 155
155long xfs_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg) 156long
157linvfs_compat_ioctl(
158 struct file *f,
159 unsigned cmd,
160 unsigned long arg)
156{ 161{
157 return __xfs_compat_ioctl(0, f, cmd, arg); 162 return __linvfs_compat_ioctl(0, f, cmd, arg);
158} 163}
159 164
160long xfs_compat_invis_ioctl(struct file *f, unsigned cmd, unsigned long arg) 165long
166linvfs_compat_invis_ioctl(
167 struct file *f,
168 unsigned cmd,
169 unsigned long arg)
161{ 170{
162 return __xfs_compat_ioctl(IO_INVIS, f, cmd, arg); 171 return __linvfs_compat_ioctl(IO_INVIS, f, cmd, arg);
163} 172}
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.h b/fs/xfs/linux-2.6/xfs_ioctl32.h
index 779f69a48116..c874793a1dc9 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.h
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2004-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
@@ -30,5 +30,5 @@
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ 30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 31 */
32 32
33long xfs_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg); 33long linvfs_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg);
34long xfs_compat_invis_ioctl(struct file *f, unsigned cmd, unsigned long arg); 34long linvfs_compat_invis_ioctl(struct file *f, unsigned cmd, unsigned long arg);
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 53dc658cafa6..455e2b2fb964 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.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
@@ -66,7 +66,6 @@
66#include "xfs_buf_item.h" 66#include "xfs_buf_item.h"
67#include "xfs_utils.h" 67#include "xfs_utils.h"
68#include "xfs_version.h" 68#include "xfs_version.h"
69#include "xfs_ioctl32.h"
70 69
71#include <linux/namei.h> 70#include <linux/namei.h>
72#include <linux/init.h> 71#include <linux/init.h>
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 991f8a61f7c4..469e1a7939d4 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -278,7 +278,9 @@ phase2:
278 switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE|BMAPI_UNWRITTEN)) { 278 switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE|BMAPI_UNWRITTEN)) {
279 case BMAPI_WRITE: 279 case BMAPI_WRITE:
280 /* If we found an extent, return it */ 280 /* If we found an extent, return it */
281 if (nimaps && (imap.br_startblock != HOLESTARTBLOCK)) { 281 if (nimaps &&
282 (imap.br_startblock != HOLESTARTBLOCK) &&
283 (imap.br_startblock != DELAYSTARTBLOCK)) {
282 xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, io, 284 xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, io,
283 offset, count, iomapp, &imap, flags); 285 offset, count, iomapp, &imap, flags);
284 break; 286 break;
diff --git a/include/asm-arm/arch-imx/imx-regs.h b/include/asm-arm/arch-imx/imx-regs.h
index f32c203952cf..93b840e8fa60 100644
--- a/include/asm-arm/arch-imx/imx-regs.h
+++ b/include/asm-arm/arch-imx/imx-regs.h
@@ -228,6 +228,30 @@
228#define PD31_BIN_SPI2_TXD ( GPIO_PORTD | GPIO_BIN | 31 ) 228#define PD31_BIN_SPI2_TXD ( GPIO_PORTD | GPIO_BIN | 31 )
229 229
230/* 230/*
231 * PWM controller
232 */
233#define PWMC __REG(IMX_PWM_BASE + 0x00) /* PWM Control Register */
234#define PWMS __REG(IMX_PWM_BASE + 0x04) /* PWM Sample Register */
235#define PWMP __REG(IMX_PWM_BASE + 0x08) /* PWM Period Register */
236#define PWMCNT __REG(IMX_PWM_BASE + 0x0C) /* PWM Counter Register */
237
238#define PWMC_HCTR (0x01<<18) /* Halfword FIFO Data Swapping */
239#define PWMC_BCTR (0x01<<17) /* Byte FIFO Data Swapping */
240#define PWMC_SWR (0x01<<16) /* Software Reset */
241#define PWMC_CLKSRC (0x01<<15) /* Clock Source */
242#define PWMC_PRESCALER(x) (((x-1) & 0x7F) << 8) /* PRESCALER */
243#define PWMC_IRQ (0x01<< 7) /* Interrupt Request */
244#define PWMC_IRQEN (0x01<< 6) /* Interrupt Request Enable */
245#define PWMC_FIFOAV (0x01<< 5) /* FIFO Available */
246#define PWMC_EN (0x01<< 4) /* Enables/Disables the PWM */
247#define PWMC_REPEAT(x) (((x) & 0x03) << 2) /* Sample Repeats */
248#define PWMC_CLKSEL(x) (((x) & 0x03) << 0) /* Clock Selection */
249
250#define PWMS_SAMPLE(x) ((x) & 0xFFFF) /* Contains a two-sample word */
251#define PWMP_PERIOD(x) ((x) & 0xFFFF) /* Represents the PWM's period */
252#define PWMC_COUNTER(x) ((x) & 0xFFFF) /* Represents the current count value */
253
254/*
231 * DMA Controller 255 * DMA Controller
232 */ 256 */
233#define DCR __REG(IMX_DMAC_BASE +0x00) /* DMA Control Register */ 257#define DCR __REG(IMX_DMAC_BASE +0x00) /* DMA Control Register */
diff --git a/include/asm-arm/arch-s3c2410/regs-nand.h b/include/asm-arm/arch-s3c2410/regs-nand.h
index c443ac834698..7cff235e667a 100644
--- a/include/asm-arm/arch-s3c2410/regs-nand.h
+++ b/include/asm-arm/arch-s3c2410/regs-nand.h
@@ -1,16 +1,17 @@
1/* linux/include/asm-arm/arch-s3c2410/regs-nand.h 1/* linux/include/asm-arm/arch-s3c2410/regs-nand.h
2 * 2 *
3 * Copyright (c) 2004 Simtec Electronics <linux@simtec.co.uk> 3 * Copyright (c) 2004,2005 Simtec Electronics <linux@simtec.co.uk>
4 * http://www.simtec.co.uk/products/SWLINUX/ 4 * http://www.simtec.co.uk/products/SWLINUX/
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 * S3C2410 clock register definitions 10 * S3C2410 NAND register definitions
11 * 11 *
12 * Changelog: 12 * Changelog:
13 * 18-Aug-2004 BJD Copied file from 2.4 and updated 13 * 18-Aug-2004 BJD Copied file from 2.4 and updated
14 * 01-May-2005 BJD Added definitions for s3c2440 controller
14*/ 15*/
15 16
16#ifndef __ASM_ARM_REGS_NAND 17#ifndef __ASM_ARM_REGS_NAND
@@ -26,6 +27,22 @@
26#define S3C2410_NFSTAT S3C2410_NFREG(0x10) 27#define S3C2410_NFSTAT S3C2410_NFREG(0x10)
27#define S3C2410_NFECC S3C2410_NFREG(0x14) 28#define S3C2410_NFECC S3C2410_NFREG(0x14)
28 29
30#define S3C2440_NFCONT S3C2410_NFREG(0x04)
31#define S3C2440_NFCMD S3C2410_NFREG(0x08)
32#define S3C2440_NFADDR S3C2410_NFREG(0x0C)
33#define S3C2440_NFDATA S3C2410_NFREG(0x10)
34#define S3C2440_NFECCD0 S3C2410_NFREG(0x14)
35#define S3C2440_NFECCD1 S3C2410_NFREG(0x18)
36#define S3C2440_NFECCD S3C2410_NFREG(0x1C)
37#define S3C2440_NFSTAT S3C2410_NFREG(0x20)
38#define S3C2440_NFESTAT0 S3C2410_NFREG(0x24)
39#define S3C2440_NFESTAT1 S3C2410_NFREG(0x28)
40#define S3C2440_NFMECC0 S3C2410_NFREG(0x2C)
41#define S3C2440_NFMECC1 S3C2410_NFREG(0x30)
42#define S3C2440_NFSECC S3C2410_NFREG(0x34)
43#define S3C2440_NFSBLK S3C2410_NFREG(0x38)
44#define S3C2440_NFEBLK S3C2410_NFREG(0x3C)
45
29#define S3C2410_NFCONF_EN (1<<15) 46#define S3C2410_NFCONF_EN (1<<15)
30#define S3C2410_NFCONF_512BYTE (1<<14) 47#define S3C2410_NFCONF_512BYTE (1<<14)
31#define S3C2410_NFCONF_4STEP (1<<13) 48#define S3C2410_NFCONF_4STEP (1<<13)
@@ -37,7 +54,28 @@
37 54
38#define S3C2410_NFSTAT_BUSY (1<<0) 55#define S3C2410_NFSTAT_BUSY (1<<0)
39 56
40/* think ECC can only be 8bit read? */ 57#define S3C2440_NFCONF_BUSWIDTH_8 (0<<0)
58#define S3C2440_NFCONF_BUSWIDTH_16 (1<<0)
59#define S3C2440_NFCONF_ADVFLASH (1<<3)
60#define S3C2440_NFCONF_TACLS(x) ((x)<<12)
61#define S3C2440_NFCONF_TWRPH0(x) ((x)<<8)
62#define S3C2440_NFCONF_TWRPH1(x) ((x)<<4)
63
64#define S3C2440_NFCONT_LOCKTIGHT (1<<13)
65#define S3C2440_NFCONT_SOFTLOCK (1<<12)
66#define S3C2440_NFCONT_ILLEGALACC_EN (1<<10)
67#define S3C2440_NFCONT_RNBINT_EN (1<<9)
68#define S3C2440_NFCONT_RN_FALLING (1<<8)
69#define S3C2440_NFCONT_SPARE_ECCLOCK (1<<6)
70#define S3C2440_NFCONT_MAIN_ECCLOCK (1<<5)
71#define S3C2440_NFCONT_INITECC (1<<4)
72#define S3C2440_NFCONT_nFCE (1<<1)
73#define S3C2440_NFCONT_ENABLE (1<<0)
74
75#define S3C2440_NFSTAT_READY (1<<0)
76#define S3C2440_NFSTAT_nCE (1<<1)
77#define S3C2440_NFSTAT_RnB_CHANGE (1<<2)
78#define S3C2440_NFSTAT_ILLEGAL_ACCESS (1<<3)
41 79
42#endif /* __ASM_ARM_REGS_NAND */ 80#endif /* __ASM_ARM_REGS_NAND */
43 81
diff --git a/include/asm-arm/page.h b/include/asm-arm/page.h
index 4ca3a8e9348f..019c45d75730 100644
--- a/include/asm-arm/page.h
+++ b/include/asm-arm/page.h
@@ -114,19 +114,8 @@ extern void __cpu_copy_user_page(void *to, const void *from,
114 unsigned long user); 114 unsigned long user);
115#endif 115#endif
116 116
117#define clear_user_page(addr,vaddr,pg) \ 117#define clear_user_page(addr,vaddr,pg) __cpu_clear_user_page(addr, vaddr)
118 do { \ 118#define copy_user_page(to,from,vaddr,pg) __cpu_copy_user_page(to, from, vaddr)
119 preempt_disable(); \
120 __cpu_clear_user_page(addr, vaddr); \
121 preempt_enable(); \
122 } while (0)
123
124#define copy_user_page(to,from,vaddr,pg) \
125 do { \
126 preempt_disable(); \
127 __cpu_copy_user_page(to, from, vaddr); \
128 preempt_enable(); \
129 } while (0)
130 119
131#define clear_page(page) memzero((void *)(page), PAGE_SIZE) 120#define clear_page(page) memzero((void *)(page), PAGE_SIZE)
132extern void copy_page(void *to, const void *from); 121extern void copy_page(void *to, const void *from);
@@ -171,6 +160,9 @@ typedef unsigned long pgprot_t;
171 160
172#endif /* STRICT_MM_TYPECHECKS */ 161#endif /* STRICT_MM_TYPECHECKS */
173 162
163/* the upper-most page table pointer */
164extern pmd_t *top_pmd;
165
174/* Pure 2^n version of get_order */ 166/* Pure 2^n version of get_order */
175static inline int get_order(unsigned long size) 167static inline int get_order(unsigned long size)
176{ 168{
diff --git a/include/asm-i386/linkage.h b/include/asm-i386/linkage.h
index af3d8571c5c7..f4a6ebac0247 100644
--- a/include/asm-i386/linkage.h
+++ b/include/asm-i386/linkage.h
@@ -5,9 +5,7 @@
5#define FASTCALL(x) x __attribute__((regparm(3))) 5#define FASTCALL(x) x __attribute__((regparm(3)))
6#define fastcall __attribute__((regparm(3))) 6#define fastcall __attribute__((regparm(3)))
7 7
8#ifdef CONFIG_REGPARM 8#define prevent_tail_call(ret) __asm__ ("" : "=r" (ret) : "0" (ret))
9# define prevent_tail_call(ret) __asm__ ("" : "=r" (ret) : "0" (ret))
10#endif
11 9
12#ifdef CONFIG_X86_ALIGNMENT_16 10#ifdef CONFIG_X86_ALIGNMENT_16
13#define __ALIGN .align 16,0x90 11#define __ALIGN .align 16,0x90
diff --git a/include/asm-ia64/ioctl32.h b/include/asm-ia64/ioctl32.h
deleted file mode 100644
index d0d227f45e05..000000000000
--- a/include/asm-ia64/ioctl32.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <linux/ioctl32.h>
diff --git a/include/asm-ppc64/iSeries/mf.h b/include/asm-ppc64/iSeries/mf.h
index 2e59a8e15a0b..db333e1ee216 100644
--- a/include/asm-ppc64/iSeries/mf.h
+++ b/include/asm-ppc64/iSeries/mf.h
@@ -52,6 +52,7 @@ extern void mf_clear_src(void);
52extern void mf_init(void); 52extern void mf_init(void);
53 53
54extern int mf_get_rtc(struct rtc_time *tm); 54extern int mf_get_rtc(struct rtc_time *tm);
55extern int mf_get_boot_rtc(struct rtc_time *tm);
55extern int mf_set_rtc(struct rtc_time *tm); 56extern int mf_set_rtc(struct rtc_time *tm);
56 57
57#endif /* _ASM_PPC64_ISERIES_MF_H */ 58#endif /* _ASM_PPC64_ISERIES_MF_H */
diff --git a/include/asm-sparc64/spitfire.h b/include/asm-sparc64/spitfire.h
index ad78ce64d69e..9d7613eea812 100644
--- a/include/asm-sparc64/spitfire.h
+++ b/include/asm-sparc64/spitfire.h
@@ -48,6 +48,9 @@ enum ultra_tlb_layout {
48 48
49extern enum ultra_tlb_layout tlb_type; 49extern enum ultra_tlb_layout tlb_type;
50 50
51extern int cheetah_pcache_forced_on;
52extern void cheetah_enable_pcache(void);
53
51#define sparc64_highest_locked_tlbent() \ 54#define sparc64_highest_locked_tlbent() \
52 (tlb_type == spitfire ? \ 55 (tlb_type == spitfire ? \
53 SPITFIRE_HIGHEST_LOCKED_TLBENT : \ 56 SPITFIRE_HIGHEST_LOCKED_TLBENT : \
diff --git a/include/asm-um/arch-signal-i386.h b/include/asm-um/arch-signal-i386.h
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/include/asm-um/arch-signal-i386.h
+++ /dev/null
diff --git a/include/asm-um/elf-i386.h b/include/asm-um/elf-i386.h
index b72e23519e00..9bab712dc5c0 100644
--- a/include/asm-um/elf-i386.h
+++ b/include/asm-um/elf-i386.h
@@ -5,7 +5,7 @@
5#ifndef __UM_ELF_I386_H 5#ifndef __UM_ELF_I386_H
6#define __UM_ELF_I386_H 6#define __UM_ELF_I386_H
7 7
8#include "user.h" 8#include <asm/user.h>
9 9
10#define R_386_NONE 0 10#define R_386_NONE 0
11#define R_386_32 1 11#define R_386_32 1
diff --git a/include/asm-um/elf-x86_64.h b/include/asm-um/elf-x86_64.h
index 19309d001aa0..8a8246d03936 100644
--- a/include/asm-um/elf-x86_64.h
+++ b/include/asm-um/elf-x86_64.h
@@ -8,6 +8,27 @@
8 8
9#include <asm/user.h> 9#include <asm/user.h>
10 10
11/* x86-64 relocation types, taken from asm-x86_64/elf.h */
12#define R_X86_64_NONE 0 /* No reloc */
13#define R_X86_64_64 1 /* Direct 64 bit */
14#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
15#define R_X86_64_GOT32 3 /* 32 bit GOT entry */
16#define R_X86_64_PLT32 4 /* 32 bit PLT address */
17#define R_X86_64_COPY 5 /* Copy symbol at runtime */
18#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
19#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
20#define R_X86_64_RELATIVE 8 /* Adjust by program base */
21#define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative
22 offset to GOT */
23#define R_X86_64_32 10 /* Direct 32 bit zero extended */
24#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
25#define R_X86_64_16 12 /* Direct 16 bit zero extended */
26#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
27#define R_X86_64_8 14 /* Direct 8 bit sign extended */
28#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
29
30#define R_X86_64_NUM 16
31
11typedef unsigned long elf_greg_t; 32typedef unsigned long elf_greg_t;
12 33
13#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) 34#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
@@ -44,7 +65,8 @@ typedef struct { } elf_fpregset_t;
44} while (0) 65} while (0)
45 66
46#ifdef TIF_IA32 /* XXX */ 67#ifdef TIF_IA32 /* XXX */
47 clear_thread_flag(TIF_IA32); \ 68#error XXX, indeed
69 clear_thread_flag(TIF_IA32);
48#endif 70#endif
49 71
50#define USE_ELF_CORE_DUMP 72#define USE_ELF_CORE_DUMP
diff --git a/include/asm-um/elf.h b/include/asm-um/elf.h
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/include/asm-um/elf.h
+++ /dev/null
diff --git a/include/asm-x86_64/apicdef.h b/include/asm-x86_64/apicdef.h
index 3d7627ffe67d..bfebdb690654 100644
--- a/include/asm-x86_64/apicdef.h
+++ b/include/asm-x86_64/apicdef.h
@@ -112,7 +112,7 @@
112 112
113#define APIC_BASE (fix_to_virt(FIX_APIC_BASE)) 113#define APIC_BASE (fix_to_virt(FIX_APIC_BASE))
114 114
115#define MAX_IO_APICS 32 115#define MAX_IO_APICS 128
116 116
117/* 117/*
118 * All x86-64 systems are xAPIC compatible. 118 * All x86-64 systems are xAPIC compatible.
diff --git a/include/asm-x86_64/bug.h b/include/asm-x86_64/bug.h
index bdbf66eab6ee..3d2a666a5dd5 100644
--- a/include/asm-x86_64/bug.h
+++ b/include/asm-x86_64/bug.h
@@ -21,6 +21,8 @@ struct bug_frame {
21 asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \ 21 asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \
22 "i"(__LINE__), "i" (__stringify(__FILE__))) 22 "i"(__LINE__), "i" (__stringify(__FILE__)))
23void out_of_line_bug(void); 23void out_of_line_bug(void);
24#else
25static inline void out_of_line_bug(void) { }
24#endif 26#endif
25 27
26#include <asm-generic/bug.h> 28#include <asm-generic/bug.h>
diff --git a/include/asm-x86_64/io_apic.h b/include/asm-x86_64/io_apic.h
index 7efc932e8f0b..32573749004c 100644
--- a/include/asm-x86_64/io_apic.h
+++ b/include/asm-x86_64/io_apic.h
@@ -202,7 +202,6 @@ extern int skip_ioapic_setup;
202#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs) 202#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
203 203
204#ifdef CONFIG_ACPI_BOOT 204#ifdef CONFIG_ACPI_BOOT
205extern int io_apic_get_unique_id (int ioapic, int apic_id);
206extern int io_apic_get_version (int ioapic); 205extern int io_apic_get_version (int ioapic);
207extern int io_apic_get_redir_entries (int ioapic); 206extern int io_apic_get_redir_entries (int ioapic);
208extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int, int); 207extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int, int);
diff --git a/include/asm-x86_64/ioctl32.h b/include/asm-x86_64/ioctl32.h
deleted file mode 100644
index d0d227f45e05..000000000000
--- a/include/asm-x86_64/ioctl32.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <linux/ioctl32.h>
diff --git a/include/asm-x86_64/nmi.h b/include/asm-x86_64/nmi.h
index 21d56b086b9d..d3abfc6a8fd5 100644
--- a/include/asm-x86_64/nmi.h
+++ b/include/asm-x86_64/nmi.h
@@ -53,5 +53,7 @@ extern void die_nmi(char *str, struct pt_regs *regs);
53 53
54extern int panic_on_timeout; 54extern int panic_on_timeout;
55extern int unknown_nmi_panic; 55extern int unknown_nmi_panic;
56
57extern int check_nmi_watchdog(void);
56 58
57#endif /* ASM_NMI_H */ 59#endif /* ASM_NMI_H */
diff --git a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
index f0581c35628e..d641b19f6da5 100644
--- a/include/asm-x86_64/processor.h
+++ b/include/asm-x86_64/processor.h
@@ -62,7 +62,6 @@ struct cpuinfo_x86 {
62 int x86_tlbsize; /* number of 4K pages in DTLB/ITLB combined(in pages)*/ 62 int x86_tlbsize; /* number of 4K pages in DTLB/ITLB combined(in pages)*/
63 __u8 x86_virt_bits, x86_phys_bits; 63 __u8 x86_virt_bits, x86_phys_bits;
64 __u8 x86_num_cores; 64 __u8 x86_num_cores;
65 __u8 x86_apicid;
66 __u32 x86_power; 65 __u32 x86_power;
67 __u32 extended_cpuid_level; /* Max extended CPUID function supported */ 66 __u32 extended_cpuid_level; /* Max extended CPUID function supported */
68 unsigned long loops_per_jiffy; 67 unsigned long loops_per_jiffy;
@@ -159,9 +158,9 @@ static inline void clear_in_cr4 (unsigned long mask)
159 158
160 159
161/* 160/*
162 * User space process size. 47bits. 161 * User space process size. 47bits minus one guard page.
163 */ 162 */
164#define TASK_SIZE (0x800000000000UL) 163#define TASK_SIZE (0x800000000000UL - 4096)
165 164
166/* 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
167 * space during mmap's. 166 * space during mmap's.
diff --git a/include/asm-x86_64/proto.h b/include/asm-x86_64/proto.h
index d0f8f8b4c394..f2f073642d62 100644
--- a/include/asm-x86_64/proto.h
+++ b/include/asm-x86_64/proto.h
@@ -30,6 +30,11 @@ extern void ia32_syscall(void);
30extern void iommu_hole_init(void); 30extern void iommu_hole_init(void);
31 31
32extern void time_init_gtod(void); 32extern void time_init_gtod(void);
33extern int pmtimer_mark_offset(void);
34extern unsigned int do_gettimeoffset_pm(void);
35extern u32 pmtmr_ioport;
36extern unsigned long long monotonic_base;
37extern int sysctl_vsyscall;
33 38
34extern void do_softirq_thunk(void); 39extern void do_softirq_thunk(void);
35 40
diff --git a/include/asm-x86_64/vsyscall.h b/include/asm-x86_64/vsyscall.h
index b0c8d4339906..2872da23fc7e 100644
--- a/include/asm-x86_64/vsyscall.h
+++ b/include/asm-x86_64/vsyscall.h
@@ -25,6 +25,7 @@ enum vsyscall_num {
25 25
26#define VXTIME_TSC 1 26#define VXTIME_TSC 1
27#define VXTIME_HPET 2 27#define VXTIME_HPET 2
28#define VXTIME_PMTMR 3
28 29
29struct vxtime_data { 30struct vxtime_data {
30 long hpet_address; /* HPET base address */ 31 long hpet_address; /* HPET base address */
@@ -54,6 +55,8 @@ extern struct timezone sys_tz;
54extern int sysctl_vsyscall; 55extern int sysctl_vsyscall;
55extern seqlock_t xtime_lock; 56extern seqlock_t xtime_lock;
56 57
58extern int sysctl_vsyscall;
59
57#define ARCH_HAVE_XTIME_LOCK 1 60#define ARCH_HAVE_XTIME_LOCK 1
58 61
59#endif /* __KERNEL__ */ 62#endif /* __KERNEL__ */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index aefe6d051ace..d5a55bdb9c3c 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -25,6 +25,8 @@
25#ifndef _LINUX_ACPI_H 25#ifndef _LINUX_ACPI_H
26#define _LINUX_ACPI_H 26#define _LINUX_ACPI_H
27 27
28#ifdef CONFIG_ACPI
29
28#ifndef _LINUX 30#ifndef _LINUX
29#define _LINUX 31#define _LINUX
30#endif 32#endif
@@ -533,4 +535,5 @@ static inline int acpi_get_pxm(acpi_handle handle)
533 535
534extern int pnpacpi_disabled; 536extern int pnpacpi_disabled;
535 537
536#endif /*_LINUX_ACPI_H*/ 538#endif /* CONFIG_ACPI */
539#endif /*_LINUX_ACPI_H*/
diff --git a/include/linux/device.h b/include/linux/device.h
index cf470459fa69..df94c0de53f2 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -273,9 +273,6 @@ struct device {
273 BIOS data relevant to device) */ 273 BIOS data relevant to device) */
274 struct dev_pm_info power; 274 struct dev_pm_info power;
275 275
276 u32 detach_state; /* State to enter when device is
277 detached from its driver. */
278
279 u64 *dma_mask; /* dma mask (if dma'able device) */ 276 u64 *dma_mask; /* dma mask (if dma'able device) */
280 u64 coherent_dma_mask;/* Like dma_mask, but for 277 u64 coherent_dma_mask;/* Like dma_mask, but for
281 alloc_coherent mappings as 278 alloc_coherent mappings as
diff --git a/include/linux/err.h b/include/linux/err.h
index 17c55df13615..ff71d2af5da3 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -13,6 +13,8 @@
13 * This should be a per-architecture thing, to allow different 13 * This should be a per-architecture thing, to allow different
14 * error and pointer decisions. 14 * error and pointer decisions.
15 */ 15 */
16#define IS_ERR_VALUE(x) unlikely((x) > (unsigned long)-1000L)
17
16static inline void *ERR_PTR(long error) 18static inline void *ERR_PTR(long error)
17{ 19{
18 return (void *) error; 20 return (void *) error;
@@ -25,7 +27,7 @@ static inline long PTR_ERR(const void *ptr)
25 27
26static inline long IS_ERR(const void *ptr) 28static inline long IS_ERR(const void *ptr)
27{ 29{
28 return unlikely((unsigned long)ptr > (unsigned long)-1000L); 30 return IS_ERR_VALUE((unsigned long)ptr);
29} 31}
30 32
31#endif /* _LINUX_ERR_H */ 33#endif /* _LINUX_ERR_H */
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 9cfc0999becb..336d6e509f59 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -664,7 +664,6 @@ typedef struct ide_drive_s {
664 664
665 struct request *rq; /* current request */ 665 struct request *rq; /* current request */
666 struct ide_drive_s *next; /* circular list of hwgroup drives */ 666 struct ide_drive_s *next; /* circular list of hwgroup drives */
667 struct ide_driver_s *driver;/* (ide_driver_t *) */
668 void *driver_data; /* extra driver data */ 667 void *driver_data; /* extra driver data */
669 struct hd_driveid *id; /* drive model identification info */ 668 struct hd_driveid *id; /* drive model identification info */
670 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 669 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
@@ -758,6 +757,8 @@ typedef struct ide_drive_s {
758 struct semaphore gendev_rel_sem; /* to deal with device release() */ 757 struct semaphore gendev_rel_sem; /* to deal with device release() */
759} ide_drive_t; 758} ide_drive_t;
760 759
760#define to_ide_device(dev)container_of(dev, ide_drive_t, gendev)
761
761#define IDE_CHIPSET_PCI_MASK \ 762#define IDE_CHIPSET_PCI_MASK \
762 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx)) 763 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx))
763#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1) 764#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1)
@@ -1086,28 +1087,20 @@ enum {
1086 */ 1087 */
1087typedef struct ide_driver_s { 1088typedef struct ide_driver_s {
1088 struct module *owner; 1089 struct module *owner;
1089 const char *name;
1090 const char *version; 1090 const char *version;
1091 u8 media; 1091 u8 media;
1092 unsigned busy : 1;
1093 unsigned supports_dsc_overlap : 1; 1092 unsigned supports_dsc_overlap : 1;
1094 int (*cleanup)(ide_drive_t *);
1095 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); 1093 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
1096 int (*end_request)(ide_drive_t *, int, int); 1094 int (*end_request)(ide_drive_t *, int, int);
1097 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); 1095 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8);
1098 ide_startstop_t (*abort)(ide_drive_t *, struct request *rq); 1096 ide_startstop_t (*abort)(ide_drive_t *, struct request *rq);
1099 int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long); 1097 int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
1100 ide_proc_entry_t *proc; 1098 ide_proc_entry_t *proc;
1101 int (*attach)(ide_drive_t *);
1102 void (*ata_prebuilder)(ide_drive_t *); 1099 void (*ata_prebuilder)(ide_drive_t *);
1103 void (*atapi_prebuilder)(ide_drive_t *); 1100 void (*atapi_prebuilder)(ide_drive_t *);
1104 struct device_driver gen_driver; 1101 struct device_driver gen_driver;
1105 struct list_head drives;
1106 struct list_head drivers;
1107} ide_driver_t; 1102} ide_driver_t;
1108 1103
1109#define DRIVER(drive) ((drive)->driver)
1110
1111int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); 1104int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);
1112 1105
1113/* 1106/*
@@ -1328,8 +1321,6 @@ extern void ide_init_subdrivers(void);
1328 1321
1329void ide_init_disk(struct gendisk *, ide_drive_t *); 1322void ide_init_disk(struct gendisk *, ide_drive_t *);
1330 1323
1331extern int ata_attach(ide_drive_t *);
1332
1333extern int ideprobe_init(void); 1324extern int ideprobe_init(void);
1334 1325
1335extern void ide_scan_pcibus(int scan_direction) __init; 1326extern void ide_scan_pcibus(int scan_direction) __init;
@@ -1342,11 +1333,8 @@ extern void default_hwif_iops(ide_hwif_t *);
1342extern void default_hwif_mmiops(ide_hwif_t *); 1333extern void default_hwif_mmiops(ide_hwif_t *);
1343extern void default_hwif_transport(ide_hwif_t *); 1334extern void default_hwif_transport(ide_hwif_t *);
1344 1335
1345int ide_register_driver(ide_driver_t *driver); 1336void ide_register_subdriver(ide_drive_t *, ide_driver_t *);
1346void ide_unregister_driver(ide_driver_t *driver); 1337void ide_unregister_subdriver(ide_drive_t *, ide_driver_t *);
1347int ide_register_subdriver(ide_drive_t *, ide_driver_t *);
1348int ide_unregister_subdriver (ide_drive_t *drive);
1349int ide_replace_subdriver(ide_drive_t *drive, const char *driver);
1350 1338
1351#define ON_BOARD 1 1339#define ON_BOARD 1
1352#define NEVER_BOARD 0 1340#define NEVER_BOARD 0
diff --git a/include/linux/if_tr.h b/include/linux/if_tr.h
index 4fd451f81ccb..6688b414c529 100644
--- a/include/linux/if_tr.h
+++ b/include/linux/if_tr.h
@@ -9,7 +9,7 @@
9 * 9 *
10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11 * Donald Becker, <becker@super.org> 11 * Donald Becker, <becker@super.org>
12 * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be> 12 * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be>
13 * 13 *
14 * This program is free software; you can redistribute it and/or 14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License 15 * modify it under the terms of the GNU General Public License
@@ -19,24 +19,16 @@
19#ifndef _LINUX_IF_TR_H 19#ifndef _LINUX_IF_TR_H
20#define _LINUX_IF_TR_H 20#define _LINUX_IF_TR_H
21 21
22
23/* IEEE 802.5 Token-Ring magic constants. The frame sizes omit the preamble 22/* IEEE 802.5 Token-Ring magic constants. The frame sizes omit the preamble
24 and FCS/CRC (frame check sequence). */ 23 and FCS/CRC (frame check sequence). */
25#define TR_ALEN 6 /* Octets in one ethernet addr */ 24#define TR_ALEN 6 /* Octets in one token-ring addr */
26#define TR_HLEN (sizeof(struct trh_hdr)+sizeof(struct trllc)) 25#define TR_HLEN (sizeof(struct trh_hdr)+sizeof(struct trllc))
27#define AC 0x10 26#define AC 0x10
28#define LLC_FRAME 0x40 27#define LLC_FRAME 0x40
29#if 0
30#define ETH_HLEN 14 /* Total octets in header. */
31#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
32#define ETH_DATA_LEN 1500 /* Max. octets in payload */
33#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */
34#endif
35
36 28
37/* LLC and SNAP constants */ 29/* LLC and SNAP constants */
38#define EXTENDED_SAP 0xAA 30#define EXTENDED_SAP 0xAA
39#define UI_CMD 0x03 31#define UI_CMD 0x03
40 32
41/* This is an Token-Ring frame header. */ 33/* This is an Token-Ring frame header. */
42struct trh_hdr { 34struct trh_hdr {
@@ -44,8 +36,8 @@ struct trh_hdr {
44 __u8 fc; /* frame control field */ 36 __u8 fc; /* frame control field */
45 __u8 daddr[TR_ALEN]; /* destination address */ 37 __u8 daddr[TR_ALEN]; /* destination address */
46 __u8 saddr[TR_ALEN]; /* source address */ 38 __u8 saddr[TR_ALEN]; /* source address */
47 __u16 rcf; /* route control field */ 39 __be16 rcf; /* route control field */
48 __u16 rseg[8]; /* routing registers */ 40 __be16 rseg[8]; /* routing registers */
49}; 41};
50 42
51#ifdef __KERNEL__ 43#ifdef __KERNEL__
@@ -63,7 +55,7 @@ struct trllc {
63 __u8 ssap; /* source SAP */ 55 __u8 ssap; /* source SAP */
64 __u8 llc; /* LLC control field */ 56 __u8 llc; /* LLC control field */
65 __u8 protid[3]; /* protocol id */ 57 __u8 protid[3]; /* protocol id */
66 __u16 ethertype; /* ether type field */ 58 __be16 ethertype; /* ether type field */
67}; 59};
68 60
69/* Token-Ring statistics collection data. */ 61/* Token-Ring statistics collection data. */
@@ -96,14 +88,13 @@ struct tr_statistics {
96}; 88};
97 89
98/* source routing stuff */ 90/* source routing stuff */
99 91#define TR_RII 0x80
100#define TR_RII 0x80 92#define TR_RCF_DIR_BIT 0x80
101#define TR_RCF_DIR_BIT 0x80 93#define TR_RCF_LEN_MASK 0x1f00
102#define TR_RCF_LEN_MASK 0x1f00 94#define TR_RCF_BROADCAST 0x8000 /* all-routes broadcast */
103#define TR_RCF_BROADCAST 0x8000 /* all-routes broadcast */ 95#define TR_RCF_LIMITED_BROADCAST 0xC000 /* single-route broadcast */
104#define TR_RCF_LIMITED_BROADCAST 0xC000 /* single-route broadcast */ 96#define TR_RCF_FRAME2K 0x20
105#define TR_RCF_FRAME2K 0x20 97#define TR_RCF_BROADCAST_MASK 0xC000
106#define TR_RCF_BROADCAST_MASK 0xC000 98#define TR_MAXRIFLEN 18
107#define TR_MAXRIFLEN 18
108 99
109#endif /* _LINUX_IF_TR_H */ 100#endif /* _LINUX_IF_TR_H */
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 505160ab472b..1f7e2039a04e 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -584,6 +584,13 @@ static inline void scr_write(struct ata_port *ap, unsigned int reg, u32 val)
584 ap->ops->scr_write(ap, reg, val); 584 ap->ops->scr_write(ap, reg, val);
585} 585}
586 586
587static inline void scr_write_flush(struct ata_port *ap, unsigned int reg,
588 u32 val)
589{
590 ap->ops->scr_write(ap, reg, val);
591 (void) ap->ops->scr_read(ap, reg);
592}
593
587static inline unsigned int sata_dev_present(struct ata_port *ap) 594static inline unsigned int sata_dev_present(struct ata_port *ap)
588{ 595{
589 return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0; 596 return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0;
diff --git a/include/linux/mii.h b/include/linux/mii.h
index 20971fe78a8d..374b615ea9ea 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -65,9 +65,13 @@
65#define ADVERTISE_SLCT 0x001f /* Selector bits */ 65#define ADVERTISE_SLCT 0x001f /* Selector bits */
66#define ADVERTISE_CSMA 0x0001 /* Only selector supported */ 66#define ADVERTISE_CSMA 0x0001 /* Only selector supported */
67#define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */ 67#define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */
68#define ADVERTISE_1000XFULL 0x0020 /* Try for 1000BASE-X full-duplex */
68#define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */ 69#define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */
70#define ADVERTISE_1000XHALF 0x0040 /* Try for 1000BASE-X half-duplex */
69#define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */ 71#define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */
72#define ADVERTISE_1000XPAUSE 0x0080 /* Try for 1000BASE-X pause */
70#define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */ 73#define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */
74#define ADVERTISE_1000XPSE_ASYM 0x0100 /* Try for 1000BASE-X asym pause */
71#define ADVERTISE_100BASE4 0x0200 /* Try for 100mbps 4k packets */ 75#define ADVERTISE_100BASE4 0x0200 /* Try for 100mbps 4k packets */
72#define ADVERTISE_PAUSE_CAP 0x0400 /* Try for pause */ 76#define ADVERTISE_PAUSE_CAP 0x0400 /* Try for pause */
73#define ADVERTISE_PAUSE_ASYM 0x0800 /* Try for asymetric pause */ 77#define ADVERTISE_PAUSE_ASYM 0x0800 /* Try for asymetric pause */
@@ -84,9 +88,13 @@
84/* Link partner ability register. */ 88/* Link partner ability register. */
85#define LPA_SLCT 0x001f /* Same as advertise selector */ 89#define LPA_SLCT 0x001f /* Same as advertise selector */
86#define LPA_10HALF 0x0020 /* Can do 10mbps half-duplex */ 90#define LPA_10HALF 0x0020 /* Can do 10mbps half-duplex */
91#define LPA_1000XFULL 0x0020 /* Can do 1000BASE-X full-duplex */
87#define LPA_10FULL 0x0040 /* Can do 10mbps full-duplex */ 92#define LPA_10FULL 0x0040 /* Can do 10mbps full-duplex */
93#define LPA_1000XHALF 0x0040 /* Can do 1000BASE-X half-duplex */
88#define LPA_100HALF 0x0080 /* Can do 100mbps half-duplex */ 94#define LPA_100HALF 0x0080 /* Can do 100mbps half-duplex */
95#define LPA_1000XPAUSE 0x0080 /* Can do 1000BASE-X pause */
89#define LPA_100FULL 0x0100 /* Can do 100mbps full-duplex */ 96#define LPA_100FULL 0x0100 /* Can do 100mbps full-duplex */
97#define LPA_1000XPAUSE_ASYM 0x0100 /* Can do 1000BASE-X pause asym*/
90#define LPA_100BASE4 0x0200 /* Can do 100mbps 4k packets */ 98#define LPA_100BASE4 0x0200 /* Can do 100mbps 4k packets */
91#define LPA_PAUSE_CAP 0x0400 /* Can pause */ 99#define LPA_PAUSE_CAP 0x0400 /* Can pause */
92#define LPA_PAUSE_ASYM 0x0800 /* Can pause asymetrically */ 100#define LPA_PAUSE_ASYM 0x0800 /* Can pause asymetrically */
diff --git a/include/linux/mmc/protocol.h b/include/linux/mmc/protocol.h
index 7b904c5102f6..896342817b97 100644
--- a/include/linux/mmc/protocol.h
+++ b/include/linux/mmc/protocol.h
@@ -195,6 +195,33 @@ struct _mmc_csd {
195#define MMC_VDD_35_36 0x00800000 /* VDD voltage 3.5 ~ 3.6 */ 195#define MMC_VDD_35_36 0x00800000 /* VDD voltage 3.5 ~ 3.6 */
196#define MMC_CARD_BUSY 0x80000000 /* Card Power up status bit */ 196#define MMC_CARD_BUSY 0x80000000 /* Card Power up status bit */
197 197
198/*
199 * Card Command Classes (CCC)
200 */
201#define CCC_BASIC (1<<0) /* (0) Basic protocol functions */
202 /* (CMD0,1,2,3,4,7,9,10,12,13,15) */
203#define CCC_STREAM_READ (1<<1) /* (1) Stream read commands */
204 /* (CMD11) */
205#define CCC_BLOCK_READ (1<<2) /* (2) Block read commands */
206 /* (CMD16,17,18) */
207#define CCC_STREAM_WRITE (1<<3) /* (3) Stream write commands */
208 /* (CMD20) */
209#define CCC_BLOCK_WRITE (1<<4) /* (4) Block write commands */
210 /* (CMD16,24,25,26,27) */
211#define CCC_ERASE (1<<5) /* (5) Ability to erase blocks */
212 /* (CMD32,33,34,35,36,37,38,39) */
213#define CCC_WRITE_PROT (1<<6) /* (6) Able to write protect blocks */
214 /* (CMD28,29,30) */
215#define CCC_LOCK_CARD (1<<7) /* (7) Able to lock down card */
216 /* (CMD16,CMD42) */
217#define CCC_APP_SPEC (1<<8) /* (8) Application specific */
218 /* (CMD55,56,57,ACMD*) */
219#define CCC_IO_MODE (1<<9) /* (9) I/O mode */
220 /* (CMD5,39,40,52,53) */
221#define CCC_SWITCH (1<<10) /* (10) High speed switch */
222 /* (CMD6,34,35,36,37,50) */
223 /* (11) Reserved */
224 /* (CMD?) */
198 225
199/* 226/*
200 * CSD field definitions 227 * CSD field definitions
diff --git a/include/linux/net.h b/include/linux/net.h
index 6d997ff3f103..20cb226b2268 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -101,7 +101,6 @@ enum sock_type {
101 * @sk: internal networking protocol agnostic socket representation 101 * @sk: internal networking protocol agnostic socket representation
102 * @wait: wait queue for several uses 102 * @wait: wait queue for several uses
103 * @type: socket type (%SOCK_STREAM, etc) 103 * @type: socket type (%SOCK_STREAM, etc)
104 * @passcred: credentials (used only in Unix Sockets (aka PF_LOCAL))
105 */ 104 */
106struct socket { 105struct socket {
107 socket_state state; 106 socket_state state;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ac11d73be4ce..b25bd02720d3 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -503,7 +503,7 @@ static inline void *netdev_priv(struct net_device *dev)
503#define SET_NETDEV_DEV(net, pdev) ((net)->class_dev.dev = (pdev)) 503#define SET_NETDEV_DEV(net, pdev) ((net)->class_dev.dev = (pdev))
504 504
505struct packet_type { 505struct packet_type {
506 unsigned short type; /* This is really htons(ether_type). */ 506 __be16 type; /* This is really htons(ether_type). */
507 struct net_device *dev; /* NULL is wildcarded here */ 507 struct net_device *dev; /* NULL is wildcarded here */
508 int (*func) (struct sk_buff *, struct net_device *, 508 int (*func) (struct sk_buff *, struct net_device *,
509 struct packet_type *); 509 struct packet_type *);
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index ae27792b5aa4..7ccbc2e4272c 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2064,12 +2064,14 @@
2064 2064
2065#define PCI_VENDOR_ID_BROADCOM 0x14e4 2065#define PCI_VENDOR_ID_BROADCOM 0x14e4
2066#define PCI_DEVICE_ID_TIGON3_5752 0x1600 2066#define PCI_DEVICE_ID_TIGON3_5752 0x1600
2067#define PCI_DEVICE_ID_TIGON3_5752M 0x1601
2067#define PCI_DEVICE_ID_TIGON3_5700 0x1644 2068#define PCI_DEVICE_ID_TIGON3_5700 0x1644
2068#define PCI_DEVICE_ID_TIGON3_5701 0x1645 2069#define PCI_DEVICE_ID_TIGON3_5701 0x1645
2069#define PCI_DEVICE_ID_TIGON3_5702 0x1646 2070#define PCI_DEVICE_ID_TIGON3_5702 0x1646
2070#define PCI_DEVICE_ID_TIGON3_5703 0x1647 2071#define PCI_DEVICE_ID_TIGON3_5703 0x1647
2071#define PCI_DEVICE_ID_TIGON3_5704 0x1648 2072#define PCI_DEVICE_ID_TIGON3_5704 0x1648
2072#define PCI_DEVICE_ID_TIGON3_5704S_2 0x1649 2073#define PCI_DEVICE_ID_TIGON3_5704S_2 0x1649
2074#define PCI_DEVICE_ID_NX2_5706 0x164a
2073#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d 2075#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d
2074#define PCI_DEVICE_ID_TIGON3_5705 0x1653 2076#define PCI_DEVICE_ID_TIGON3_5705 0x1653
2075#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654 2077#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654
@@ -2089,6 +2091,7 @@
2089#define PCI_DEVICE_ID_TIGON3_5702X 0x16a6 2091#define PCI_DEVICE_ID_TIGON3_5702X 0x16a6
2090#define PCI_DEVICE_ID_TIGON3_5703X 0x16a7 2092#define PCI_DEVICE_ID_TIGON3_5703X 0x16a7
2091#define PCI_DEVICE_ID_TIGON3_5704S 0x16a8 2093#define PCI_DEVICE_ID_TIGON3_5704S 0x16a8
2094#define PCI_DEVICE_ID_NX2_5706S 0x16aa
2092#define PCI_DEVICE_ID_TIGON3_5702A3 0x16c6 2095#define PCI_DEVICE_ID_TIGON3_5702A3 0x16c6
2093#define PCI_DEVICE_ID_TIGON3_5703A3 0x16c7 2096#define PCI_DEVICE_ID_TIGON3_5703A3 0x16c7
2094#define PCI_DEVICE_ID_TIGON3_5781 0x16dd 2097#define PCI_DEVICE_ID_TIGON3_5781 0x16dd
diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index 73d84c071cb1..1d9da36eb9db 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -427,6 +427,7 @@ enum
427 TCA_NETEM_UNSPEC, 427 TCA_NETEM_UNSPEC,
428 TCA_NETEM_CORR, 428 TCA_NETEM_CORR,
429 TCA_NETEM_DELAY_DIST, 429 TCA_NETEM_DELAY_DIST,
430 TCA_NETEM_REORDER,
430 __TCA_NETEM_MAX, 431 __TCA_NETEM_MAX,
431}; 432};
432 433
@@ -437,7 +438,7 @@ struct tc_netem_qopt
437 __u32 latency; /* added delay (us) */ 438 __u32 latency; /* added delay (us) */
438 __u32 limit; /* fifo limit (packets) */ 439 __u32 limit; /* fifo limit (packets) */
439 __u32 loss; /* random packet loss (0=none ~0=100%) */ 440 __u32 loss; /* random packet loss (0=none ~0=100%) */
440 __u32 gap; /* re-ordering gap (0 for delay all) */ 441 __u32 gap; /* re-ordering gap (0 for none) */
441 __u32 duplicate; /* random packet dup (0=none ~0=100%) */ 442 __u32 duplicate; /* random packet dup (0=none ~0=100%) */
442 __u32 jitter; /* random jitter in latency (us) */ 443 __u32 jitter; /* random jitter in latency (us) */
443}; 444};
@@ -449,6 +450,12 @@ struct tc_netem_corr
449 __u32 dup_corr; /* duplicate correlation */ 450 __u32 dup_corr; /* duplicate correlation */
450}; 451};
451 452
453struct tc_netem_reorder
454{
455 __u32 probability;
456 __u32 correlation;
457};
458
452#define NETEM_DIST_SCALE 8192 459#define NETEM_DIST_SCALE 8192
453 460
454#endif 461#endif
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index c3fb5984f250..d6025af7efac 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -479,6 +479,25 @@ uart_handle_cts_change(struct uart_port *port, unsigned int status)
479 } 479 }
480} 480}
481 481
482#include <linux/tty_flip.h>
483
484static inline void
485uart_insert_char(struct uart_port *port, unsigned int status,
486 unsigned int overrun, unsigned int ch, unsigned int flag)
487{
488 struct tty_struct *tty = port->info->tty;
489
490 if ((status & port->ignore_status_mask & ~overrun) == 0)
491 tty_insert_flip_char(tty, ch, flag);
492
493 /*
494 * Overrun is special. Since it's reported immediately,
495 * it doesn't affect the current character.
496 */
497 if (status & ~port->ignore_status_mask & overrun)
498 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
499}
500
482/* 501/*
483 * UART_ENABLE_MS - determine if port should enable modem status irqs 502 * UART_ENABLE_MS - determine if port should enable modem status irqs
484 */ 503 */
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index e895f3eaf53a..d6ba068719b6 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -248,7 +248,7 @@ typedef struct {
248 248
249#define _spin_trylock_bh(lock) ({preempt_disable(); local_bh_disable(); \ 249#define _spin_trylock_bh(lock) ({preempt_disable(); local_bh_disable(); \
250 _raw_spin_trylock(lock) ? \ 250 _raw_spin_trylock(lock) ? \
251 1 : ({preempt_enable(); local_bh_enable(); 0;});}) 251 1 : ({preempt_enable_no_resched(); local_bh_enable(); 0;});})
252 252
253#define _spin_lock(lock) \ 253#define _spin_lock(lock) \
254do { \ 254do { \
@@ -383,7 +383,7 @@ do { \
383#define _spin_unlock_bh(lock) \ 383#define _spin_unlock_bh(lock) \
384do { \ 384do { \
385 _raw_spin_unlock(lock); \ 385 _raw_spin_unlock(lock); \
386 preempt_enable(); \ 386 preempt_enable_no_resched(); \
387 local_bh_enable(); \ 387 local_bh_enable(); \
388 __release(lock); \ 388 __release(lock); \
389} while (0) 389} while (0)
@@ -391,7 +391,7 @@ do { \
391#define _write_unlock_bh(lock) \ 391#define _write_unlock_bh(lock) \
392do { \ 392do { \
393 _raw_write_unlock(lock); \ 393 _raw_write_unlock(lock); \
394 preempt_enable(); \ 394 preempt_enable_no_resched(); \
395 local_bh_enable(); \ 395 local_bh_enable(); \
396 __release(lock); \ 396 __release(lock); \
397} while (0) 397} while (0)
@@ -423,8 +423,8 @@ do { \
423#define _read_unlock_bh(lock) \ 423#define _read_unlock_bh(lock) \
424do { \ 424do { \
425 _raw_read_unlock(lock); \ 425 _raw_read_unlock(lock); \
426 preempt_enable_no_resched(); \
426 local_bh_enable(); \ 427 local_bh_enable(); \
427 preempt_enable(); \
428 __release(lock); \ 428 __release(lock); \
429} while (0) 429} while (0)
430 430
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 3a358c895188..6409d9cf5965 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -41,6 +41,7 @@ extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags);
41extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags, 41extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
42 unsigned long start, unsigned long end); 42 unsigned long start, unsigned long end);
43extern struct vm_struct *remove_vm_area(void *addr); 43extern struct vm_struct *remove_vm_area(void *addr);
44extern struct vm_struct *__remove_vm_area(void *addr);
44extern int map_vm_area(struct vm_struct *area, pgprot_t prot, 45extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
45 struct page ***pages); 46 struct page ***pages);
46extern void unmap_vm_area(struct vm_struct *area); 47extern void unmap_vm_area(struct vm_struct *area);
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 17c874a8eb3f..c9486c3efb4a 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -386,9 +386,7 @@ int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
386 wait_queue_t name = { \ 386 wait_queue_t name = { \
387 .task = current, \ 387 .task = current, \
388 .func = autoremove_wake_function, \ 388 .func = autoremove_wake_function, \
389 .task_list = { .next = &(name).task_list, \ 389 .task_list = LIST_HEAD_INIT((name).task_list), \
390 .prev = &(name).task_list, \
391 }, \
392 } 390 }
393 391
394#define DEFINE_WAIT_BIT(name, word, bit) \ 392#define DEFINE_WAIT_BIT(name, word, bit) \
diff --git a/include/media/video-buf-dvb.h b/include/media/video-buf-dvb.h
index 94bd33619aa5..ad0a07a3a895 100644
--- a/include/media/video-buf-dvb.h
+++ b/include/media/video-buf-dvb.h
@@ -16,7 +16,7 @@ struct videobuf_dvb {
16 int nfeeds; 16 int nfeeds;
17 17
18 /* videobuf_dvb_(un)register manges this */ 18 /* videobuf_dvb_(un)register manges this */
19 struct dvb_adapter *adapter; 19 struct dvb_adapter adapter;
20 struct dvb_demux demux; 20 struct dvb_demux demux;
21 struct dmxdev dmxdev; 21 struct dmxdev dmxdev;
22 struct dmx_frontend fe_hw; 22 struct dmx_frontend fe_hw;
diff --git a/include/net/act_generic.h b/include/net/act_generic.h
index 95b120781c14..c9daa7e52300 100644
--- a/include/net/act_generic.h
+++ b/include/net/act_generic.h
@@ -2,8 +2,8 @@
2 * include/net/act_generic.h 2 * include/net/act_generic.h
3 * 3 *
4*/ 4*/
5#ifndef ACT_GENERIC_H 5#ifndef _NET_ACT_GENERIC_H
6#define ACT_GENERIC_H 6#define _NET_ACT_GENERIC_H
7static inline int tcf_defact_release(struct tcf_defact *p, int bind) 7static inline int tcf_defact_release(struct tcf_defact *p, int bind)
8{ 8{
9 int ret = 0; 9 int ret = 0;
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index e142a256d5dc..d675836ba6c3 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -515,6 +515,8 @@ struct xfrm_dst
515 struct dst_entry *route; 515 struct dst_entry *route;
516 u32 route_mtu_cached; 516 u32 route_mtu_cached;
517 u32 child_mtu_cached; 517 u32 child_mtu_cached;
518 u32 route_cookie;
519 u32 path_cookie;
518}; 520};
519 521
520static inline void xfrm_dst_destroy(struct xfrm_dst *xdst) 522static inline void xfrm_dst_destroy(struct xfrm_dst *xdst)
diff --git a/include/scsi/scsi_transport_spi.h b/include/scsi/scsi_transport_spi.h
index 6dcf497bf46d..a30d6cd4c0e8 100644
--- a/include/scsi/scsi_transport_spi.h
+++ b/include/scsi/scsi_transport_spi.h
@@ -27,8 +27,11 @@ struct scsi_transport_template;
27 27
28struct spi_transport_attrs { 28struct spi_transport_attrs {
29 int period; /* value in the PPR/SDTR command */ 29 int period; /* value in the PPR/SDTR command */
30 int min_period;
30 int offset; 31 int offset;
32 int max_offset;
31 unsigned int width:1; /* 0 - narrow, 1 - wide */ 33 unsigned int width:1; /* 0 - narrow, 1 - wide */
34 unsigned int max_width:1;
32 unsigned int iu:1; /* Information Units enabled */ 35 unsigned int iu:1; /* Information Units enabled */
33 unsigned int dt:1; /* DT clocking enabled */ 36 unsigned int dt:1; /* DT clocking enabled */
34 unsigned int qas:1; /* Quick Arbitration and Selection enabled */ 37 unsigned int qas:1; /* Quick Arbitration and Selection enabled */
@@ -63,8 +66,11 @@ struct spi_host_attrs {
63 66
64/* accessor functions */ 67/* accessor functions */
65#define spi_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->period) 68#define spi_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->period)
69#define spi_min_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->min_period)
66#define spi_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->offset) 70#define spi_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->offset)
71#define spi_max_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_offset)
67#define spi_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->width) 72#define spi_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->width)
73#define spi_max_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_width)
68#define spi_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->iu) 74#define spi_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->iu)
69#define spi_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dt) 75#define spi_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dt)
70#define spi_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->qas) 76#define spi_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->qas)
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 961d74044deb..00e8f2575512 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -166,9 +166,8 @@ static struct super_block *cpuset_sb = NULL;
166 * The hooks from fork and exit, cpuset_fork() and cpuset_exit(), don't 166 * The hooks from fork and exit, cpuset_fork() and cpuset_exit(), don't
167 * (usually) grab cpuset_sem. These are the two most performance 167 * (usually) grab cpuset_sem. These are the two most performance
168 * critical pieces of code here. The exception occurs on exit(), 168 * critical pieces of code here. The exception occurs on exit(),
169 * if the last task using a cpuset exits, and the cpuset was marked 169 * when a task in a notify_on_release cpuset exits. Then cpuset_sem
170 * notify_on_release. In that case, the cpuset_sem is taken, the 170 * is taken, and if the cpuset count is zero, a usermode call made
171 * path to the released cpuset calculated, and a usermode call made
172 * to /sbin/cpuset_release_agent with the name of the cpuset (path 171 * to /sbin/cpuset_release_agent with the name of the cpuset (path
173 * relative to the root of cpuset file system) as the argument. 172 * relative to the root of cpuset file system) as the argument.
174 * 173 *
@@ -1404,6 +1403,18 @@ void cpuset_fork(struct task_struct *tsk)
1404 * 1403 *
1405 * Description: Detach cpuset from @tsk and release it. 1404 * Description: Detach cpuset from @tsk and release it.
1406 * 1405 *
1406 * Note that cpusets marked notify_on_release force every task
1407 * in them to take the global cpuset_sem semaphore when exiting.
1408 * This could impact scaling on very large systems. Be reluctant
1409 * to use notify_on_release cpusets where very high task exit
1410 * scaling is required on large systems.
1411 *
1412 * Don't even think about derefencing 'cs' after the cpuset use
1413 * count goes to zero, except inside a critical section guarded
1414 * by the cpuset_sem semaphore. If you don't hold cpuset_sem,
1415 * then a zero cpuset use count is a license to any other task to
1416 * nuke the cpuset immediately.
1417 *
1407 **/ 1418 **/
1408 1419
1409void cpuset_exit(struct task_struct *tsk) 1420void cpuset_exit(struct task_struct *tsk)
@@ -1415,10 +1426,13 @@ void cpuset_exit(struct task_struct *tsk)
1415 tsk->cpuset = NULL; 1426 tsk->cpuset = NULL;
1416 task_unlock(tsk); 1427 task_unlock(tsk);
1417 1428
1418 if (atomic_dec_and_test(&cs->count)) { 1429 if (notify_on_release(cs)) {
1419 down(&cpuset_sem); 1430 down(&cpuset_sem);
1420 check_for_release(cs); 1431 if (atomic_dec_and_test(&cs->count))
1432 check_for_release(cs);
1421 up(&cpuset_sem); 1433 up(&cpuset_sem);
1434 } else {
1435 atomic_dec(&cs->count);
1422 } 1436 }
1423} 1437}
1424 1438
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 2fb0e46e11f3..06b5a6323998 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -30,6 +30,7 @@
30 */ 30 */
31irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = { 31irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
32 [0 ... NR_IRQS-1] = { 32 [0 ... NR_IRQS-1] = {
33 .status = IRQ_DISABLED,
33 .handler = &no_irq_type, 34 .handler = &no_irq_type,
34 .lock = SPIN_LOCK_UNLOCKED 35 .lock = SPIN_LOCK_UNLOCKED
35 } 36 }
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 7960ddf04a57..4cdebc972ff2 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -156,14 +156,14 @@ static int enter_state(suspend_state_t state)
156 goto Unlock; 156 goto Unlock;
157 } 157 }
158 158
159 pr_debug("PM: Preparing system for suspend\n"); 159 pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
160 if ((error = suspend_prepare(state))) 160 if ((error = suspend_prepare(state)))
161 goto Unlock; 161 goto Unlock;
162 162
163 pr_debug("PM: Entering state.\n"); 163 pr_debug("PM: Entering %s sleep\n", pm_states[state]);
164 error = suspend_enter(state); 164 error = suspend_enter(state);
165 165
166 pr_debug("PM: Finishing up.\n"); 166 pr_debug("PM: Finishing wakeup.\n");
167 suspend_finish(state); 167 suspend_finish(state);
168 Unlock: 168 Unlock:
169 up(&pm_sem); 169 up(&pm_sem);
diff --git a/kernel/printk.c b/kernel/printk.c
index 290a07ce2c8a..01b58d7d17ff 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -160,42 +160,6 @@ static int __init console_setup(char *str)
160 160
161__setup("console=", console_setup); 161__setup("console=", console_setup);
162 162
163/**
164 * add_preferred_console - add a device to the list of preferred consoles.
165 *
166 * The last preferred console added will be used for kernel messages
167 * and stdin/out/err for init. Normally this is used by console_setup
168 * above to handle user-supplied console arguments; however it can also
169 * be used by arch-specific code either to override the user or more
170 * commonly to provide a default console (ie from PROM variables) when
171 * the user has not supplied one.
172 */
173int __init add_preferred_console(char *name, int idx, char *options)
174{
175 struct console_cmdline *c;
176 int i;
177
178 /*
179 * See if this tty is not yet registered, and
180 * if we have a slot free.
181 */
182 for(i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
183 if (strcmp(console_cmdline[i].name, name) == 0 &&
184 console_cmdline[i].index == idx) {
185 selected_console = i;
186 return 0;
187 }
188 if (i == MAX_CMDLINECONSOLES)
189 return -E2BIG;
190 selected_console = i;
191 c = &console_cmdline[i];
192 memcpy(c->name, name, sizeof(c->name));
193 c->name[sizeof(c->name) - 1] = 0;
194 c->options = options;
195 c->index = idx;
196 return 0;
197}
198
199static int __init log_buf_len_setup(char *str) 163static int __init log_buf_len_setup(char *str)
200{ 164{
201 unsigned long size = memparse(str, &str); 165 unsigned long size = memparse(str, &str);
@@ -671,6 +635,42 @@ static void call_console_drivers(unsigned long start, unsigned long end) {}
671#endif 635#endif
672 636
673/** 637/**
638 * add_preferred_console - add a device to the list of preferred consoles.
639 *
640 * The last preferred console added will be used for kernel messages
641 * and stdin/out/err for init. Normally this is used by console_setup
642 * above to handle user-supplied console arguments; however it can also
643 * be used by arch-specific code either to override the user or more
644 * commonly to provide a default console (ie from PROM variables) when
645 * the user has not supplied one.
646 */
647int __init add_preferred_console(char *name, int idx, char *options)
648{
649 struct console_cmdline *c;
650 int i;
651
652 /*
653 * See if this tty is not yet registered, and
654 * if we have a slot free.
655 */
656 for(i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
657 if (strcmp(console_cmdline[i].name, name) == 0 &&
658 console_cmdline[i].index == idx) {
659 selected_console = i;
660 return 0;
661 }
662 if (i == MAX_CMDLINECONSOLES)
663 return -E2BIG;
664 selected_console = i;
665 c = &console_cmdline[i];
666 memcpy(c->name, name, sizeof(c->name));
667 c->name[sizeof(c->name) - 1] = 0;
668 c->options = options;
669 c->index = idx;
670 return 0;
671}
672
673/**
674 * acquire_console_sem - lock the console system for exclusive use. 674 * acquire_console_sem - lock the console system for exclusive use.
675 * 675 *
676 * Acquires a semaphore which guarantees that the caller has 676 * Acquires a semaphore which guarantees that the caller has
diff --git a/kernel/profile.c b/kernel/profile.c
index 0221a50ca867..ad8cbb75ffa2 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -49,15 +49,19 @@ static DECLARE_MUTEX(profile_flip_mutex);
49 49
50static int __init profile_setup(char * str) 50static int __init profile_setup(char * str)
51{ 51{
52 static char __initdata schedstr[] = "schedule";
52 int par; 53 int par;
53 54
54 if (!strncmp(str, "schedule", 8)) { 55 if (!strncmp(str, schedstr, strlen(schedstr))) {
55 prof_on = SCHED_PROFILING; 56 prof_on = SCHED_PROFILING;
56 printk(KERN_INFO "kernel schedule profiling enabled\n"); 57 if (str[strlen(schedstr)] == ',')
57 if (str[7] == ',') 58 str += strlen(schedstr) + 1;
58 str += 8; 59 if (get_option(&str, &par))
59 } 60 prof_shift = par;
60 if (get_option(&str,&par)) { 61 printk(KERN_INFO
62 "kernel schedule profiling enabled (shift: %ld)\n",
63 prof_shift);
64 } else if (get_option(&str, &par)) {
61 prof_shift = par; 65 prof_shift = par;
62 prof_on = CPU_PROFILING; 66 prof_on = CPU_PROFILING;
63 printk(KERN_INFO "kernel profiling enabled (shift: %ld)\n", 67 printk(KERN_INFO "kernel profiling enabled (shift: %ld)\n",
diff --git a/kernel/sched.c b/kernel/sched.c
index 0dc3158667a2..66b2ed784822 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4243,7 +4243,7 @@ static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *tsk)
4243 4243
4244 /* No more Mr. Nice Guy. */ 4244 /* No more Mr. Nice Guy. */
4245 if (dest_cpu == NR_CPUS) { 4245 if (dest_cpu == NR_CPUS) {
4246 tsk->cpus_allowed = cpuset_cpus_allowed(tsk); 4246 cpus_setall(tsk->cpus_allowed);
4247 dest_cpu = any_online_cpu(tsk->cpus_allowed); 4247 dest_cpu = any_online_cpu(tsk->cpus_allowed);
4248 4248
4249 /* 4249 /*
diff --git a/kernel/signal.c b/kernel/signal.c
index 8f3debc77c5b..b3c24c732c5a 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -522,7 +522,16 @@ static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
522{ 522{
523 int sig = 0; 523 int sig = 0;
524 524
525 sig = next_signal(pending, mask); 525 /* SIGKILL must have priority, otherwise it is quite easy
526 * to create an unkillable process, sending sig < SIGKILL
527 * to self */
528 if (unlikely(sigismember(&pending->signal, SIGKILL))) {
529 if (!sigismember(mask, SIGKILL))
530 sig = SIGKILL;
531 }
532
533 if (likely(!sig))
534 sig = next_signal(pending, mask);
526 if (sig) { 535 if (sig) {
527 if (current->notifier) { 536 if (current->notifier) {
528 if (sigismember(current->notifier_mask, sig)) { 537 if (sigismember(current->notifier_mask, sig)) {
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index e15ed17863f1..0c3f9d8bbe17 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -294,7 +294,7 @@ EXPORT_SYMBOL(_spin_unlock_irq);
294void __lockfunc _spin_unlock_bh(spinlock_t *lock) 294void __lockfunc _spin_unlock_bh(spinlock_t *lock)
295{ 295{
296 _raw_spin_unlock(lock); 296 _raw_spin_unlock(lock);
297 preempt_enable(); 297 preempt_enable_no_resched();
298 local_bh_enable(); 298 local_bh_enable();
299} 299}
300EXPORT_SYMBOL(_spin_unlock_bh); 300EXPORT_SYMBOL(_spin_unlock_bh);
@@ -318,7 +318,7 @@ EXPORT_SYMBOL(_read_unlock_irq);
318void __lockfunc _read_unlock_bh(rwlock_t *lock) 318void __lockfunc _read_unlock_bh(rwlock_t *lock)
319{ 319{
320 _raw_read_unlock(lock); 320 _raw_read_unlock(lock);
321 preempt_enable(); 321 preempt_enable_no_resched();
322 local_bh_enable(); 322 local_bh_enable();
323} 323}
324EXPORT_SYMBOL(_read_unlock_bh); 324EXPORT_SYMBOL(_read_unlock_bh);
@@ -342,7 +342,7 @@ EXPORT_SYMBOL(_write_unlock_irq);
342void __lockfunc _write_unlock_bh(rwlock_t *lock) 342void __lockfunc _write_unlock_bh(rwlock_t *lock)
343{ 343{
344 _raw_write_unlock(lock); 344 _raw_write_unlock(lock);
345 preempt_enable(); 345 preempt_enable_no_resched();
346 local_bh_enable(); 346 local_bh_enable();
347} 347}
348EXPORT_SYMBOL(_write_unlock_bh); 348EXPORT_SYMBOL(_write_unlock_bh);
@@ -354,7 +354,7 @@ int __lockfunc _spin_trylock_bh(spinlock_t *lock)
354 if (_raw_spin_trylock(lock)) 354 if (_raw_spin_trylock(lock))
355 return 1; 355 return 1;
356 356
357 preempt_enable(); 357 preempt_enable_no_resched();
358 local_bh_enable(); 358 local_bh_enable();
359 return 0; 359 return 0;
360} 360}
diff --git a/mm/filemap.c b/mm/filemap.c
index 47263ac3e4ea..1d33fec7bac6 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1004,7 +1004,7 @@ __generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
1004 if (pos < size) { 1004 if (pos < size) {
1005 retval = generic_file_direct_IO(READ, iocb, 1005 retval = generic_file_direct_IO(READ, iocb,
1006 iov, pos, nr_segs); 1006 iov, pos, nr_segs);
1007 if (retval >= 0 && !is_sync_kiocb(iocb)) 1007 if (retval > 0 && !is_sync_kiocb(iocb))
1008 retval = -EIOCBQUEUED; 1008 retval = -EIOCBQUEUED;
1009 if (retval > 0) 1009 if (retval > 0)
1010 *ppos = pos + retval; 1010 *ppos = pos + retval;
diff --git a/mm/memory.c b/mm/memory.c
index 6bad4c4064e7..d209f745db7f 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1701,12 +1701,13 @@ static int do_swap_page(struct mm_struct * mm,
1701 spin_lock(&mm->page_table_lock); 1701 spin_lock(&mm->page_table_lock);
1702 page_table = pte_offset_map(pmd, address); 1702 page_table = pte_offset_map(pmd, address);
1703 if (unlikely(!pte_same(*page_table, orig_pte))) { 1703 if (unlikely(!pte_same(*page_table, orig_pte))) {
1704 pte_unmap(page_table);
1705 spin_unlock(&mm->page_table_lock);
1706 unlock_page(page);
1707 page_cache_release(page);
1708 ret = VM_FAULT_MINOR; 1704 ret = VM_FAULT_MINOR;
1709 goto out; 1705 goto out_nomap;
1706 }
1707
1708 if (unlikely(!PageUptodate(page))) {
1709 ret = VM_FAULT_SIGBUS;
1710 goto out_nomap;
1710 } 1711 }
1711 1712
1712 /* The page isn't present yet, go ahead with the fault. */ 1713 /* The page isn't present yet, go ahead with the fault. */
@@ -1741,6 +1742,12 @@ static int do_swap_page(struct mm_struct * mm,
1741 spin_unlock(&mm->page_table_lock); 1742 spin_unlock(&mm->page_table_lock);
1742out: 1743out:
1743 return ret; 1744 return ret;
1745out_nomap:
1746 pte_unmap(page_table);
1747 spin_unlock(&mm->page_table_lock);
1748 unlock_page(page);
1749 page_cache_release(page);
1750 goto out;
1744} 1751}
1745 1752
1746/* 1753/*
diff --git a/mm/mmap.c b/mm/mmap.c
index 01f9793591f6..de54acd9942f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1244,7 +1244,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
1244 addr = mm->free_area_cache; 1244 addr = mm->free_area_cache;
1245 1245
1246 /* make sure it can fit in the remaining address space */ 1246 /* make sure it can fit in the remaining address space */
1247 if (addr >= len) { 1247 if (addr > len) {
1248 vma = find_vma(mm, addr-len); 1248 vma = find_vma(mm, addr-len);
1249 if (!vma || addr <= vma->vm_start) 1249 if (!vma || addr <= vma->vm_start)
1250 /* remember the address as a hint for next time */ 1250 /* remember the address as a hint for next time */
@@ -1266,7 +1266,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
1266 1266
1267 /* try just below the current vma->vm_start */ 1267 /* try just below the current vma->vm_start */
1268 addr = vma->vm_start-len; 1268 addr = vma->vm_start-len;
1269 } while (len <= vma->vm_start); 1269 } while (len < vma->vm_start);
1270 1270
1271 /* 1271 /*
1272 * A failed mmap() very likely causes application failure, 1272 * A failed mmap() very likely causes application failure,
@@ -1302,37 +1302,40 @@ unsigned long
1302get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, 1302get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
1303 unsigned long pgoff, unsigned long flags) 1303 unsigned long pgoff, unsigned long flags)
1304{ 1304{
1305 if (flags & MAP_FIXED) { 1305 unsigned long ret;
1306 unsigned long ret;
1307 1306
1308 if (addr > TASK_SIZE - len) 1307 if (!(flags & MAP_FIXED)) {
1309 return -ENOMEM; 1308 unsigned long (*get_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
1310 if (addr & ~PAGE_MASK)
1311 return -EINVAL;
1312 if (file && is_file_hugepages(file)) {
1313 /*
1314 * Check if the given range is hugepage aligned, and
1315 * can be made suitable for hugepages.
1316 */
1317 ret = prepare_hugepage_range(addr, len);
1318 } else {
1319 /*
1320 * Ensure that a normal request is not falling in a
1321 * reserved hugepage range. For some archs like IA-64,
1322 * there is a separate region for hugepages.
1323 */
1324 ret = is_hugepage_only_range(current->mm, addr, len);
1325 }
1326 if (ret)
1327 return -EINVAL;
1328 return addr;
1329 }
1330 1309
1331 if (file && file->f_op && file->f_op->get_unmapped_area) 1310 get_area = current->mm->get_unmapped_area;
1332 return file->f_op->get_unmapped_area(file, addr, len, 1311 if (file && file->f_op && file->f_op->get_unmapped_area)
1333 pgoff, flags); 1312 get_area = file->f_op->get_unmapped_area;
1313 addr = get_area(file, addr, len, pgoff, flags);
1314 if (IS_ERR_VALUE(addr))
1315 return addr;
1316 }
1334 1317
1335 return current->mm->get_unmapped_area(file, addr, len, pgoff, flags); 1318 if (addr > TASK_SIZE - len)
1319 return -ENOMEM;
1320 if (addr & ~PAGE_MASK)
1321 return -EINVAL;
1322 if (file && is_file_hugepages(file)) {
1323 /*
1324 * Check if the given range is hugepage aligned, and
1325 * can be made suitable for hugepages.
1326 */
1327 ret = prepare_hugepage_range(addr, len);
1328 } else {
1329 /*
1330 * Ensure that a normal request is not falling in a
1331 * reserved hugepage range. For some archs like IA-64,
1332 * there is a separate region for hugepages.
1333 */
1334 ret = is_hugepage_only_range(current->mm, addr, len);
1335 }
1336 if (ret)
1337 return -EINVAL;
1338 return addr;
1336} 1339}
1337 1340
1338EXPORT_SYMBOL(get_unmapped_area); 1341EXPORT_SYMBOL(get_unmapped_area);
diff --git a/mm/mremap.c b/mm/mremap.c
index 0dd7ace94e51..ec7238a78f36 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -224,6 +224,12 @@ static unsigned long move_vma(struct vm_area_struct *vma,
224 split = 1; 224 split = 1;
225 } 225 }
226 226
227 /*
228 * if we failed to move page tables we still do total_vm increment
229 * since do_munmap() will decrement it by old_len == new_len
230 */
231 mm->total_vm += new_len >> PAGE_SHIFT;
232
227 if (do_munmap(mm, old_addr, old_len) < 0) { 233 if (do_munmap(mm, old_addr, old_len) < 0) {
228 /* OOM: unable to split vma, just get accounts right */ 234 /* OOM: unable to split vma, just get accounts right */
229 vm_unacct_memory(excess >> PAGE_SHIFT); 235 vm_unacct_memory(excess >> PAGE_SHIFT);
@@ -237,7 +243,6 @@ static unsigned long move_vma(struct vm_area_struct *vma,
237 vma->vm_next->vm_flags |= VM_ACCOUNT; 243 vma->vm_next->vm_flags |= VM_ACCOUNT;
238 } 244 }
239 245
240 mm->total_vm += new_len >> PAGE_SHIFT;
241 __vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT); 246 __vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
242 if (vm_flags & VM_LOCKED) { 247 if (vm_flags & VM_LOCKED) {
243 mm->locked_vm += new_len >> PAGE_SHIFT; 248 mm->locked_vm += new_len >> PAGE_SHIFT;
diff --git a/mm/nommu.c b/mm/nommu.c
index b293ec1cc4e6..c53e9c8f6b4a 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -150,7 +150,8 @@ void vfree(void *addr)
150 kfree(addr); 150 kfree(addr);
151} 151}
152 152
153void *__vmalloc(unsigned long size, int gfp_mask, pgprot_t prot) 153void *__vmalloc(unsigned long size, unsigned int __nocast gfp_mask,
154 pgprot_t prot)
154{ 155{
155 /* 156 /*
156 * kmalloc doesn't like __GFP_HIGHMEM for some reason 157 * kmalloc doesn't like __GFP_HIGHMEM for some reason
diff --git a/mm/rmap.c b/mm/rmap.c
index 378de234c12b..9827409eb7c7 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -586,7 +586,7 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma)
586 dec_mm_counter(mm, anon_rss); 586 dec_mm_counter(mm, anon_rss);
587 } 587 }
588 588
589 inc_mm_counter(mm, rss); 589 dec_mm_counter(mm, rss);
590 page_remove_rmap(page); 590 page_remove_rmap(page);
591 page_cache_release(page); 591 page_cache_release(page);
592 592
@@ -626,7 +626,7 @@ static void try_to_unmap_cluster(unsigned long cursor,
626 pgd_t *pgd; 626 pgd_t *pgd;
627 pud_t *pud; 627 pud_t *pud;
628 pmd_t *pmd; 628 pmd_t *pmd;
629 pte_t *pte; 629 pte_t *pte, *original_pte;
630 pte_t pteval; 630 pte_t pteval;
631 struct page *page; 631 struct page *page;
632 unsigned long address; 632 unsigned long address;
@@ -658,7 +658,7 @@ static void try_to_unmap_cluster(unsigned long cursor,
658 if (!pmd_present(*pmd)) 658 if (!pmd_present(*pmd))
659 goto out_unlock; 659 goto out_unlock;
660 660
661 for (pte = pte_offset_map(pmd, address); 661 for (original_pte = pte = pte_offset_map(pmd, address);
662 address < end; pte++, address += PAGE_SIZE) { 662 address < end; pte++, address += PAGE_SIZE) {
663 663
664 if (!pte_present(*pte)) 664 if (!pte_present(*pte))
@@ -694,7 +694,7 @@ static void try_to_unmap_cluster(unsigned long cursor,
694 (*mapcount)--; 694 (*mapcount)--;
695 } 695 }
696 696
697 pte_unmap(pte); 697 pte_unmap(original_pte);
698out_unlock: 698out_unlock:
699 spin_unlock(&mm->page_table_lock); 699 spin_unlock(&mm->page_table_lock);
700} 700}
diff --git a/mm/swapfile.c b/mm/swapfile.c
index a60e0075d55b..da48405cd9a3 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -79,7 +79,7 @@ void swap_unplug_io_fn(struct backing_dev_info *unused_bdi, struct page *page)
79 WARN_ON(page_count(page) <= 1); 79 WARN_ON(page_count(page) <= 1);
80 80
81 bdi = bdev->bd_inode->i_mapping->backing_dev_info; 81 bdi = bdev->bd_inode->i_mapping->backing_dev_info;
82 bdi->unplug_io_fn(bdi, page); 82 blk_run_backing_dev(bdi, page);
83 } 83 }
84 up_read(&swap_unplug_sem); 84 up_read(&swap_unplug_sem);
85} 85}
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 2bd83e5c2bbf..8ff16a1eee6a 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -248,31 +248,20 @@ struct vm_struct *get_vm_area(unsigned long size, unsigned long flags)
248 return __get_vm_area(size, flags, VMALLOC_START, VMALLOC_END); 248 return __get_vm_area(size, flags, VMALLOC_START, VMALLOC_END);
249} 249}
250 250
251/** 251/* Caller must hold vmlist_lock */
252 * remove_vm_area - find and remove a contingous kernel virtual area 252struct vm_struct *__remove_vm_area(void *addr)
253 *
254 * @addr: base address
255 *
256 * Search for the kernel VM area starting at @addr, and remove it.
257 * This function returns the found VM area, but using it is NOT safe
258 * on SMP machines.
259 */
260struct vm_struct *remove_vm_area(void *addr)
261{ 253{
262 struct vm_struct **p, *tmp; 254 struct vm_struct **p, *tmp;
263 255
264 write_lock(&vmlist_lock);
265 for (p = &vmlist ; (tmp = *p) != NULL ;p = &tmp->next) { 256 for (p = &vmlist ; (tmp = *p) != NULL ;p = &tmp->next) {
266 if (tmp->addr == addr) 257 if (tmp->addr == addr)
267 goto found; 258 goto found;
268 } 259 }
269 write_unlock(&vmlist_lock);
270 return NULL; 260 return NULL;
271 261
272found: 262found:
273 unmap_vm_area(tmp); 263 unmap_vm_area(tmp);
274 *p = tmp->next; 264 *p = tmp->next;
275 write_unlock(&vmlist_lock);
276 265
277 /* 266 /*
278 * Remove the guard page. 267 * Remove the guard page.
@@ -281,6 +270,24 @@ found:
281 return tmp; 270 return tmp;
282} 271}
283 272
273/**
274 * remove_vm_area - find and remove a contingous kernel virtual area
275 *
276 * @addr: base address
277 *
278 * Search for the kernel VM area starting at @addr, and remove it.
279 * This function returns the found VM area, but using it is NOT safe
280 * on SMP machines, except for its size or flags.
281 */
282struct vm_struct *remove_vm_area(void *addr)
283{
284 struct vm_struct *v;
285 write_lock(&vmlist_lock);
286 v = __remove_vm_area(addr);
287 write_unlock(&vmlist_lock);
288 return v;
289}
290
284void __vunmap(void *addr, int deallocate_pages) 291void __vunmap(void *addr, int deallocate_pages)
285{ 292{
286 struct vm_struct *area; 293 struct vm_struct *area;
diff --git a/net/802/tr.c b/net/802/tr.c
index 85293ccf7efc..a755e880f4ba 100644
--- a/net/802/tr.c
+++ b/net/802/tr.c
@@ -47,12 +47,12 @@ static void rif_check_expire(unsigned long dummy);
47 * Each RIF entry we learn is kept this way 47 * Each RIF entry we learn is kept this way
48 */ 48 */
49 49
50struct rif_cache_s { 50struct rif_cache {
51 unsigned char addr[TR_ALEN]; 51 unsigned char addr[TR_ALEN];
52 int iface; 52 int iface;
53 __u16 rcf; 53 __be16 rcf;
54 __u16 rseg[8]; 54 __be16 rseg[8];
55 struct rif_cache_s *next; 55 struct rif_cache *next;
56 unsigned long last_used; 56 unsigned long last_used;
57 unsigned char local_ring; 57 unsigned char local_ring;
58}; 58};
@@ -64,7 +64,7 @@ struct rif_cache_s {
64 * up a lot. 64 * up a lot.
65 */ 65 */
66 66
67static struct rif_cache_s *rif_table[RIF_TABLE_SIZE]; 67static struct rif_cache *rif_table[RIF_TABLE_SIZE];
68 68
69static DEFINE_SPINLOCK(rif_lock); 69static DEFINE_SPINLOCK(rif_lock);
70 70
@@ -249,7 +249,7 @@ void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,struct net_device *
249{ 249{
250 int slack; 250 int slack;
251 unsigned int hash; 251 unsigned int hash;
252 struct rif_cache_s *entry; 252 struct rif_cache *entry;
253 unsigned char *olddata; 253 unsigned char *olddata;
254 static const unsigned char mcast_func_addr[] 254 static const unsigned char mcast_func_addr[]
255 = {0xC0,0x00,0x00,0x04,0x00,0x00}; 255 = {0xC0,0x00,0x00,0x04,0x00,0x00};
@@ -337,7 +337,7 @@ printk("source routing for %02X:%02X:%02X:%02X:%02X:%02X\n",trh->daddr[0],
337static void tr_add_rif_info(struct trh_hdr *trh, struct net_device *dev) 337static void tr_add_rif_info(struct trh_hdr *trh, struct net_device *dev)
338{ 338{
339 unsigned int hash, rii_p = 0; 339 unsigned int hash, rii_p = 0;
340 struct rif_cache_s *entry; 340 struct rif_cache *entry;
341 341
342 342
343 spin_lock_bh(&rif_lock); 343 spin_lock_bh(&rif_lock);
@@ -373,7 +373,7 @@ printk("adding rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
373 * FIXME: We ought to keep some kind of cache size 373 * FIXME: We ought to keep some kind of cache size
374 * limiting and adjust the timers to suit. 374 * limiting and adjust the timers to suit.
375 */ 375 */
376 entry=kmalloc(sizeof(struct rif_cache_s),GFP_ATOMIC); 376 entry=kmalloc(sizeof(struct rif_cache),GFP_ATOMIC);
377 377
378 if(!entry) 378 if(!entry)
379 { 379 {
@@ -435,7 +435,7 @@ static void rif_check_expire(unsigned long dummy)
435 spin_lock_bh(&rif_lock); 435 spin_lock_bh(&rif_lock);
436 436
437 for(i =0; i < RIF_TABLE_SIZE; i++) { 437 for(i =0; i < RIF_TABLE_SIZE; i++) {
438 struct rif_cache_s *entry, **pentry; 438 struct rif_cache *entry, **pentry;
439 439
440 pentry = rif_table+i; 440 pentry = rif_table+i;
441 while((entry=*pentry) != NULL) { 441 while((entry=*pentry) != NULL) {
@@ -467,10 +467,10 @@ static void rif_check_expire(unsigned long dummy)
467 467
468#ifdef CONFIG_PROC_FS 468#ifdef CONFIG_PROC_FS
469 469
470static struct rif_cache_s *rif_get_idx(loff_t pos) 470static struct rif_cache *rif_get_idx(loff_t pos)
471{ 471{
472 int i; 472 int i;
473 struct rif_cache_s *entry; 473 struct rif_cache *entry;
474 loff_t off = 0; 474 loff_t off = 0;
475 475
476 for(i = 0; i < RIF_TABLE_SIZE; i++) 476 for(i = 0; i < RIF_TABLE_SIZE; i++)
@@ -493,7 +493,7 @@ static void *rif_seq_start(struct seq_file *seq, loff_t *pos)
493static void *rif_seq_next(struct seq_file *seq, void *v, loff_t *pos) 493static void *rif_seq_next(struct seq_file *seq, void *v, loff_t *pos)
494{ 494{
495 int i; 495 int i;
496 struct rif_cache_s *ent = v; 496 struct rif_cache *ent = v;
497 497
498 ++*pos; 498 ++*pos;
499 499
@@ -522,7 +522,7 @@ static void rif_seq_stop(struct seq_file *seq, void *v)
522static int rif_seq_show(struct seq_file *seq, void *v) 522static int rif_seq_show(struct seq_file *seq, void *v)
523{ 523{
524 int j, rcf_len, segment, brdgnmb; 524 int j, rcf_len, segment, brdgnmb;
525 struct rif_cache_s *entry = v; 525 struct rif_cache *entry = v;
526 526
527 if (v == SEQ_START_TOKEN) 527 if (v == SEQ_START_TOKEN)
528 seq_puts(seq, 528 seq_puts(seq,
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index daebd93fd8a0..760dc8238d65 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -490,6 +490,14 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
490 /* Partially cloned skb? */ 490 /* Partially cloned skb? */
491 if (skb_shared(frag)) 491 if (skb_shared(frag))
492 goto slow_path; 492 goto slow_path;
493
494 BUG_ON(frag->sk);
495 if (skb->sk) {
496 sock_hold(skb->sk);
497 frag->sk = skb->sk;
498 frag->destructor = sock_wfree;
499 skb->truesize -= frag->truesize;
500 }
493 } 501 }
494 502
495 /* Everything is OK. Generate! */ 503 /* Everything is OK. Generate! */
diff --git a/net/ipv4/ipvs/ip_vs_xmit.c b/net/ipv4/ipvs/ip_vs_xmit.c
index faa6176bbeb1..de21da00057f 100644
--- a/net/ipv4/ipvs/ip_vs_xmit.c
+++ b/net/ipv4/ipvs/ip_vs_xmit.c
@@ -508,7 +508,6 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
508 rc = NF_ACCEPT; 508 rc = NF_ACCEPT;
509 /* do not touch skb anymore */ 509 /* do not touch skb anymore */
510 atomic_inc(&cp->in_pkts); 510 atomic_inc(&cp->in_pkts);
511 __ip_vs_conn_put(cp);
512 goto out; 511 goto out;
513 } 512 }
514 513
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 28d9425d5c39..09e824622977 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -940,37 +940,25 @@ void ip_ct_refresh_acct(struct ip_conntrack *ct,
940struct sk_buff * 940struct sk_buff *
941ip_ct_gather_frags(struct sk_buff *skb, u_int32_t user) 941ip_ct_gather_frags(struct sk_buff *skb, u_int32_t user)
942{ 942{
943 struct sock *sk = skb->sk;
944#ifdef CONFIG_NETFILTER_DEBUG 943#ifdef CONFIG_NETFILTER_DEBUG
945 unsigned int olddebug = skb->nf_debug; 944 unsigned int olddebug = skb->nf_debug;
946#endif 945#endif
947 946
948 if (sk) { 947 skb_orphan(skb);
949 sock_hold(sk);
950 skb_orphan(skb);
951 }
952 948
953 local_bh_disable(); 949 local_bh_disable();
954 skb = ip_defrag(skb, user); 950 skb = ip_defrag(skb, user);
955 local_bh_enable(); 951 local_bh_enable();
956 952
957 if (!skb) { 953 if (skb) {
958 if (sk) 954 ip_send_check(skb->nh.iph);
959 sock_put(sk); 955 skb->nfcache |= NFC_ALTERED;
960 return skb;
961 }
962
963 if (sk) {
964 skb_set_owner_w(skb, sk);
965 sock_put(sk);
966 }
967
968 ip_send_check(skb->nh.iph);
969 skb->nfcache |= NFC_ALTERED;
970#ifdef CONFIG_NETFILTER_DEBUG 956#ifdef CONFIG_NETFILTER_DEBUG
971 /* Packet path as if nothing had happened. */ 957 /* Packet path as if nothing had happened. */
972 skb->nf_debug = olddebug; 958 skb->nf_debug = olddebug;
973#endif 959#endif
960 }
961
974 return skb; 962 return skb;
975} 963}
976 964
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 79835a67a274..5bad504630a3 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4355,16 +4355,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
4355 goto no_ack; 4355 goto no_ack;
4356 } 4356 }
4357 4357
4358 if (eaten) { 4358 __tcp_ack_snd_check(sk, 0);
4359 if (tcp_in_quickack_mode(tp)) {
4360 tcp_send_ack(sk);
4361 } else {
4362 tcp_send_delayed_ack(sk);
4363 }
4364 } else {
4365 __tcp_ack_snd_check(sk, 0);
4366 }
4367
4368no_ack: 4359no_ack:
4369 if (eaten) 4360 if (eaten)
4370 __kfree_skb(skb); 4361 __kfree_skb(skb);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 0f0711417c9d..b78a53586804 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -552,13 +552,17 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
552 skb_headroom(frag) < hlen) 552 skb_headroom(frag) < hlen)
553 goto slow_path; 553 goto slow_path;
554 554
555 /* Correct socket ownership. */
556 if (frag->sk == NULL)
557 goto slow_path;
558
559 /* Partially cloned skb? */ 555 /* Partially cloned skb? */
560 if (skb_shared(frag)) 556 if (skb_shared(frag))
561 goto slow_path; 557 goto slow_path;
558
559 BUG_ON(frag->sk);
560 if (skb->sk) {
561 sock_hold(skb->sk);
562 frag->sk = skb->sk;
563 frag->destructor = sock_wfree;
564 skb->truesize -= frag->truesize;
565 }
562 } 566 }
563 567
564 err = 0; 568 err = 0;
@@ -1116,12 +1120,10 @@ int ip6_push_pending_frames(struct sock *sk)
1116 tail_skb = &(tmp_skb->next); 1120 tail_skb = &(tmp_skb->next);
1117 skb->len += tmp_skb->len; 1121 skb->len += tmp_skb->len;
1118 skb->data_len += tmp_skb->len; 1122 skb->data_len += tmp_skb->len;
1119#if 0 /* Logically correct, but useless work, ip_fragment() will have to undo */
1120 skb->truesize += tmp_skb->truesize; 1123 skb->truesize += tmp_skb->truesize;
1121 __sock_put(tmp_skb->sk); 1124 __sock_put(tmp_skb->sk);
1122 tmp_skb->destructor = NULL; 1125 tmp_skb->destructor = NULL;
1123 tmp_skb->sk = NULL; 1126 tmp_skb->sk = NULL;
1124#endif
1125 } 1127 }
1126 1128
1127 ipv6_addr_copy(final_dst, &fl->fl6_dst); 1129 ipv6_addr_copy(final_dst, &fl->fl6_dst);
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
index 601a148f60f3..6b9867717d11 100644
--- a/net/ipv6/xfrm6_output.c
+++ b/net/ipv6/xfrm6_output.c
@@ -84,6 +84,7 @@ static int xfrm6_tunnel_check_size(struct sk_buff *skb)
84 mtu = IPV6_MIN_MTU; 84 mtu = IPV6_MIN_MTU;
85 85
86 if (skb->len > mtu) { 86 if (skb->len > mtu) {
87 skb->dev = dst->dev;
87 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev); 88 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev);
88 ret = -EMSGSIZE; 89 ret = -EMSGSIZE;
89 } 90 }
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 4429b1a1fe5f..cf1d91e74c82 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -113,6 +113,8 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
113 113
114 xdst = (struct xfrm_dst *)dst1; 114 xdst = (struct xfrm_dst *)dst1;
115 xdst->route = &rt->u.dst; 115 xdst->route = &rt->u.dst;
116 if (rt->rt6i_node)
117 xdst->route_cookie = rt->rt6i_node->fn_sernum;
116 118
117 dst1->next = dst_prev; 119 dst1->next = dst_prev;
118 dst_prev = dst1; 120 dst_prev = dst1;
@@ -137,6 +139,8 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
137 139
138 dst_prev->child = &rt->u.dst; 140 dst_prev->child = &rt->u.dst;
139 dst->path = &rt->u.dst; 141 dst->path = &rt->u.dst;
142 if (rt->rt6i_node)
143 ((struct xfrm_dst *)dst)->path_cookie = rt->rt6i_node->fn_sernum;
140 144
141 *dst_p = dst; 145 *dst_p = dst;
142 dst = dst_prev; 146 dst = dst_prev;
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 733bf52cef3e..e41ce458c2a9 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -735,11 +735,15 @@ static inline int do_one_broadcast(struct sock *sk,
735 735
736 sock_hold(sk); 736 sock_hold(sk);
737 if (p->skb2 == NULL) { 737 if (p->skb2 == NULL) {
738 if (atomic_read(&p->skb->users) != 1) { 738 if (skb_shared(p->skb)) {
739 p->skb2 = skb_clone(p->skb, p->allocation); 739 p->skb2 = skb_clone(p->skb, p->allocation);
740 } else { 740 } else {
741 p->skb2 = p->skb; 741 p->skb2 = skb_get(p->skb);
742 atomic_inc(&p->skb->users); 742 /*
743 * skb ownership may have been set when
744 * delivered to a previous socket.
745 */
746 skb_orphan(p->skb2);
743 } 747 }
744 } 748 }
745 if (p->skb2 == NULL) { 749 if (p->skb2 == NULL) {
@@ -785,11 +789,12 @@ int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid,
785 sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list) 789 sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list)
786 do_one_broadcast(sk, &info); 790 do_one_broadcast(sk, &info);
787 791
792 kfree_skb(skb);
793
788 netlink_unlock_table(); 794 netlink_unlock_table();
789 795
790 if (info.skb2) 796 if (info.skb2)
791 kfree_skb(info.skb2); 797 kfree_skb(info.skb2);
792 kfree_skb(skb);
793 798
794 if (info.delivered) { 799 if (info.delivered) {
795 if (info.congested && (allocation & __GFP_WAIT)) 800 if (info.congested && (allocation & __GFP_WAIT))
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index e0c9fbe73b15..bb9bf8d5003c 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -53,7 +53,6 @@
53 53
54struct netem_sched_data { 54struct netem_sched_data {
55 struct Qdisc *qdisc; 55 struct Qdisc *qdisc;
56 struct sk_buff_head delayed;
57 struct timer_list timer; 56 struct timer_list timer;
58 57
59 u32 latency; 58 u32 latency;
@@ -63,11 +62,12 @@ struct netem_sched_data {
63 u32 gap; 62 u32 gap;
64 u32 jitter; 63 u32 jitter;
65 u32 duplicate; 64 u32 duplicate;
65 u32 reorder;
66 66
67 struct crndstate { 67 struct crndstate {
68 unsigned long last; 68 unsigned long last;
69 unsigned long rho; 69 unsigned long rho;
70 } delay_cor, loss_cor, dup_cor; 70 } delay_cor, loss_cor, dup_cor, reorder_cor;
71 71
72 struct disttable { 72 struct disttable {
73 u32 size; 73 u32 size;
@@ -137,122 +137,68 @@ static long tabledist(unsigned long mu, long sigma,
137 return x / NETEM_DIST_SCALE + (sigma / NETEM_DIST_SCALE) * t + mu; 137 return x / NETEM_DIST_SCALE + (sigma / NETEM_DIST_SCALE) * t + mu;
138} 138}
139 139
140/* Put skb in the private delayed queue. */
141static int netem_delay(struct Qdisc *sch, struct sk_buff *skb)
142{
143 struct netem_sched_data *q = qdisc_priv(sch);
144 psched_tdiff_t td;
145 psched_time_t now;
146
147 PSCHED_GET_TIME(now);
148 td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
149
150 /* Always queue at tail to keep packets in order */
151 if (likely(q->delayed.qlen < q->limit)) {
152 struct netem_skb_cb *cb = (struct netem_skb_cb *)skb->cb;
153
154 PSCHED_TADD2(now, td, cb->time_to_send);
155
156 pr_debug("netem_delay: skb=%p now=%llu tosend=%llu\n", skb,
157 now, cb->time_to_send);
158
159 __skb_queue_tail(&q->delayed, skb);
160 return NET_XMIT_SUCCESS;
161 }
162
163 pr_debug("netem_delay: queue over limit %d\n", q->limit);
164 sch->qstats.overlimits++;
165 kfree_skb(skb);
166 return NET_XMIT_DROP;
167}
168
169/* 140/*
170 * Move a packet that is ready to send from the delay holding 141 * Insert one skb into qdisc.
171 * list to the underlying qdisc. 142 * Note: parent depends on return value to account for queue length.
143 * NET_XMIT_DROP: queue length didn't change.
144 * NET_XMIT_SUCCESS: one skb was queued.
172 */ 145 */
173static int netem_run(struct Qdisc *sch)
174{
175 struct netem_sched_data *q = qdisc_priv(sch);
176 struct sk_buff *skb;
177 psched_time_t now;
178
179 PSCHED_GET_TIME(now);
180
181 skb = skb_peek(&q->delayed);
182 if (skb) {
183 const struct netem_skb_cb *cb
184 = (const struct netem_skb_cb *)skb->cb;
185 long delay
186 = PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
187 pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
188
189 /* if more time remaining? */
190 if (delay > 0) {
191 mod_timer(&q->timer, jiffies + delay);
192 return 1;
193 }
194
195 __skb_unlink(skb, &q->delayed);
196
197 if (q->qdisc->enqueue(skb, q->qdisc)) {
198 sch->q.qlen--;
199 sch->qstats.drops++;
200 }
201 }
202
203 return 0;
204}
205
206static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) 146static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
207{ 147{
208 struct netem_sched_data *q = qdisc_priv(sch); 148 struct netem_sched_data *q = qdisc_priv(sch);
149 struct netem_skb_cb *cb = (struct netem_skb_cb *)skb->cb;
150 struct sk_buff *skb2;
209 int ret; 151 int ret;
152 int count = 1;
210 153
211 pr_debug("netem_enqueue skb=%p\n", skb); 154 pr_debug("netem_enqueue skb=%p\n", skb);
212 155
156 /* Random duplication */
157 if (q->duplicate && q->duplicate >= get_crandom(&q->dup_cor))
158 ++count;
159
213 /* Random packet drop 0 => none, ~0 => all */ 160 /* Random packet drop 0 => none, ~0 => all */
214 if (q->loss && q->loss >= get_crandom(&q->loss_cor)) { 161 if (q->loss && q->loss >= get_crandom(&q->loss_cor))
215 pr_debug("netem_enqueue: random loss\n"); 162 --count;
163
164 if (count == 0) {
216 sch->qstats.drops++; 165 sch->qstats.drops++;
217 kfree_skb(skb); 166 kfree_skb(skb);
218 return 0; /* lie about loss so TCP doesn't know */ 167 return NET_XMIT_DROP;
219 } 168 }
220 169
221 /* Random duplication */ 170 /*
222 if (q->duplicate && q->duplicate >= get_crandom(&q->dup_cor)) { 171 * If we need to duplicate packet, then re-insert at top of the
223 struct sk_buff *skb2; 172 * qdisc tree, since parent queuer expects that only one
224 173 * skb will be queued.
225 skb2 = skb_clone(skb, GFP_ATOMIC); 174 */
226 if (skb2 && netem_delay(sch, skb2) == NET_XMIT_SUCCESS) { 175 if (count > 1 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
227 struct Qdisc *qp; 176 struct Qdisc *rootq = sch->dev->qdisc;
228 177 u32 dupsave = q->duplicate; /* prevent duplicating a dup... */
229 /* Since one packet can generate two packets in the 178 q->duplicate = 0;
230 * queue, the parent's qlen accounting gets confused, 179
231 * so fix it. 180 rootq->enqueue(skb2, rootq);
232 */ 181 q->duplicate = dupsave;
233 qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
234 if (qp)
235 qp->q.qlen++;
236
237 sch->q.qlen++;
238 sch->bstats.bytes += skb2->len;
239 sch->bstats.packets++;
240 } else
241 sch->qstats.drops++;
242 } 182 }
243 183
244 /* If doing simple delay then gap == 0 so all packets 184 if (q->gap == 0 /* not doing reordering */
245 * go into the delayed holding queue 185 || q->counter < q->gap /* inside last reordering gap */
246 * otherwise if doing out of order only "1 out of gap" 186 || q->reorder < get_crandom(&q->reorder_cor)) {
247 * packets will be delayed. 187 psched_time_t now;
248 */ 188 PSCHED_GET_TIME(now);
249 if (q->counter < q->gap) { 189 PSCHED_TADD2(now, tabledist(q->latency, q->jitter,
190 &q->delay_cor, q->delay_dist),
191 cb->time_to_send);
250 ++q->counter; 192 ++q->counter;
251 ret = q->qdisc->enqueue(skb, q->qdisc); 193 ret = q->qdisc->enqueue(skb, q->qdisc);
252 } else { 194 } else {
195 /*
196 * Do re-ordering by putting one out of N packets at the front
197 * of the queue.
198 */
199 PSCHED_GET_TIME(cb->time_to_send);
253 q->counter = 0; 200 q->counter = 0;
254 ret = netem_delay(sch, skb); 201 ret = q->qdisc->ops->requeue(skb, q->qdisc);
255 netem_run(sch);
256 } 202 }
257 203
258 if (likely(ret == NET_XMIT_SUCCESS)) { 204 if (likely(ret == NET_XMIT_SUCCESS)) {
@@ -296,22 +242,33 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
296{ 242{
297 struct netem_sched_data *q = qdisc_priv(sch); 243 struct netem_sched_data *q = qdisc_priv(sch);
298 struct sk_buff *skb; 244 struct sk_buff *skb;
299 int pending;
300
301 pending = netem_run(sch);
302 245
303 skb = q->qdisc->dequeue(q->qdisc); 246 skb = q->qdisc->dequeue(q->qdisc);
304 if (skb) { 247 if (skb) {
305 pr_debug("netem_dequeue: return skb=%p\n", skb); 248 const struct netem_skb_cb *cb
306 sch->q.qlen--; 249 = (const struct netem_skb_cb *)skb->cb;
307 sch->flags &= ~TCQ_F_THROTTLED; 250 psched_time_t now;
308 } 251 long delay;
309 else if (pending) { 252
310 pr_debug("netem_dequeue: throttling\n"); 253 /* if more time remaining? */
254 PSCHED_GET_TIME(now);
255 delay = PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
256 pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
257 if (delay <= 0) {
258 pr_debug("netem_dequeue: return skb=%p\n", skb);
259 sch->q.qlen--;
260 sch->flags &= ~TCQ_F_THROTTLED;
261 return skb;
262 }
263
264 mod_timer(&q->timer, jiffies + delay);
311 sch->flags |= TCQ_F_THROTTLED; 265 sch->flags |= TCQ_F_THROTTLED;
312 }
313 266
314 return skb; 267 if (q->qdisc->ops->requeue(skb, q->qdisc) != 0)
268 sch->qstats.drops++;
269 }
270
271 return NULL;
315} 272}
316 273
317static void netem_watchdog(unsigned long arg) 274static void netem_watchdog(unsigned long arg)
@@ -328,8 +285,6 @@ static void netem_reset(struct Qdisc *sch)
328 struct netem_sched_data *q = qdisc_priv(sch); 285 struct netem_sched_data *q = qdisc_priv(sch);
329 286
330 qdisc_reset(q->qdisc); 287 qdisc_reset(q->qdisc);
331 skb_queue_purge(&q->delayed);
332
333 sch->q.qlen = 0; 288 sch->q.qlen = 0;
334 sch->flags &= ~TCQ_F_THROTTLED; 289 sch->flags &= ~TCQ_F_THROTTLED;
335 del_timer_sync(&q->timer); 290 del_timer_sync(&q->timer);
@@ -397,6 +352,19 @@ static int get_correlation(struct Qdisc *sch, const struct rtattr *attr)
397 return 0; 352 return 0;
398} 353}
399 354
355static int get_reorder(struct Qdisc *sch, const struct rtattr *attr)
356{
357 struct netem_sched_data *q = qdisc_priv(sch);
358 const struct tc_netem_reorder *r = RTA_DATA(attr);
359
360 if (RTA_PAYLOAD(attr) != sizeof(*r))
361 return -EINVAL;
362
363 q->reorder = r->probability;
364 init_crandom(&q->reorder_cor, r->correlation);
365 return 0;
366}
367
400static int netem_change(struct Qdisc *sch, struct rtattr *opt) 368static int netem_change(struct Qdisc *sch, struct rtattr *opt)
401{ 369{
402 struct netem_sched_data *q = qdisc_priv(sch); 370 struct netem_sched_data *q = qdisc_priv(sch);
@@ -417,9 +385,15 @@ static int netem_change(struct Qdisc *sch, struct rtattr *opt)
417 q->jitter = qopt->jitter; 385 q->jitter = qopt->jitter;
418 q->limit = qopt->limit; 386 q->limit = qopt->limit;
419 q->gap = qopt->gap; 387 q->gap = qopt->gap;
388 q->counter = 0;
420 q->loss = qopt->loss; 389 q->loss = qopt->loss;
421 q->duplicate = qopt->duplicate; 390 q->duplicate = qopt->duplicate;
422 391
392 /* for compatiablity with earlier versions.
393 * if gap is set, need to assume 100% probablity
394 */
395 q->reorder = ~0;
396
423 /* Handle nested options after initial queue options. 397 /* Handle nested options after initial queue options.
424 * Should have put all options in nested format but too late now. 398 * Should have put all options in nested format but too late now.
425 */ 399 */
@@ -441,6 +415,11 @@ static int netem_change(struct Qdisc *sch, struct rtattr *opt)
441 if (ret) 415 if (ret)
442 return ret; 416 return ret;
443 } 417 }
418 if (tb[TCA_NETEM_REORDER-1]) {
419 ret = get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
420 if (ret)
421 return ret;
422 }
444 } 423 }
445 424
446 425
@@ -455,11 +434,9 @@ static int netem_init(struct Qdisc *sch, struct rtattr *opt)
455 if (!opt) 434 if (!opt)
456 return -EINVAL; 435 return -EINVAL;
457 436
458 skb_queue_head_init(&q->delayed);
459 init_timer(&q->timer); 437 init_timer(&q->timer);
460 q->timer.function = netem_watchdog; 438 q->timer.function = netem_watchdog;
461 q->timer.data = (unsigned long) sch; 439 q->timer.data = (unsigned long) sch;
462 q->counter = 0;
463 440
464 q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops); 441 q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
465 if (!q->qdisc) { 442 if (!q->qdisc) {
@@ -491,6 +468,7 @@ static int netem_dump(struct Qdisc *sch, struct sk_buff *skb)
491 struct rtattr *rta = (struct rtattr *) b; 468 struct rtattr *rta = (struct rtattr *) b;
492 struct tc_netem_qopt qopt; 469 struct tc_netem_qopt qopt;
493 struct tc_netem_corr cor; 470 struct tc_netem_corr cor;
471 struct tc_netem_reorder reorder;
494 472
495 qopt.latency = q->latency; 473 qopt.latency = q->latency;
496 qopt.jitter = q->jitter; 474 qopt.jitter = q->jitter;
@@ -504,6 +482,11 @@ static int netem_dump(struct Qdisc *sch, struct sk_buff *skb)
504 cor.loss_corr = q->loss_cor.rho; 482 cor.loss_corr = q->loss_cor.rho;
505 cor.dup_corr = q->dup_cor.rho; 483 cor.dup_corr = q->dup_cor.rho;
506 RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor); 484 RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
485
486 reorder.probability = q->reorder;
487 reorder.correlation = q->reorder_cor.rho;
488 RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
489
507 rta->rta_len = skb->tail - b; 490 rta->rta_len = skb->tail - b;
508 491
509 return skb->len; 492 return skb->len;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index c478fc8db776..c420eba4876b 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -770,33 +770,12 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
770 err = path_lookup(sunaddr->sun_path, LOOKUP_PARENT, &nd); 770 err = path_lookup(sunaddr->sun_path, LOOKUP_PARENT, &nd);
771 if (err) 771 if (err)
772 goto out_mknod_parent; 772 goto out_mknod_parent;
773 /* 773
774 * Yucky last component or no last component at all? 774 dentry = lookup_create(&nd, 0);
775 * (foo/., foo/.., /////)
776 */
777 err = -EEXIST;
778 if (nd.last_type != LAST_NORM)
779 goto out_mknod;
780 /*
781 * Lock the directory.
782 */
783 down(&nd.dentry->d_inode->i_sem);
784 /*
785 * Do the final lookup.
786 */
787 dentry = lookup_hash(&nd.last, nd.dentry);
788 err = PTR_ERR(dentry); 775 err = PTR_ERR(dentry);
789 if (IS_ERR(dentry)) 776 if (IS_ERR(dentry))
790 goto out_mknod_unlock; 777 goto out_mknod_unlock;
791 err = -ENOENT; 778
792 /*
793 * Special case - lookup gave negative, but... we had foo/bar/
794 * From the vfs_mknod() POV we just have a negative dentry -
795 * all is fine. Let's be bastards - you had / on the end, you've
796 * been asking for (non-existent) directory. -ENOENT for you.
797 */
798 if (nd.last.name[nd.last.len] && !dentry->d_inode)
799 goto out_mknod_dput;
800 /* 779 /*
801 * All right, let's create it. 780 * All right, let's create it.
802 */ 781 */
@@ -845,7 +824,6 @@ out_mknod_dput:
845 dput(dentry); 824 dput(dentry);
846out_mknod_unlock: 825out_mknod_unlock:
847 up(&nd.dentry->d_inode->i_sem); 826 up(&nd.dentry->d_inode->i_sem);
848out_mknod:
849 path_release(&nd); 827 path_release(&nd);
850out_mknod_parent: 828out_mknod_parent:
851 if (err==-EEXIST) 829 if (err==-EEXIST)
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
index 080aae243ce0..2f4531fcaca2 100644
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -698,7 +698,7 @@ int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer)
698 return -ENOMEM; 698 return -ENOMEM;
699 699
700 if (skb1->sk) 700 if (skb1->sk)
701 skb_set_owner_w(skb, skb1->sk); 701 skb_set_owner_w(skb2, skb1->sk);
702 702
703 /* Looking around. Are we still alive? 703 /* Looking around. Are we still alive?
704 * OK, link new skb, drop old one */ 704 * OK, link new skb, drop old one */
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 55ed979db144..d07f5ce31824 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1136,7 +1136,7 @@ int xfrm_bundle_ok(struct xfrm_dst *first, struct flowi *fl, int family)
1136 struct xfrm_dst *last; 1136 struct xfrm_dst *last;
1137 u32 mtu; 1137 u32 mtu;
1138 1138
1139 if (!dst_check(dst->path, 0) || 1139 if (!dst_check(dst->path, ((struct xfrm_dst *)dst)->path_cookie) ||
1140 (dst->dev && !netif_running(dst->dev))) 1140 (dst->dev && !netif_running(dst->dev)))
1141 return 0; 1141 return 0;
1142 1142
@@ -1156,7 +1156,7 @@ int xfrm_bundle_ok(struct xfrm_dst *first, struct flowi *fl, int family)
1156 xdst->child_mtu_cached = mtu; 1156 xdst->child_mtu_cached = mtu;
1157 } 1157 }
1158 1158
1159 if (!dst_check(xdst->route, 0)) 1159 if (!dst_check(xdst->route, xdst->route_cookie))
1160 return 0; 1160 return 0;
1161 mtu = dst_mtu(xdst->route); 1161 mtu = dst_mtu(xdst->route);
1162 if (xdst->route_mtu_cached != mtu) { 1162 if (xdst->route_mtu_cached != mtu) {
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 5ddda2c98af9..97509011c274 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -34,14 +34,21 @@ static int verify_one_alg(struct rtattr **xfrma, enum xfrm_attr_type_t type)
34{ 34{
35 struct rtattr *rt = xfrma[type - 1]; 35 struct rtattr *rt = xfrma[type - 1];
36 struct xfrm_algo *algp; 36 struct xfrm_algo *algp;
37 int len;
37 38
38 if (!rt) 39 if (!rt)
39 return 0; 40 return 0;
40 41
41 if ((rt->rta_len - sizeof(*rt)) < sizeof(*algp)) 42 len = (rt->rta_len - sizeof(*rt)) - sizeof(*algp);
43 if (len < 0)
42 return -EINVAL; 44 return -EINVAL;
43 45
44 algp = RTA_DATA(rt); 46 algp = RTA_DATA(rt);
47
48 len -= (algp->alg_key_len + 7U) / 8;
49 if (len < 0)
50 return -EINVAL;
51
45 switch (type) { 52 switch (type) {
46 case XFRMA_ALG_AUTH: 53 case XFRMA_ALG_AUTH:
47 if (!algp->alg_key_len && 54 if (!algp->alg_key_len &&
@@ -162,6 +169,7 @@ static int attach_one_algo(struct xfrm_algo **algpp, u8 *props,
162 struct rtattr *rta = u_arg; 169 struct rtattr *rta = u_arg;
163 struct xfrm_algo *p, *ualg; 170 struct xfrm_algo *p, *ualg;
164 struct xfrm_algo_desc *algo; 171 struct xfrm_algo_desc *algo;
172 int len;
165 173
166 if (!rta) 174 if (!rta)
167 return 0; 175 return 0;
@@ -173,11 +181,12 @@ static int attach_one_algo(struct xfrm_algo **algpp, u8 *props,
173 return -ENOSYS; 181 return -ENOSYS;
174 *props = algo->desc.sadb_alg_id; 182 *props = algo->desc.sadb_alg_id;
175 183
176 p = kmalloc(sizeof(*ualg) + ualg->alg_key_len, GFP_KERNEL); 184 len = sizeof(*ualg) + (ualg->alg_key_len + 7U) / 8;
185 p = kmalloc(len, GFP_KERNEL);
177 if (!p) 186 if (!p)
178 return -ENOMEM; 187 return -ENOMEM;
179 188
180 memcpy(p, ualg, sizeof(*ualg) + ualg->alg_key_len); 189 memcpy(p, ualg, len);
181 *algpp = p; 190 *algpp = p;
182 return 0; 191 return 0;
183} 192}
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 5a820cf88c9c..8449d667b062 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -476,8 +476,8 @@ int security_compute_av(u32 ssid,
476 int rc = 0; 476 int rc = 0;
477 477
478 if (!ss_initialized) { 478 if (!ss_initialized) {
479 avd->allowed = requested; 479 avd->allowed = 0xffffffff;
480 avd->decided = requested; 480 avd->decided = 0xffffffff;
481 avd->auditallow = 0; 481 avd->auditallow = 0;
482 avd->auditdeny = 0xffffffff; 482 avd->auditdeny = 0xffffffff;
483 avd->seqno = latest_granting; 483 avd->seqno = latest_granting;
@@ -1196,9 +1196,11 @@ int security_load_policy(void *data, size_t len)
1196 } 1196 }
1197 policydb_loaded_version = policydb.policyvers; 1197 policydb_loaded_version = policydb.policyvers;
1198 ss_initialized = 1; 1198 ss_initialized = 1;
1199 1199 seqno = ++latest_granting;
1200 LOAD_UNLOCK; 1200 LOAD_UNLOCK;
1201 selinux_complete_init(); 1201 selinux_complete_init();
1202 avc_ss_reset(seqno);
1203 selnl_notify_policyload(seqno);
1202 return 0; 1204 return 0;
1203 } 1205 }
1204 1206